Problem/Motivation
This bug really could belong to views, Search API, or GeoField. However, since the error comes up based on a views file and the attached patch seems to correct the problem.
Situation:
- I've created a Search Index using Search API's SOLR capabilities and have based my view on that Index.
- I've added the GeoField Map Format to the view
- I've added the GeoField coordinates field to the view
At this point, I start getting the following error both in AJAX in views and on a WSOD if I save the view and load the page:
Fatal error: __clone method called on non-object in /drupal/sites/all/modules/views/modules/field/views_handler_field_field.inc on line 720
Proposed resolution
After examining this code, it looks like it blindly assumes that the $entity value can be set. So, I just added a quick bit of verification to the code to make sure that what we are looking at both exists and that it is an object.
This seems to resolve the problem.
if (isset($values->_field_data[$this->field_alias]['entity']) && is_object($values->_field_data[$this->field_alias]['entity'])) {
$entity = clone $values->_field_data[$this->field_alias]['entity'] ;
} else {
return false;
}
Remaining tasks
None.
User interface changes
None.
API changes
None.
Comments
Comment #1
mikemadison CreditAttribution: mikemadison commentedHere is a patch to handle the above
Comment #3
mikemadison CreditAttribution: mikemadison commentedResubmitting
Comment #4
anrikun CreditAttribution: anrikun commentedThis patch has 2 problems:
- Function should return array() instead of FALSE.
- Wrong code formatting
Comment #5
anrikun CreditAttribution: anrikun commentedHere's an updated patch.
Comment #6
anrikun CreditAttribution: anrikun commentedComment #7
mikemadison CreditAttribution: mikemadison commentedComment #8
marcoscanoSame problem here, with scenario:
- view of profile2 entities, each one with an entityreference field pointing to a node which has a geofield
- building a display of type "leaflet map", using the geofiled mentioned before
Patch in #5 solved the problem for me, so marking as RTBC
Comment #11
david_garcia CreditAttribution: david_garcia commentedSame thing here with FIELD COLLECTION and using relationships.
Patch #5 solved the issue.
Comment #12
schulle@web.de CreditAttribution: schulle@web.de commentedSame error with view pane on custom node view page.
Patch #5 solved the issue. I use the most current beta version and edited the file manually.
Comment #13
brandy.brown CreditAttribution: brandy.brown commented--- fixed my problem ---
Comment #14
DrCord CreditAttribution: DrCord commentedpatch in #5 worked for me fine. I was experiencing the problem with a field collection.
Comment #16
ashzade CreditAttribution: ashzade commentedPatch 5 fixed my issue. Thanks!
Comment #17
veerasekar89 CreditAttribution: veerasekar89 commentedPatch #5 works - resolved integration with views aggregation plus. (when there is no data and we are trying to clone the view, with this patch the error is removed)
Comment #18
revagomes CreditAttribution: revagomes commentedComment #19
bisonbleu CreditAttribution: bisonbleu commentedRan into this issue. My scenario: geofield, leaflet, search_api (Database service).
The strange part: this combination has been working without issues for more than 2 weeks. The fatal error appeared after the following:
Patch in #5 fixes this issue
Comment #20
bisonbleu CreditAttribution: bisonbleu commentedI thought the error in #19 was linked to Views/Page settings/Menu.
Because of an unresolved bug in core, the best advice seems to be: never add a menu entry in Views. Is is safer to do it from the menu UI (e.g. admin/structure/menu/manage/main-menu) from where it can be properly deleted if required.
So I was able to fix the fatal error without 7.x-3.x-dev and without the patch in #5 by:
In Views UI
Wishful thinking. The minute I created a basic page with dummy content the fatal error reappeared.
Applying the patch in #5 to views-7.x-3.10 fixes my issue.
Thanks all!
Comment #21
nattyweb CreditAttribution: nattyweb commentedpatch #5 worked for me on views-7.x-3.10 with Drupal 7.34. Thank you!
Comment #22
glynster CreditAttribution: glynster commentedAny chance we can get this committed to the latest production version of views?
Comment #23
imperator_99 CreditAttribution: imperator_99 commentedPatch in #5 fixed my issue - would love to see this in Views production.
Comment #24
FMB CreditAttribution: FMB commentedConfirm it solved the problem with a view based on a Search API index and a Leaflet display.
Comment #25
nattyweb CreditAttribution: nattyweb commentedPatch in #5 just re-applied - I'd over-written it with an update to Views. Duh. Many thanks @anrikun.
Comment #27
colanThanks everyone! It's now in dev.
Comment #28
colanComment #29
glynster CreditAttribution: glynster commentedGreat news!
Comment #30
colanComment #31
jhedstromI don't think this is relevant to D8?
Comment #34
joelpittetThere is no
clone
of the entity on the field in D8 on FieldPluginBase.