I am using Aegir to upgrade Commerce Kickstart to a new version. However, it stumbles on:

Drush command terminated abnormally due to an unrecoverable error. Error: Unsupported operand types in /data/disk/o1/static/commerce_kickstart-7.x-2.x-dev/profiles/commerce_kickstart/modules/contrib/message_notify/message_notify.module, line 80

Comments

amitaibu’s picture

I'm unclear how you get $entity_info['message']['view modes'] as NULL. Can you debug it?

7wonders’s picture

I am also getting this error when doing drush rr on an aegir setup. How can I help to debug?

lsolesen’s picture

@Amitaibu I tried to debug the issue, but did not come up with a solution. But since more people are having problems, maybe a check to see if it is an array should be put in?

socialnicheguru’s picture

This is what I got:

/testcommons.socialnicheguru.com$ drush rr
call_user_func() expects parameter 1 to be a valid [warning]
callback, first array member is not a valid class name or
object message_notify.module:75
Invalid argument supplied for foreach() [warning]
message_notify.module:77
PHP Fatal error: Unsupported operand types in /message_notify/message_notify.module on line 80

Fatal error: Unsupported operand types in /message_notify/message_notify.module on line 80
Drush command terminated abnormally due to an [error]
unrecoverable error.
Error: Unsupported operand types in
message_notify/message_notify.module,
line 80

drush dis message_notify
call_user_func() expects parameter 1 to be a valid [warning]
callback, first array member is not a valid class name or
object message_notify.module:75
Invalid argument supplied for foreach() [warning]
message_notify.module:77
PHP Fatal error: Unsupported operand types in message_notify/message_notify.module on line 80
Drush command terminated abnormally due to an [error]
unrecoverable error.
Error: Unsupported operand types in
message_notify/message_notify.module,
line 80

since this is needed for drupal_commons, I can't move forward :(

socialnicheguru’s picture

Version: 7.x-2.2 » 7.x-2.x-dev

I was using the nov 4 dev version

socialnicheguru’s picture

$class, $view_modes, and $view_mode are all NULL.

I debugged and got Null values are all of the above:
var_dump($class);
echo "";
var_dump($view_modes);
echo "";
var_dump($view_mode);
echo "";
var_dump($entity_info['message']['view modes']);
echo "";

This looks like the cause. I wonder if ctools function has changed

$class = ctools_plugin_load_class('message_notify', 'notifier', $notifier_name, 'class');
Edit:
Ctools class_exists($return) returns false in ctools/ includes/plugins.inc

socialnicheguru’s picture

I am still getting this message.

I will try uninstalling, remove anytihng in the db and variable tables (which I hope there isn't) and re-installing

Edit:
tried all of this and it still was an issue.

Chipie’s picture

Version: 7.x-2.x-dev » 7.x-2.3

I am getting the same error. Did you find a solution?

socialnicheguru’s picture

no. i had to comment out the problem lines just to get the install to work.
message notify is not working for me right now

niccolox’s picture

yep, using Aegir BOA 2.04 dev and Commons Beta 1 and had to comment out for site to run, verify etc

/**
 * Implements hook_entity_info_alter().
 *
 * Add a the notifiers view modes.
 */

/** http://drupal.org/node/1782034 
function message_notify_entity_info_alter(&$entity_info) {
  foreach (message_notify_get_notifiers() as $notifier_name => $plugin) {
    $class = ctools_plugin_load_class('message_notify', 'notifier', $notifier_name, 'class');
    $view_modes = call_user_func(array($class, 'viewModes'));
    // Set default values.
    foreach ($view_modes as &$view_mode) {
      $view_mode += array('custom settings' => TRUE);
    }
 
    $entity_info['message']['view modes'] += $view_modes;
 
  }
}
**/
socialnicheguru’s picture

Issue tags: +ApacheSolr, +Acquia

This occurred once I disabled modules:
drush dis -y acquia_connector and apachesolr

I wonder if it has to do with either of these or just disabling modules in general

blackandcode’s picture

Status: Active » Needs review

The bug with this is some unsupported operand in PHP. I look at code and find out that someone has error in file message?notify.module on line 80

The code on the line is:
$entity_info['message']['view modes'] += $view_modes;

And I change to
$entity_info['message']['view modes'] .= $view_modes;

Now everything is working!

socialnicheguru’s picture

can you explain what " .= " means?

Edit:
.= Concatenate Equals $my_str.="hello"; $my_str = $my_str . "hello";

that makes sense. it just is trying to add the value to the string. Does this work for array elements?

ERROR:
I got an error with cron when trying this method:

drush cron
Error: Unsupported operand types in modules/field_ui/field_ui.module line 180

Fatal error: Unsupported operand types in modules/field_ui/field_ui.module on line 180

socialnicheguru’s picture

I am going to assume that in the original message_notify module they wanted to append $views_mode array onto the end of another array.

I believe that "+=" and ".=" are used for strings and thus won't work for the array elements.

I tried using array_merge and it seems to work
$entity_info['message']['view modes'] = array_merge($entity_info['message']['view modes'],(array)$view_modes);

http://php.net/manual/en/function.array-merge.php

Edit:
OK array_merge does and "+=" are not the same

http://stackoverflow.com/questions/2140090/operator-for-array-in-php

Anonymous’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
StatusFileSize
new513 bytes

i have made a patch based on comment #14

please review

kalman.hosszu’s picture

Status: Needs review » Reviewed & tested by the community

I think array_marge() is better solution than concatenate the arrays. The patch didn't influence the functionality because the tests are passed so I modify the status to RTBC.

kalman.hosszu’s picture

StatusFileSize
new572 bytes
new515 bytes

Coding standard is fixed. I stay the status because it's a minor change.

amitaibu’s picture

Issue tags: -ApacheSolr, -Acquia

@kalman.hosszu ,
Are you able to reproduce it on a clean installation? I think that error is just a symptom for a bug in another module -- as the view-modes should be an array.

socialnicheguru’s picture

other than checking modules one by one, what other suggestions are there.

socialnicheguru’s picture

Status: Reviewed & tested by the community » Active

Ok, so I went back to take a look.

if you enable this with some modules and not others the error in this queue is thrown.

Taking a look at this line:
call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object message_notify.module:75
Invalid argument supplied for foreach() message_notify.module:77

$ctools_plugin_load_class returns NULL when a number of modules are enabled.

A small list includes:
panels_breadcrumb
panels_createnode
contextual
permission_select

it is tripped when $notifier is "email".

Does every module have to enable this ctools_plugin or should there be a check?

I am not familiar enough to know if items dealing with permissions which are not entities should have a ctools_plugin for a message_notify email plugin.

Lines in message_notify.module giving errors:

74-> $class = ctools_plugin_load_class('message_notify', 'notifier', $notifier_name, 'class');   <strong>//Do all modules have to return a ctools_plugin</strong>
75 ->    $view_modes = call_user_func(array($class, 'viewModes'));  <strong>//$class is NULL for some modules</strong>
77 ->    foreach ($view_modes as &$view_mode) {

CTools ctools_plugin_load_class

/**
 * Load a plugin and get a class name from it, returning success only if the
 * class exists.
 *
 * @param $module
 *   The module that owns the plugin type.
 * @param $type
 *   The type of plugin.
 * @param $id
 *   The id of the specific plugin to load.
 * @param $class_name
 *   The identifier of the class. For example, 'handler'.
 *
 * @return
 *   The actual name of the class to call, or NULL if the class does not exist.
 */
function ctools_plugin_load_class($module, $type, $id, $class_name) {
  $plugin = ctools_get_plugins($module, $type, $id);
  return ctools_plugin_get_class($plugin, $class_name);
}
amitaibu’s picture

Assigned: Unassigned » amitaibu
Status: Active » Needs review
StatusFileSize
new5.12 KB

Let's try to move the view-modes into the plugin definition itself.

Chipie’s picture

@lsolesen: My workaround: comment line 80 during aegir operations (verify, migrate, ..) and then enable the line again.

Status: Needs review » Needs work

The last submitted patch, 1782034-view-modes-21.patch, failed testing.

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new5.12 KB

Oops, corrected variable.

amitaibu’s picture

Title: Error: Unsupported operand types » Move "view-modes" to the plugin definition to prevent WSOD

Better title

amitaibu’s picture

Can anyone confirm this patch is working

amitaibu’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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