I am using Embedded Media to have a CCK video field for a specific content type. I added Media - Youtube as a provider as well.

The video plays fine but making any changes to the content type's video field I set up do not change when I save the settings on the content type / edit field page. I am wondering what I have done wrong? Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

phantomvish’s picture

Same issue here. subscribing. Is there any workaround till we get a fix? I'm no programmer but, can we add say "vimeo" as a provider to the particular CCK field in the back end by phpmyadmin or something?

phantomvish’s picture

Component: User interface » Code
Category: support » bug
Priority: Normal » Major
phantomvish’s picture

I found the issue is with the "Embedded Media Bonus Pack". I disabled it and tried adding the provider to the field. It worked !

Danny Englander’s picture

@phantomvish--Indeed, it looks like the issue is with Media Bonus Pack. I disabled that and then i was able to save custom settings to my Embedded Media field. Offhand I don't remember what Bonus Pack does, I need to look into that to see if it's something I really needed.

Danny Englander’s picture

Title: Settings not saved on CCK manage fields page when editing a content type » "Media Bonus Pack" interrupts embedded media field settings not saved on CCK manage fields page when editing a content type

Changing title to be more meaningful and descriptive.

Danny Englander’s picture

Title: "Media Bonus Pack" interrupts embedded media field settings not saved on CCK manage fields page when editing a content type » "Media Bonus Pack" interrupts embedded media field settings from being saved on manage fields page when editing a content type
kirikintha’s picture

Hi everyone,

I ran into this problem as well with the bonus pack, and it led me to look into this issue a little more in depth.

When adding a field, I was receiving a variety of warnings:

Warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #1 is not an array in _emfield_emfield_widget_settings() (line 168 of /sites/all/modules/contrib/emfield/emfield.cck.inc).
Warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in _emfield_emfield_widget_settings() (line 168 of /sites/all/modules/contrib/emfield/emfield.cck.inc).

Debugging a little, I found that in embonus.module in the function embonus_emfield_widget_settings_extra($op, $widget) - there is a conditional for the $collect variable. If there are no modules implementing $collect, then the 'save' op is not producing a value at all, and is failing the array_merge.

I changed the way that embonus_emfield_widget_settings_extra($op, $widget) uses the switch, so that an empty array is populated if the $collect variable has not been set. This solves the above problem, without messing with how the static variable is working.

Updated code:

function embonus_emfield_widget_settings_extra($op, $widget) {
  static $collect;

  if (!isset($collect)) {
    // We only collect the collect start/end times if requested by a module
    // that implements hook_embonus_collect_start_end_times() and returns TRUE.
    foreach (module_implements('embonus_collect_start_end_times') as $module) {
      $collect = $collect || module_invoke($module, 'embonus_collect_start_end_times', $widget);
    }
  }
  
  switch ($op) {
    case 'form':
      $form = array();
      if ($collect) {
        //If we are collecting, show our collection form.
        $form['collect_start_end_times'] = array(
          '#type' => 'checkbox',
          '#title' => t('Collect start & end times'),
          '#description' => t('Some providers may respect start and end times when displaying media. Check this box if you wish to collect that information on a per-instance basis.'),
          '#default_value' => isset($widget['collect_start_end_times']) ? $widget['collect_start_end_times'] : FALSE,
        );
      }
      return $form;
    case 'save':
      //Keep an empty array in tact, if we are not collecting, so that the array_merge does not bail out.
      $columns = ($collect) ? array('collect_start_end_times') : array();
      return $columns;
  }
}

However, I thought about it for a minute here, and I realized that this solves the immediate problem, but one can still fail the function _emfield_emfield_widget_settings($op, $widget, $module) if a valid array is not sent back to function. Array merge summarily fails when no array is allowed to merge, effectively halting the 'save' op.

My solution is to also apply this code change to switch($op) in function _emfield_emfield_widget_settings on emfield.cck.inc:

...
    case 'save':
      $columns = array('providers');
      foreach (module_implements('emfield_widget_settings_extra') as $module) {
        //Get our extra settings from our modules that invokes the emfield_widget_settings_extra hook. 
        $settings_extra = module_invoke($module, 'emfield_widget_settings_extra', 'save', $widget);
        //Check that we are actually getting an array back, if not ensure that array merge will not fail.
        $settings_extra = (!is_array($settings_extra) || empty($settings_extra)) ? array() : $settings_extra;
        //Merge columns together.
        $columns = array_merge($columns, $settings_extra);
      }

      return $columns;
...

So, if any module implements do not return an array properly, the array merge is still safe and will not bail out when saving. I have tested these patches, and find that I have regained the functionality I need and also that the bonus module does not fail when updating, AND that this should protect any other modules from bailing out the CCK fields saving properly when implementing emfield_widget_settings_extra if they are not so ready for prime time.

I have also included a patch file, from git - I am confident that the patching works, not necessarily that my patch file is perfect. I'll be watching this thread to see feedback here. Thank you for developing such a great module!

kclarkson’s picture

Status: Active » Needs review

I can download the patch to see if it works for me but someone else should review the actual code.

Anybody’s picture

Anything new about it?
The bug still exists for me so nothing seems to have changed so far?