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:

  1. I've created a Search Index using Search API's SOLR capabilities and have based my view on that Index.
  2. I've added the GeoField Map Format to the view
  3. 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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikemadison’s picture

Here is a patch to handle the above

Status: Needs review » Needs work
mikemadison’s picture

anrikun’s picture

Version: 7.x-3.7 » 7.x-3.x-dev
Priority: Minor » Normal
Issue summary: View changes

This patch has 2 problems:
- Function should return array() instead of FALSE.
- Wrong code formatting

anrikun’s picture

Component: Code » fieldapi data
Status: Needs work » Needs review
FileSize
670 bytes

Here's an updated patch.

anrikun’s picture

Title: Fata Error: __clone method called on non-object » Fatal Error: __clone method called on non-object
mikemadison’s picture

Issue summary: View changes
marcoscano’s picture

Status: Needs review » Reviewed & tested by the community

Same 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

david_garcia’s picture

Same thing here with FIELD COLLECTION and using relationships.

Patch #5 solved the issue.

schulle@web.de’s picture

Same 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.

brandy.brown’s picture

--- fixed my problem ---

DrCord’s picture

patch in #5 worked for me fine. I was experiencing the problem with a field collection.

ashzade’s picture

Patch 5 fixed my issue. Thanks!

veerasekar89’s picture

Patch #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)

revagomes’s picture

Issue summary: View changes
bisonbleu’s picture

Ran into this issue. My scenario: geofield, leaflet, search_api (Database service).

Fatal error: __clone method called on non-object in /Applications/MAMP/htdocs/rcq1/sites/all/modules/views/modules/field/views_handler_field_field.inc on line 720

The strange part: this combination has been working without issues for more than 2 weeks. The fatal error appeared after the following:

  • adding place holder pages with dummy lipsum with main menu entries
  • enabling the Contact module
  • disabling views-created main menu entries and replacing them with similar entries in the management menu

Patch in #5 fixes this issue

bisonbleu’s picture

I 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

  • first, changing all Normal menu entries to Menu tabs
  • second, saving the view
  • third, setting Menu settings back to No menu before saving again

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!

nattyweb’s picture

patch #5 worked for me on views-7.x-3.10 with Drupal 7.34. Thank you!

glynster’s picture

Any chance we can get this committed to the latest production version of views?

imperator_99’s picture

Patch in #5 fixed my issue - would love to see this in Views production.

FMB’s picture

Confirm it solved the problem with a view based on a Search API index and a Leaflet display.

nattyweb’s picture

Patch in #5 just re-applied - I'd over-written it with an update to Views. Duh. Many thanks @anrikun.

  • colan committed 21fd8f9 on 7.x-3.x authored by anrikun
    Issue #2115269 by lalweil, anrikun: Check for entity in...
colan’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone! It's now in dev.

colan’s picture

glynster’s picture

Great news!

colan’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 8.0.x-dev
Component: fieldapi data » views.module
Status: Fixed » Patch (to be ported)
jhedstrom’s picture

Status: Patch (to be ported) » Postponed (maintainer needs more info)

I don't think this is relevant to D8?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelpittet’s picture

Project: Drupal core » Views (for Drupal 7)
Version: 8.2.x-dev » 7.x-3.x-dev
Component: views.module » Code
Status: Postponed (maintainer needs more info) » Fixed

There is no clone of the entity on the field in D8 on FieldPluginBase.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.