Download & Extend

Update function from 5.x -> 6.x

Project:ImageCache
Version:6.x-2.0-beta3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hello, I can't create new actions in presets. When I save action, I've got an error:

user warning: Unknown column 'module' in 'field list' query: INSERT INTO imagecache_action (presetid, weight, module, action, data) VALUES (0, 0, 'imagecache', 'imagecache_scale_and_crop', 'a:2:{s:5:\"width\";s:3:\"100\";s:6:\"height\";s:2:\"70\";}') in D:\portal\nnn\www\includes\common.inc on line 3318.

My solution is to add new update iteration for missing field in imagecache.install

function imagecache_update_5() {
  $ret = array();
  db_add_field($ret, 'imagecache_action', 'module', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
  return $ret;
}

Comments

#1

Status:needs review» needs work

if that's a D6 update function (i'm guessing it is because it's calling db_add_field()) then the update needs to be named 6000.

marked #321190: Drupal 6 upgrade path as a duplicate... it has the update number right but wasn't using db_add_field(). it also had a bit to set the module on existing actions:

+      $ret[] = update_sql("UPDATE {imagecache_action} set module = 'imagecache'");

not sure if it's necessary but since i'm marking it as duplicate i didn't want that bit get lost.

also this need to be submitted as a proper patch see http://drupal.org/patch for more details

#2

Title:SQL-error when creating new action» Update function from 5.x -> 6.x
Version:6.x-1.0-alpha2» 6.x-2.0-beta3
Status:needs work» needs review

Here's a patch that implements imagecache_update_6000(). It modifies the tables to make the primary keys serial types. It follows the way it is done for core in system_update_6019.

AttachmentSizeStatusTest resultOperations
imagecache.install.patch1009 bytesIgnored: Check issue status.NoneNone

#3

new patch also removes imagecache entries in the sequences table

AttachmentSizeStatusTest resultOperations
imagecache.install.patch1.15 KBIgnored: Check issue status.NoneNone

#4

sorry for so many posts/patches.

this one uses update_sql for the sequences queries rather than db_query

AttachmentSizeStatusTest resultOperations
imagecache.install.patch1.17 KBIgnored: Check issue status.NoneNone

#5

seems like the autoincrement is duplicating the patch on #333769: imagecache_preset needs auto increment?

#6

marked the other as a duplicate of this issue.

#7

Status:needs review» needs work

seems like the delete query could go inside the for loop...

#8

patch at #6 didn't fix the problem here.. running update.php performs the new updates, but i am still getting the warning

user warning: Unknown column 'module' in 'field list' query: UPDATE imagecache_action SET presetid = 3, weight = 0, module = 'imagecache', action = 'imagecache_scale_and_crop', data = 'a:2:{s:5:\"width\";s:2:\"80\";s:6:\"height\";s:2:\"60\";}' WHERE actionid = 3 in /Users/user/site/includes/common.inc on line 3418.

#9

I just applied the patch at #4, and I can now add presets again. I am still unable to add actions to the presets. I do not get an error message. After clicking "Add Action" I am returned to the preset's screen with only the "Add Actions" dropdown showing. Any ideas?

#10

I have the same experience as @SlipAngel exactly - I can create the preset name, but after creating and clicking "add action" for any given preset, I am returned to the Actions interface without a preset action. Preset actions from my 6.x ubercart installation are there, but I can't add any new preset actions.

#11

I got it working after applying the patch #4, running update.php and adding this database column manually, as suggested in http://drupal.org/node/331858#comment-1099296 :

ALTER TABLE imagecache_action ADD module VARCHAR(255) AFTER weight;

#12

Status:needs work» needs review

Here's a new patch that addresses the missing module column. I used schema.module to figure out what else might be missing and noticed that the presetid index was also missing.

Another serious problem that I found is that imagecache_update_4() is missing a break after the mysql/mysqli case, causing the postgres case to also run. This created a couple of errors during my update. I've added the break and all seems to be working.

AttachmentSizeStatusTest resultOperations
imagecache.install.patch1.74 KBIgnored: Check issue status.NoneNone

#13

just noticed from the duplicate issue that the module field should also be populated with 'imagecache'.

new patch to fix it.

AttachmentSizeStatusTest resultOperations
imagecache.install.patch1.85 KBIgnored: Check issue status.NoneNone

#14

Status:needs review» needs work

you cannot call:

+  $schema = imagecache_schema();

in an update function. think about it for a second, what happens when we update the schema and someone who's upgrading from D5 runs this? they'll be getting a current copy of the schema and updates after this will fail. you need to put a full copy of the field in the update function.

we don't need:

+  $ret[] = update_sql("UPDATE {imagecache_action} set module = 'imagecache'");

because db_add_field() will look in the $spec parameter for the key 'initial' which will be used to fill the newly created field.

#15

also the break in update_4() has been committed in another patch.

#16

here's an untested patch.

AttachmentSizeStatusTest resultOperations
imagecache_304376.patch2.28 KBIgnored: Check issue status.NoneNone

#17

Status:needs work» fixed

okay, tested this and i'm satisfied. committed to HEAD.

AttachmentSizeStatusTest resultOperations
imagecache_304376.patch2.3 KBIgnored: Check issue status.NoneNone

#18

Status:fixed» closed (fixed)

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