When running update.php on updating to 6.x-5.1 I get the following errors on update.php?op=results

warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/www/www.mywebsite.com/update.php on line 173.
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/www/www.mywebsite.com/update.php on line 173.
user warning: Unknown column 'added_by_uid' in 'twitter_account' query: ALTER TABLE twitter_account CHANGE `added_by_uid` `uid` INT unsigned NOT NULL DEFAULT 0 in /home/www/www.mywebsite.com/includes/database.mysql-common.inc on line 529.
The selected file /tmp/filehVnyRA could not be uploaded, because the destination sites/default/files/js/gmap_markers.js is not properly configured.
warning: Invalid argument supplied for foreach() in /home/www/www.mywebsite.com/update.php on line 340.
warning: Invalid argument supplied for foreach() in /home/www/www.mywebsite.com/update.php on line 340.

The /tmp/filehVnyRA one is unrelated I think, since I alsa had it on another update.

Here are the query results:

The following queries were executed
twitter module
Update #6500

ALTER TABLE {twitter_account} DROP include_retweets

Update #6501

ALTER TABLE {twitter_account} ADD `mentions` INT unsigned NOT NULL DEFAULT 0

Update #6502

No queries

Update #6503

ALTER TABLE {twitter_account} CHANGE `import` `import` INT unsigned NOT NULL DEFAULT 0

Update #6504

No queries

Update #6505

Failed: ALTER TABLE {twitter_account} CHANGE `added_by_uid` `uid` INT unsigned NOT NULL DEFAULT 0

Comments

mgriego’s picture

Status: Active » Needs review
StatusFileSize
new1.28 KB

Here's a patch that corrects this. If you're updating from an older version (ie 6.x-3.x), then this will notice if you're running the 6504 update and handle that fact appropriately by using the correct field name rather than what the field name would have been had it been updated previously.

Note, to use this patch properly, your schema_version in the system table must be less than 6504, and updates 6504 and 6505 must not have been run. In actuality, there should probably be some kind of check for update 6502 as well, but this will probably get most people going who run into this because, like us, they updated from a 3.x version.

joachim’s picture

Title: Error running update.php » Error running update.php -- update 6504 has been changed
Priority: Normal » Critical
Status: Needs review » Needs work

It looks like hook_update_n() function was changed, and they should never be:

/**
 * Adds field added_by_uid to twitter_account table.
 *
 * This update has been set empty afterwards as the existing field twitter_account.uid is used.
 */
function twitter_update_6504() {}

/**
 * Renames twitter_account.added_by_uid to twitter_account.uid.
 *
 * This reverts updates 6502 and 6504.
 */
function twitter_update_6505() {
  $ret = array();
  $spec = array(
   'description' => "The uid of the user who added this Twitter account",
   'type' => 'int',
   'unsigned' => TRUE,
   'not null' => TRUE,
   'default' => 0,
  );

  db_change_field($ret, 'twitter_account', 'added_by_uid', 'uid', $spec);
  return $ret;
}

The 6504 update should never have been changed, even if 6505 was added to remove the field it adds. It that means that users upgrading from 6.x-2.x, or indeed from earlier on the 6.x-5.x branch, have their update.php add the field, *only to remove it seconds later*, then that is what needs to happen.

The correct fix here is to restore 6504 to what it was originally.

mgriego’s picture

As long as update 6504 is safe to reinstate, then, yes, that would probably be the better option. The problem is that it's been released in this state, so the final solution may actually require a *new* update function to undo any damage done by this to existing installations.

joachim’s picture

It's impossible to add a new update function to fix this problem, because you can't renumber them. We currently have:

- 6504: does nothing
- 6505: tries to rename a field that doesn't exist

Anything you would add would be 6506, which would be powerless to affect the error.

The only fix is to restore 6504, and make a new release with that fix.

summit’s picture

Hi,

Can I ignore the errors on a production site? Because somewhere it says the update tries to remove a field which is not there..
So should the field added_by_uid be added?

Thanks for your reply!

Greetings, Martijn

Michael-IDA’s picture

If you are Upgrading:

Twitter (twitter) 6.x-3.0 6.x-5.1 Installed version not supported

Then it looks like you can ignore this warning. In 6.x-3.0, field twitter_account.uid already exists and there is no twitter_account.added_by_uid field to rename.

Drush:

Executing twitter_update_6505
Unknown column 'added_by_uid' in 'twitter_account'                                                     [warning]
query: ALTER TABLE twitter_account CHANGE `added_by_uid` `uid` INT unsigned NOT NULL DEFAULT 0 database.mysqli.inc:134
ALTER TABLE {twitter_account} CHANGE `added_by_uid` `uid` INT unsigned NOT NULL DEFAULT 0                                  [error]

cat twitter.install:

/**
 * Adds field added_by_uid to twitter_account table.
 *
 * This update has been set empty afterwards as the existing field twitter_account.uid is used.
 */
function twitter_update_6504() {}

/**
 * Renames twitter_account.added_by_uid to twitter_account.uid.

Condensed version of changes:


twitter module
6500 - Removes include_retweets field.
6501 - Adds field mentions to twitter_account table.
6502 - Drops field uid at twitter_account.   This update has been set empty afterwards as the field is actually needed.
6503 - Makes the import field not enabled by default at twitter_account table.
6504 - Adds field added_by_uid to twitter_account table.   This update has been set empty afterwards as the existing field twitter_account.uid is used.
6505 - Renames twitter_account.added_by_uid to twitter_account.uid.   This reverts updates 6502 and 6504.
damienmckenna’s picture

Version: 6.x-5.1 » 6.x-5.x-dev
Status: Needs work » Needs review
Parent issue: » #2402311: Plan for Twitter v6.x-5.2 release
StatusFileSize
new1.97 KB

So it should do a conditional check in twitter_update_6505() to see if the field exists and only rename it if needed.

damienmckenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed 6a35e72 on 6.x-5.x
    Issue #1994362 by DamienMcKenna, mgriego: Reverted changes to update...

Status: Fixed » Closed (fixed)

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