I'm seeing some extraneous items in Views overrides. Exporting and saving these overrides doesn't actually break anything, but I'd still like to identify where they're coming from. Don't have an example on hand, will update when I do.

CommentFileSizeAuthor
#1 features-override-1083354-1.patch1.12 KBcdale

Comments

cdale’s picture

StatusFileSize
new1.12 KB

This may not be relevant for Drupal 7, or Views 3, but for Drupal 6 and Views 2 I believe I've found the cause of these extra items, and also a cause of #1085880: [PHP] warning: Attempt to assign property of non-object.

When views discovers the default templates, it calls $view->destory() on each discovered view object. This happens before it is passed to hook_views_default_views_alter(), which means the view object has actually had all handlers and extra stuff removed.

The following patch not only reduced the amount of differences found by features override, but also stopped the errors in the above issue.

Not sure if this is the right way to go about it, but it is working for me.

=== modified file 'features_override.module'
--- features_override.module	2011-08-16 02:48:50 +0000
+++ features_override.module	2011-10-13 23:05:46 +0000
@@ -203,6 +203,16 @@
             $component_overrides[$name] = array('additions' => array(), 'deletions' => array());
             // TODO: handle the case of added components.
             if (isset($default[$name])) {
+              // Clean up views objects so we don't process information we don't need to.
+              if ($component == 'views') {
+                if (is_object($properties) && method_exists($properties, 'destroy')) {
+                  $properties->destroy();
+                }
+                if (is_object($default[$name]) && method_exists($default[$name], 'destroy')) {
+                  $default[$name]->destroy();
+                }
+              }
+
               _features_override_set_additions($default[$name], $properties, $component_overrides[$name]['additions']);
               _features_override_leave_hive($default[$name]);
               _features_override_set_deletions($default[$name], $properties, $component_overrides[$name]['deletions']);
nedjo’s picture

Thanks, good sleuthing.

I wonder if we need the test for 'views'. Would calling destroy() be valid for other object types?

cdale’s picture

I honestly don't know. Given I check for the presence of the function before calling it, it may work, but, it might not also do what is expected here. I always like to practice caution when doing this kind of stuff. The question is, in a non-views object, what would a function named destory() do? I honestly don't know, which makes me think the 'views' test is needed.

nedjo’s picture

Status: Active » Reviewed & tested by the community

Thanks, please go ahead and apply first to D7 and then to D6.

nedjo’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, applied.

Status: Fixed » Closed (fixed)

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

EmanueleQuinto’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)

We tested the patch on 6.x-1.x-dev: it applies and works smoothly. Would be possible to commit to the 6.x-1.x-dev branch?

It removes PHP warnings reported in #1085880: [PHP] warning: Attempt to assign property of non-object and Open Atrium community.

zeip’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)

Drupal 6 is no longer supported.