Problem/Motivation

Because media_file_default_displays_alter() gets fired when features compares the export to the DB, the export always shows as overridden.

Further the export throws these errors:

Warning: Creating default object from empty value in media_file_default_displays_alter() (line 1080 of /drupal/admiral/sites/all/modules/media/media.module).
Warning: Creating default object from empty value in media_file_default_displays_alter() (line 1091 of /drupal/admiral/sites/all/modules/media/media.module).
Warning: Creating default object from empty value in media_file_default_displays_alter() (line 1102 of /drupal/admiral/sites/all/modules/media/media.module).

Proposed resolution

Related to the warnings media_file_default_displays_alter() should check if a certain config exists before adjusting it.
Regarding the overrides, this could be a issue of features:
#1345174: Alter hook implementations lead to false overridden status for features components
#1042088: Feature stuck in overridden state due to buggy hook detection

Remaining tasks

Patch in #1 should fix the errors.
Figure out where the override state comes from.:
Patch in #4 adjusts the features module and should fix the overriden status. However, this could have some serious side-effects - qualified feedback is still outstanding.

User interface changes

None

API changes

None

#2070003: Unable to export through features cleanly
Features:
#1345174: Alter hook implementations lead to false overridden status for features components
#1042088: Feature stuck in overridden state due to buggy hook detection

Original report by @CIsSharp

I updated both file_entity and media module from unstable7 to 7.x-2.0 alpha2 (run update.php too) and I am getting several warnings on almost every single pages even in admin pages.
Strict warning: Creating default object from empty value in media_file_default_displays_alter() (line 1080 of .../sites/all/modules/contrib/media/media.module).
Notice: Undefined property: stdClass::$name in ctools_export_load_object() (line 518 of .../sites/all/modules/contrib/ctools/includes/export.inc).
Notice: Undefined property: stdClass::$name in ctools_export_load_object() (line 518 of .../sites/all/modules/contrib/ctools/includes/export.inc).
...........
I do have custom fields and they are all in features. Is there anything I am missing?

Comments

Status:Active» Needs review
StatusFileSize
new2.05 KB
PASSED: [[SimpleTest]]: [MySQL] 92 pass(es).
[ View ]

I think media_file_default_displays_alter() should check if a certain config exists before adjusting it. If the config doesn't exist it will throw such warnings.

Title:Getting warnings (Strict warning: Creating default object from empty value in media_file_default_displays_alter()) after updateFile display featues exports stuck in overriden state and php warnings are thrown
Issue tags:-#media+media

Found "duplicate": #2070003: Unable to export through features cleanly
Updated issue title and summary.

The patch at #1 fixed the `media_filed_default_displays_alter()` php warnings for me, but i still have image styles stuck in the overriden state. No amount of force-reverting or even recreating seems to fix this. In the UI, when viewing components you still see "overriden", but when you go to the "review overrides" tab, you get "no overrides found". I'm using these features in a deployment scenario, and it looks like the settings for all the image styles are fine. Its more of annoyance that the component is marked as overriden.

Title:File display featues exports stuck in overriden state and php warnings are thrownFile display featues exports stuck in overridden state and php warnings are thrown
StatusFileSize
new1.13 KB

The attached patch contains adjustments to the feature module. It seems like it solves the overridden issue, however I don't know yet at what cost.
So far I couldn't identify any issues but I can't guarantee that there aren't undesired side effects!

@das-peter, using #4 fixed the image style overriden state. It does seem like this patch is painting with a fairly broad brush, though, as patching Features to get image styles to play nicely goes against logic. I can report, however, that I started having image style issues with core 7.23 (the image style API change was in there), so maybe it does make sense. So the complete solution to fix the image style issues i am having was to use #1 against Media, and #4 against Features 2.x with core 7.23.

Going to leave this in needs review in the hopes we can get some more eyes on it. In the meantime, I'll monitor for any oddness in other workflows resulting from this patch.

Oops, here's a related issue, too: #1042088: Feature stuck in overridden state due to buggy hook detection. I tried the patch at #24 there first which didn't help.

@mpgeek Yes I've found that related issue too - see the issue summary.
That's why I was working on features.
My best guess is, that media introduced the usage of media_file_default_displays_alter() lately and thus we've now the warnings and the overridden state because features seems to have issue with alter hooks in some cases.

Status:Needs review» Reviewed & tested by the community

Perfect. Also had to use the patch in https://drupal.org/node/1042088#comment-7812041 get rid of the overridden issue.

Status:Reviewed & tested by the community» Active

Applying the patch from #4 and https://drupal.org/node/1042088#comment-7796697 did not yet solve the overridden status. I keep on getting the following diff:

Component: file_display
  array(
<   'audio__preview__file_field_media_large_icon' => array(
<     'api_version' => 1,
<     'name' => 'audio__preview__file_field_media_large_icon',
<     'weight' => 0,
<     'status' => TRUE,
<     'settings' => '',
<   ),
<   'document__preview__file_field_media_large_icon' => array(
<     'api_version' => 1,
<     'name' => 'document__preview__file_field_media_large_icon',
<     'weight' => 0,
<     'status' => TRUE,
<     'settings' => '',
<   ),
    'image__promoted_big__file_field_image' => array(
      'api_version' => 1,
        'image_link' => 'content',
      ),
<   ),
<   'video__preview__file_field_media_large_icon' => array(
<     'api_version' => 1,
<     'name' => 'video__preview__file_field_media_large_icon',
<     'weight' => 0,
<     'status' => TRUE,
<     'settings' => '',
    ),
  )

which seems related to the alters from media_file_default_displays_alter(). Any idea of how to solve this?

In my tests, the patch from https://drupal.org/node/1042088#comment-7796697 gets rid of the PHP notices only temporarily. I have not yet tested the patches from this thread.

Its also worth noting that the stuff that is showing up overridden in my particular feature are not even things that are supposed to be versioned.

Example: I am attempting to version:

image__teaser__file_field_colorbox
image__teaser__file_field_picture
image__teaser__file_field_slideshow
image__teaser__file_picture

But the 'default' that are showing up have nothing to do with this (audio, document, video, etc). I double-checked to see if these components somehow snuck their way into the Feature but they are nowhere in the codebase. I am not sure where these phantom defaults are coming from. I am seeing this problem even on a new build of the site and enabling the Feature.

file_displays-overrides-phantom-defaults.png

I still had to revert the features in question. Did you guys try that?

I can confirm #9 is happening even after reverting the feature.

#4 resolves the override status for me. However, it doesn't resolve the error
Strict warning: Creating default object from empty value in media_file_default_displays_alter() (line 1102 of sites/all/modules/contrib/media/media.module).

I even tried applying #1042088-24: Feature stuck in overridden state due to buggy hook detection and that didn't help with the errors.

Updated Issue Summary:
Patch in #1 should fix the errors.
Figure out where the override state comes from.:
Patch in #4 adjusts the features module and should fix the overriden status. However, this could have some serious side-effects - qualified feedback is still outstanding.

Status:Active» Reviewed & tested by the community

#1 does indeed fix the errors. Can we get that piece committed and work on override in a different issue?

Marking RTBC for errors.

Status:Reviewed & tested by the community» Needs work

How can this be considered RTBC if the errors are suppressed but the Features are still overridden?

Status:Needs work» Reviewed & tested by the community

@brantwynn Did you checkout the patch and are you aware that the overridden issue is likely an issue of Features and not Media?
The Media patch #1 doesn't suppress anything - it properly checks if there's something to handle at all. If there's nothing to make the modification on don't event attempt it.

The Features patch #4 changes the parameter which triggers if the alter hooks should be taken in account or not when comparing exported features. So, again no error suppression of any kind.
However, I'm not sure that it is the correct approach to fix the feature issue.

But as pointed out in #15 why should we wait with fixing the part that's really related to Media?
Thus RTBC again as of #15. Until someone disagrees and can point out where Media is doing something Features related wrong.

Title:File display featues exports stuck in overridden state and php warnings are thrownphp warnings are thrown because media_file_default_displays_alter() checks for configs that may not exist

Hi @das-peter - yes I checked out the patches. Sorry, my usage of the word 'supressed' was not intended that this is a workaround or a hack - in this case, the patch is working correctly to get rid of the warnings. But it doesn't solve what the issue says we are trying to do.

The title of this issue is misleading as it presumes this issue still also deals with the overridden state. If the issue is RTBC because the warnings are gone, then we have to update the issue details to reflect this change. The overrides still exist and the patch doesn't go about fixing it. So the goal of this issue has changed and we're only dealing in fixing the warnings in Media.

The problem/motivation describes this:

Because media_file_default_displays_alter() gets fired when features compares the export to the DB, the export always shows as overridden.

Then later it says in the steps to take:

Figure out where the override state comes from.:

We don't know where the override state comes from. But we just stated in the motivation that its because media_file_default_displays_alter() gets fired when features compares the export to the DB.

We at least know, thanks to your patch in #1, that the PHP warnings are not related to the fact that the export is showing up as overridden.

We also know from #4 that something is happening in Features causing the overridden state. So yes, to deal with that issue in the Features queue...

I'll leave this issue RTBC but we should update the problem/motivations described in the summary so that the maintainers are not confused when they review this issue.

I've already updated the title.

i obvs need more coffee because am having this problem but this thread has me confused: which patches should i apply? thnx in advance for the heads up.

Sorry to report otherwise. This issue may have nothing to do with features.
Just got the same messages with a new and clean install without features ...

Version: 7.x-2.0-alpha2+4-dev

These messages appear - in my case - when I add a new page and want to use the media insert ...

Strict warning: Creating default object from empty value in media_file_default_displays_alter() (line 1080 of ...sites\mobile.localhost\modules\media\media.module).
Strict warning: Creating default object from empty value in media_file_default_displays_alter() (line 1091 of ...sites\mobile.localhost\modules\media\media.module).
Strict warning: Creating default object from empty value in media_file_default_displays_alter() (line 1102 of ...sites\mobile.localhost\modules\media\media.module).

Notice: Undefined property: stdClass::$name in ctools_export_load_object() (line 518 of
...sites\mobile.localhost\modules\ctools\includes\export.inc).
Notice: Undefined property: stdClass::$name in ctools_export_load_object() (line 518 of ...sites\mobile.localhost\modules\ctools\includes\export.inc).
Notice: Undefined property: stdClass::$name in ctools_export_load_object() (line 518 of
...\sites\mobile.localhost\modules\ctools\includes\export.inc).
Notice: Undefined property: stdClass::$name in ctools_export_load_object() (line 518 of
...\sites\mobile.localhost\modules\ctools\includes\export.inc).

*edit*

The thing I suggested turned out to be a Bad Idea™

So, I also suffer from the permanently overridden status!

Issue tags:-features

Seems to be working for us with media-7.x-2.0-alpha2 and features 7.x-2.0-rc3.

  • Applied #1 and it get rid of the red error messages.
  • Applied #4 and it removed the overridden state under the file entity component.
  • I did have a image style that was still overridden but it was because a 'label' was not exported in the feature which I had to manually patch.
  • I did apply #24 in #1042088: Feature stuck in overridden state due to buggy hook detection in place of #4 here, then cleared cache and reverted the feature but no cigar.

Issue tags:+features

Issue tags:+features

Made an issue over at: https://drupal.org/node/2104193 that discusses das-peter's extra patch and media being overridden.

I just noticed that applying the patch in #4 also fixes the error messages for me... Meaning, I didn't use the #1 patch...

Thanks Sylus,

Just left a comment and RTBC'd it. Now we can find out if the way is correct!

Status:Reviewed & tested by the community» Fixed

partch in #1 makes perfect sense. committed, pushed, thanks!
3d23123

Hi all

Just did a fresh instal, then ran some updates- can confirm I get the following messages with this version:

Strict warning: Creating default object from empty value in media_file_default_displays_alter() (line 1080 of C:\localsites\localsite\profiles\openatrium\modules\contrib\media\media.module).
Strict warning: Creating default object from empty value in media_file_default_displays_alter() (line 1091 of C:\localsites\localsite\profiles\openatrium\modules\contrib\media\media.module).

Cheers,

H

Hi there, I did apply the patch from comment #1 and my feature is still on "Overridden" status.

~/Sites/mysite/profiles/myprofile(develop): drush fd myprofile_distro
Legend:
Code:       drush features-revert will remove the overrides.
Overrides:  drush features-update will update the exported feature with the displayed overrides
Component: file_display
  array(
<   'audio__preview__file_field_media_large_icon' => array(
<     'api_version' => 1,
<     'name' => 'audio__preview__file_field_media_large_icon',
<     'weight' => 0,
<     'status' => TRUE,
<     'settings' => '',
<   ),
<   'document__preview__file_field_media_large_icon' => array(
<     'api_version' => 1,
<     'name' => 'document__preview__file_field_media_large_icon',
<     'weight' => 0,
<     'status' => TRUE,
<     'settings' => '',
<   ),
    'image__default__file_image' => array(
      'api_version' => 1,
        'image_style' => 'medium',
      ),
<   ),
<   'video__preview__file_field_media_large_icon' => array(
<     'api_version' => 1,
<     'name' => 'video__preview__file_field_media_large_icon',
<     'weight' => 0,
<     'status' => TRUE,
<     'settings' => '',
    ),
  )

I did try revert and also update, and of course clean all caches, and nothing of that worked.

This issue deals with the PHP Warnings.

The problem with the file_entity settings showing up overridden is being worked on in the Features queue. It is tracked here: #2104193: Default file entities are not exportable by features (Media File Entity Overridden)

Thank you, I'll take a look at it.

Thank you, I'll take a look at it.

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

Issue summary:View changes

Updated issue summary.