I tried to updated to the latest CVS version in the 4.7 branch and got this failure:

Fatal error: Unsupported operand types in /var/www/html/drupal/sites/default/modules/ecommerce/store/store.install on line 475

It turns out this line was trying to divide an int by an array. The supplied patch takes the value from the array instead. It also adds a check for the case when the store is empty (no transactions).

I marking it critical because you can not upgrade with this bug. This was found/tested on php 5.

Comments

neclimdul’s picture

StatusFileSize
new2.85 KB

I didn't have any trouble and it seemed to have tested fine so this is strange. You are right that we would be comparing a array or object. I don't think there is a need for all that casting though as php will do it for you. There is also a simpler way to get the value from the query as well and I messed up the variable names so I fixed that in the patch since we really should be consistent. Thanks for catching the edge case where this update is applied with no transactions. I didn't consider that.

I'm going to see about updating the handbook that I got the code from so this error doesn't happen elsewhere as well.

plumbley’s picture

StatusFileSize
new1.1 KB

I'm not sure if this is connected, but I suspect that store.install may also fail to change the sequences (db_next_id) key properly if a database prefix is used. Here's why:
In store.install,v 1.20 2006/05/18 12:42:24 we have

function store_update_2() {
    ...
      $ret[] = update_sql("UPDATE sequences SET name = '{ec_transaction}_txnid' WHERE name = '{ec_store_transaction}_txnid'");
    ...

but in database.mysql.inc,v 1.53 2006/05/24 20:46:56 we have

function db_next_id($name) {
  $name = db_prefix_tables($name);
  ...
  db_query("REPLACE INTO {sequences} VALUES ('%s', %d)", $name, $id);
  ...

so the sequences table should be prefixed, i.e. we should have
$ret[] = update_sql("UPDATE {sequences} SET name = '{ec_transaction}_txnid' WHERE name = '{ec_store_transaction}_txnid'");
Patch appended which I hope should fix.
NB this is a guess from inspection of the code only: I don't have an old install of ecommerce so I have not observed this to fail or tested the patch.

wpd’s picture

Status: Active » Needs review

I am fairly certain this is a PHP5 specific problem. My test site is running on my local box with PHP5 and it failed. The same update worked fine on PHP4 box.
I agree the casts are not needed as mention in #1 that was debug code, I forgot to remove.

sime’s picture

Component: store.module » store
Status: Needs review » Fixed

housekeeping, assume fixed

Anonymous’s picture

Status: Fixed » Closed (fixed)