Run drush dis module_name --debug and I get the following error:

PHP Fatal error: Unsupported operand types in modules/all/og/includes/og.info.inc on line 29
Drush command terminated abnormally due to an unrecoverable error. [
Error: Unsupported operand types in /var/aegir/platforms/7/modules/all/og/includes/og.info.inc,

 $properties['entity_type'] += array(
      'required' => TRUE,
      'options list' => 'og_get_all_group_entity',
    );
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wielrijder’s picture

same error. site locked up

shenzhuxi’s picture

Confirm for
7.x-1.4
7.x-1.x-dev
7.x-2.x-dev

nikolas.tatianenko’s picture

Adding test for array on line 29 and 109 will solve problem
for example i'll make changes in line 29
text on this line
$properties['entity_type'] += array(
'required' => TRUE,
'options list' => 'og_get_all_group_entity',
);
i'll change to
if (is_array($properties['entity_type'])){
$properties['entity_type'] += array(
'required' => TRUE,
'options list' => 'og_get_all_group_entity',
);
}
the same on 109 line

Nephele’s picture

I'm getting this same problem when trying to update from an early 1.x-dev release of og (Mar 6, 2011) to og 1.4. The version of og that I'm starting from is old enough that the og_membership table did not previously exist.

The problem is triggering for me on line 113 of og.info.inc in og 1.4. It occurs when I try to run update.php -- and once it's triggered within update.php, trying to load any page on the site produces the same error message and aborts. I'm simultaneously updating og, entity, and entityreference; entity is being updated from version 7.x-1.0-beta7 to 7.x-1.0-rc3. (And note that entity 1.0-beta7 is the last version that is still compatible with the old version of og I'm using, so I have to install and update both modules simultaneously).

I've traced the problem to the fact that entity.info.inc tries to look up the og_membership schema (using drupal_get_schema('og_membership') in its entity_metadata_convert_schema function), it's coming back empty ($schema = FALSE). When I look in mysql, the og_membership table does exist, but it has not been added to the cached version of the schema being checked by drupal_get_schema.

I was able to resolve the issue by editing entity.info.inc, changing line 149 to drupal_get_schema('og_membership', TRUE) -- forcing drupal to rebuild its schema instead of using the cached version.

So basically I'm guessing it's a transient problem that can crop up if both entity and og need to be updated simultaneously -- entity is asked to run its update functions before any of og's update functions have been called, forcing entity to try to generate entity definitions with incomplete information. As such, the real root of the problem is probably with entity (therefore I've added a bug report at entity, see #1748626: entity_metadata_convert_schema can try to use out-of-date schema information).

However, it may also be prudent to have some code added to og.info.inc to ensure that its functions quit somewhat more gracefully if parent::entityPropertyInfo() returns invalid/unexpected information -- allowing entity to successfully finish its updates and then give og a chance to properly run its update functions.

Nephele’s picture

Status: Active » Needs review
FileSize
1.29 KB

I subsequently noticed that this issue has effectively been patched in og 7.x-2.0-beta1, so I copied the same code into 7.x-1.x-dev and created the attached patch.

Status: Needs review » Needs work

The last submitted patch, og-fatal_in_og.info_.inc-1543696.patch, failed testing.

Nephele’s picture

Status: Needs work » Needs review
FileSize
1.11 KB

Retrying the same patch, but without some unnecessary array keys.

Status: Needs review » Needs work

The last submitted patch, og-fatal_in_og.info_.inc-1543696-7.patch, failed testing.

Nephele’s picture

Status: Needs work » Needs review
amitaibu’s picture

Minor:

+++ b/includes/og.info.incundefined
@@ -14,6 +14,12 @@ class OgMetadataController extends EntityDefaultMetadataController {
+    // Initialize values to prevent WSOD and other fatal errors

Better short it to just Initialize values.

+++ b/includes/og.info.incundefined
@@ -14,6 +14,12 @@ class OgMetadataController extends EntityDefaultMetadataController {
+      'entity_type' => array(),

Is this really needed, as in next line we assign the values.

Nephele’s picture

Re:

+++ b/includes/og.info.incundefined
@@ -14,6 +14,12 @@ class OgMetadataController extends EntityDefaultMetadataController {
+      'entity_type' => array(),

The next line assigns $properties['entity'], not $properties['entity_type']. When entity_type is modified, it's using +=, not =:

    $properties['entity_type'] += array(

Which is precisely what causes the unsupported operand types error (can't add a scalar and an array) unless entity_type has been initialized.

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

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