when i try to revert a feature that contains a view i sometimes get this beaty:

Fatal error: Call to a member function delete() on a non-object in
/data/disk/o4390052107/static/platforms/geekroyale-d7-004/sites/all/modules/contrib/views/views.module on line 1463

so who should i assign blame (and bribes to) ? views or features

Comments

mortendk’s picture

actually this happens if i wanna update an existing view - am i the only one that gets this error

merilainen’s picture

Nope, I have the same problem. I'm using dev-version of Views at the moment. Which is why the call happens on a different line, 1550.

tbenice’s picture

I had the same exact problem and clear-cache all allowed the feature to revert. Try that.

febbraro’s picture

Status: Active » Postponed (maintainer needs more info)

Is this still a problem? I can't reproduce.

diricia’s picture

I have this problem.

My views are in my feature. However when I revert, I get the fatal error. When I do a drush cc all - the error disappears and the view is in list of views. If I do another drush cc all (nothing else) the views disappear from the list (database)

Attached sequence, screen shots and feature.

Screen shot 1 shows the views are not in the list

$ drush fr simplybiz_job_spheres
Do you really want to revert views_view? (y/n): y
Fatal error: Call to a member function delete() on a non-object in /var/aegir/platforms/bc77_stage_20110901/sites/all/modules/contrib/views/views.module on line 1463
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Call to a member function delete() on a non-object in /var/aegir/platforms/bc77_stage_20110901/sites/all/modules/contrib/views/views.module, line 1463

$ drush cc all
'all' cache was cleared [success]

$ drush fr simplybiz_job_spheres
Do you really want to revert context? (y/n): y
Reverted context. [ok]

Notice above that I'm not asked if I want to revert the views. Screen shot 2 shows the views are now in the list

$ drush cc all
'all' cache was cleared

Screen shot 3 shows the views have disappeared again

I would suggest removing the menu, context, strong arm and user permissions files from the feature. I've left them in for completeness

diricia’s picture

My problem was solved by using the development version of views.

febbraro’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Ok sounds good, it this is still a problem reopen.

mrfelton’s picture

Nothing to add - Just confirmation that I had the same problem, and upgrading Views to latest dev code resolved the problem.

mrfelton’s picture

Status: Closed (cannot reproduce) » Active

Nah, sorry. I still get this a lot. It seems to happen when I add a new to an existing feature, and then try and revert the review on another copy of the site to pull in the new view. I can't work out the exact steps to revolve, but it involved clearing the registry and the cache a number of times

mrfelton’s picture

See #1331656: Components from Features that contain field_collection views go missing for another description of the problem, and the steps to resolve (run drush fl, clear cache and then run drush fl again). This only seems to affect field_collection views, which is why I posted the issue over there. But I suspect the problem is with Views.

mrfelton’s picture

StatusFileSize
new4.4 KB

Attached is the feature that is giving me the problem.

Views 7.x-3.x-dev with #1032836: Call to a member function unpack_translatables() on a non-object applied
Features 1.0-beta4 with #813760: CTools Page manager pages do not revert properly applied
CTools 7.x-1.x-dev with #1275886: Error - Notice: Trying to get property of non-object in menu_block_view_alter() applied

tim.plunkett’s picture

Priority: Normal » Major

The circumstances where I can reproduce:

Create a feature with a panel.
Create a view with a content pane, add the content pane to the view, add the view to the feature.
Commit that code, deploy it.
On a site with a clean database that never knew that view existed, get the new code and revert the feature.

ctools_component_features_revert() attempts to load an object with ctools_export_crud_load(), and then calls _ctools_features_export_crud_delete() on it without checking to see if it is not an object.

In the case of a new view, the object doesn't exist yet, hence the error.

The workaround is to create a dummy view on the clean site, merely to revert it.

eMuse_be’s picture

#3 did the trick: clear cache

drzraf’s picture

I can reproduce and confirm that the clear-cache workaround works,
but still an issue anyway.

PHP Fatal error:  Call to a member function delete() on a non-object in /drupal/sites/all/modules/views/views.module on line 1556
PHP Stack trace:
PHP   1. {main}() /drush/drush.php:0
PHP   2. drush_main() /drush/drush.php:14
PHP   3. _drush_bootstrap_and_dispatch() /drush/drush.php:58
PHP   4. drush_dispatch() /drush/drush.php:89
PHP   5. call_user_func_array() /drush/includes/command.inc:129
PHP   6. drush_command() /drush/includes/command.inc:129
PHP   7. _drush_invoke_hooks() /drush/includes/command.inc:162
PHP   8. call_user_func_array() /drush/includes/command.inc:291
PHP   9. drush_features_revert() /drush/includes/command.inc:291
PHP  10. features_revert() /drupal/sites/all/modules/features/features.drush.inc:503
PHP  11. _features_restore() /drupal/sites/all/modules/features/features.module:811
PHP  12. features_invoke() /drupal/sites/all/modules/features/features.module:796
PHP  13. call_user_func_array() /drupal/sites/all/modules/features/features.module:440
PHP  14. views_view_features_revert() /drupal/sites/all/modules/features/features.module:440
PHP  15. ctools_component_features_revert() /drupal/sites/all/modules/features/includes/features.ctools.inc(26) : eval()'d code:1
PHP  16. _ctools_features_export_crud_delete() /drupal/sites/all/modules/features/includes/features.ctools.inc:209
PHP  17. ctools_export_crud_delete() /drupal/sites/all/modules/features/includes/features.ctools.inc:312

The problems is around ctools_export_crud_load();
I've CTOOLS_API_VERSION = 2.0.4, so that's what _ctools_features_export_crud_load calls.

[edit] Further down the road, ctools_export_load_object (/modules/ctools/includes/export.inc):
It is called with correct args: table = views_view, name = vassoc but it returns an empty array();
Maybe ctools people may help here ?

hefox’s picture

Oh, I've seen this error also though I was doing something funny to produce it, if I recall correctly. Some error checking is all that's needed to fix it, if I recall correctly.

bradjones1’s picture

Given how the symptoms of this problem mimic #1331656: Components from Features that contain field_collection views go missing (linked above in #10), I am wondering if this isn't a byproduct of #994140: Modify .module file when a features.inc is added, which solved that problem and (so far) this one, too.

Can anyone look at the affected .module files and see if they're missing a feature_name.features.inc include? Would be great to mark this as duplicate and chalk this up to a relatively simple problem.

alanmackenzie’s picture

I can confirm that drush cc all fixed this issue for me.

The feature I was reverting has always had the feature_name.features.inc include statement in the .module file.

imiksu’s picture

drush cc all helped me too :)

nicholasthompson’s picture

A cache clear helped here too...

bradjones1’s picture

Status: Active » Closed (cannot reproduce)

Going to close this as can't reproduce based on the past 4 comments (plus others above)... if someone can post a guide to reproducing this on a clean install, please do and re-open.

Volx’s picture

Status: Closed (cannot reproduce) » Active
StatusFileSize
new595 bytes

I saw the same error while doing pretty much the same as comment #12. It contains a step-by-step guide to reproduce and actually nails down the error in my opinion, that is ctools_component_features_revert trying to delete an object that does not exist. A simple check fixes the error at least for this case. Patch is attached.

And like I already said here http://drupal.org/node/813760#comment-3700694 , I think that the Features integration of ctools components should be handled within the ctools module to avoid problems like this one.

kirie’s picture

I encountered the same issue, and while the patch in #21 made the error go away - it did not fix the issue. In my setup I also noticed that I would sometimes get the following warning (I'm using Drush):

myfeature.module does not appear to include the myfeature.features.inc file.

After a bit of searching found this isuse: #994140: Modify .module file when a features.inc is added

After manually adding include_once('myfeature.features.inc'); to my myfeature.module I have had no issues, and I can now revert my features again.

dawehner’s picture

Status: Active » Needs review

Update status.

In general this should fix the issue, though it's a question whether this is the actual right place to fix that.
Maybe there is a real bug behind this, when the objects can be loaded, thought this is much harder to find out.

wiifm’s picture

Had exactly the same issue on #1481150: PHP Fatal error: Call to a member function delete() on a non-object [views.module on line 1566] - and the patch in #21 seems like it is very like mine.

(on a related note, it is nice to see we would solve it the same way)

This is a critical bug for our sites, as aegir will fail to install the site is PHP throws a fatal during the installation.

kirie’s picture

I encountered the same problem (again) - and applying the patch in #21 fixed the problem. The problem occurred when I tried to revert a feature which added a new view (the first and only view for that feature) - pretty similar to #12, albeit without the panel part.

wiifm’s picture

Status: Needs review » Reviewed & tested by the community

Can #21 be committed, it goes a long way to address the immediate concerns of a lot of people. Have tested the patch and can confirm our intall profile does work with it applied (and horribly not on stock beta 6)

hefox’s picture

StatusFileSize
new679 bytes

This seems like a correct solution to me, however I'm thinking it should also add a check for $object->export_type & EXPORT_IN_DATABASE so it only runs on overridden objects.

That patch attached.

21 is still rtbc, but this patch may be more useful.

tim.plunkett’s picture

+++ b/includes/features.ctools.incundefined
@@ -206,7 +206,9 @@ function ctools_component_features_revert($component, $module) {
+      if ($object && $object->export_type & EXPORT_IN_DATABASE) {

Oh bitwise operators. I think the second half should be wrapped in parentheses for clarity, otherwise this looks fine

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

Committed with additional parens as per tim.plunkett. db61d14

Status: Fixed » Closed (fixed)

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