Fatal error: Unsupported operand types in /home/ecodev/public_html/sites/all/modules/entity/views/entity.views.inc on line 189
Drush command terminated abnormally due to an unrecoverable error. 

After having this problem, I totally removed Commerce, including un install, and all %commerce% tables removed and cache cleared as describe in #858722. I also found some "field_delete_field" related to commerce and removed them (after reviewing #943772).

I reinstalled commerce 7.x-1.2 and commerce_repair 7.x-1.x-dev (2011-Sep-09). As instructed in #1007434 I enabled the components Commerce and Commerce UI + Customer and Customer UI + Price + Line Item and Line Item UI with no problem. I then ran commerce_repair and clear cache (drush cc=1).

When trying to enable order, the error appear again and the web fail.

After restoring from a backup I made just before enabling order, I was able to enable Product and Product UI.

Enabling Product reference cause another error:

WD php: FieldException: Attempt to create field name commerce_product[error]
which already exists, although it is inactive. in
field_create_field() (line 85 of
/home/ecodev/public_html/modules/field/field.crud.inc).
Cannot modify header information - headers already sent by (output   [warning]
started at /usr/share/drush/includes/output.inc:37)
bootstrap.inc:1251
FieldException: Attempt to create field name <em class="placeholder">commerce_product</em> which already exists, although it is inactive. in field_create_field() (line 85 of /home/ecodev/public_html/modules/field/field.crud.inc).
Drush command terminated abnormally due to an unrecoverable error.   [error]

But the website is fine.

The other modules I have installed are:

  • Address Field 1.0-beta2
  • Chaos tool suite 1.0-rc1
  • Entity API 1.0-rc1+43-dev
  • Rules 2.0
  • Views 3.3

Comments

rszrama’s picture

Status: Active » Closed (duplicate)

Deleting manually is always fraught with peril. It sounds like you have fields that weren't deleted that are causing problems now on re-installation. Any field prefixed with commerce_ instead of field_ was added by a Drupal Commerce module and will be recreated when the module is installed. Now, it actually does check to ensure a field doesn't exist before creating again, but if you disabled a module and that resulted in a field being disabled, we have an open issue that I'll link to from here where we need to accommodate that scenario still. In the meantime, I'll mark this one as a duplicate for that issue.

See #1361562: Re-enabling Commerce causes a PHP Fatal Error.

As to the original bug you encountered, I think you would've been better off to figure out why you were getting that error before nuking the database. I've never seen any errors with respect to the Views integration in Entity API, so who knows what could've been wrong. : ?

shaisamuel’s picture

Thank for the help. This was the case before I deleted anything. I couldn't get order to be re-activate after I de-activate it at the first place. I thought that clearing out commerce of my db will allow fresh install. Any suggestion how to clear it all out and restart?

shaisamuel’s picture

SOLUTION !!!

After straggling with this many weeks, I finally found a solution which work and managed to cleanly remove commerce (!) and get it to reinstall and activate all its component !!!

I know it is not a clean way, since you need to mess with the DB, but in fact, it is a big issue for many. I found a script which I modified to do all of the above with some addition and it works.

I wish, someone with more knowledge than me, best some commerce guy, will use it to create an uninstall option from commerce, until all the loss ends will come together.

Basically I combined #858722: Cannot reinstall Commerce modules after uninstall due to field deletion failure by improving a script I found in
http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cts=13317....

Here is the process step by step:

1. Disable commerce components one by one or using a single drush command drush pm-disable commerce
2. Uninstall commerce components one by one (if possible). Drush currently can't do it in a single command.
3. Delete folder sites/all/modules/commerce
4. Create a php file under your drupal directory, with a name commerce_cleanup_script.php
5. Paste the following code into it, after replacing myDBname, myDBuser, myDBpass with your DB name, user and password.

<?php

// Select your database 
$db = 'myDBname';

$final_buffer = '';
$buffer = '';

mysql_connect('localhost','myDBuser','myDBpassword', true) or die('Couldn\'t connect to MySQL!' . mysql_error());

$result = mysql_query("delete from $db.system where filename like '%contrib/commerce/%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("DELETE FROM $db.field_config WHERE field_name LIKE '%commerce%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("DELETE FROM $db.field_config_instance WHERE field_name LIKE '%commerce%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 2 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 2 (delete) Success<br />";
}

$result = mysql_query("delete from $db.rules_config where name like 'commerce_%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("delete from $db.rules_trigger where event like 'commerce_%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("delete from $db.variable where name like 'commerce_%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("delete from $db.registry where filename like '%contrib/commerce%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("delete from $db.registry_file where filename like '%contrib/commerce%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("delete from $db.block where module like '%commerce_%'");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 1 (delete) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 1 (delete) Success<br />";
}

$result = mysql_query("TRUNCATE $db.cache_field");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 3 (truncate) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 3 (truncate) Success<br />";
}

$result = mysql_query("TRUNCATE $db.cache_bootstrap");
if (!$result)
{
        // Return an error for this statement
        $buffer .= "Statement 4 (truncate) Did Not Work - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $buffer .= "Statement 4 (truncate) Success<br />";
}

$drop_buffer = "Dropping Tables ...<br /><br />";

// array the table names
$tables = array("customer_address", "customer_billing", "display_path", "line_items", "order_total", "price", "product", "total", "unit_price");

foreach ($tables as $suffix)
{
        $result = mysql_query("drop table if exists $db.drupal_field_data_commerce_$suffix");
        if (!$result)
        {
                // Return an error for this statement
                $drop_buffer .= "[Fail] Did Not Drop $suffix<br />";
        }
        else
        {
                // Return true for this statement
                $drop_buffer .= "[Success] Dropped $suffix<br />";
        }
}

// drop all remaining tables
$result = mysql_query("drop table if exists '$db.%commerce%'");
if (!$result)
{
        // Return an error for this statement
        $final_buffer .= "No Final Tables Dropped - " . mysql_error() . "<br />";
}
else
{
        // Return true for this statement
        $final_buffer .= "Final Tables Were Dropped<br /><br />";
}

$final_buffer .= "Script End";

echo "$buffer<br /><br />";
echo "$drop_buffer<br /><br />";
echo "$final_buffer<br /><br />";

?>

6. In SQl run the following command: show tables like '%commerce%';
7. Drop each if the tables in the list (if still exists).
8. Clear ALL cache (using Drush cc).

Backup your DB which is clean of commerce.

Reinstall commerce, its an incredible module.

Hope it helps.

keva’s picture

Thank you, shaisamuel! It works.

drupalerocant’s picture

Thanks for the instructions, shaisamuel
I tried following them step by step, after executing the script, this was the output:

Statement 1 (delete) Success
Statement 1 (delete) Success
Statement 2 (delete) Success
Statement 1 (delete) Success
Statement 1 (delete) Success
Statement 1 (delete) Success
Statement 1 (delete) Success
Statement 1 (delete) Success
Statement 1 (delete) Success
Statement 3 (truncate) Success
Statement 4 (truncate) Success

Dropping Tables ...

[Success] Dropped customer_address
[Success] Dropped customer_billing
[Success] Dropped display_path
[Success] Dropped line_items
[Success] Dropped order_total
[Success] Dropped price
[Success] Dropped product
[Success] Dropped total
[Success] Dropped unit_price

No Final Tables Dropped - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''myDBname.%commerce%'' at line 1
Script End

I followed the correct order for installation and after enabling order and order UI it gave me the following error:

Notice: Undefined index: commerce_order_total in commerce_order_entity_property_info_alter() (line 133 in /homezzzzzzzzzzz/sites/all/modules/commerce/modules/order/commerce_order.info.inc).
    Recoverable fatal error: Argument 2 passed to entity_views_field_definition() must be an array, null given, called in /home/zzzzzzz/sites/all/modules/entity/views/entity.views.inc on line 152 and defined en entity_views_field_definition() (line 175 in /home/zzzzzzzzzzzz/sites/all/modules/entity/views/entity.views.inc).

and I couldn't finish my commerce installation.
I guess there has been some problem with the script, but I cannot identify it.

drupalerocant’s picture

Well, finally I figured it out. The problem was I was trying to install order not being user 1.
I ran commerce_repair module as a user 1, and finally everything went fine.
Thanks for the instructions!

cleaver’s picture

I've been able to work around this problem by patching entity.views.inc

See: #2136919: Unsupported operand types in entity.views.inc when property info is missing.

joelpittet’s picture