If you’re upgrading from Drupal 5.x to 6.x, and you’re using the Block Cache module, be sure to drop the cache_block table prior to upgrading.
Update.php fails to create the cache_block table if it already exists from the 5.x install of the Block Cache module. Turns out there’s a patch for update.php created by chx way back in ‘07, but it never made it in.
I ran into this issue upgrading our internal forums from 5 to 6. Hopefully, you catch this before running update.php, but if you didn’t here’s a fix.
There’s no uninstall option for Block Cache, so unfortunately, you’ll have to get under the hood whether or not you anticipate this upgrade problem.
Not Yet Upgraded
If you haven’t run update.php yet, you can save yourself some hassle by dropping the cache_block table first.
Use phpmyadmin or ssh+mysql to do it.
DROP TABLE IF EXISTS `cache_block`;
Already Boned
If you already upgraded and got the “failed to create table error”, like I did, then you’ll need to manually drop and create the table. It gets a little complicated because there isn’t a schema to just copy and paste anymore (Drupal moved away from that in 6).
Option #1 – ssh+mysql
If you have direct mysql access, here’s the cache_block table’s schema.
DROP TABLE IF EXISTS `cache_block`; CREATE TABLE `cache_block` ( `cid` varchar(255) NOT NULL default '', `data` longblob, `expire` int(11) NOT NULL default '0', `created` int(11) NOT NULL default '0', `headers` text, `serialized` smallint(6) NOT NULL default '0', PRIMARY KEY (`cid`), KEY `expire` (`expire`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
(I think you can drop and create the table using phpmyadmin too, but I’m not sure since I haven’t used it in ages.)
Option #2 – use the Devel module
Install the Devel module and enable the Development block. Click on Execute PHP Code in the block (or go directly to /devel/php). Paste the php code below into the box and execute it.
This is the code that sets the cache_block table’s schema and creates the table. (It’s in the update_fix_d6_requirements() function in update.php.)
// drop cache_block table
update_sql('DROP TABLE {cache_block}');
// Create the cache_block table. See system_update_6027() for more details.
$schema['cache_block'] = array(
'fields' => array(
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'headers' => array('type' => 'text', 'not null' => FALSE),
'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
),
'indexes' => array('expire' => array('expire')),
'primary key' => array('cid'),
);
db_create_table($ret, 'cache_block', $schema['cache_block']);
Hi, I'm Greg. I'm a cofounder of Killer Aces Media. We publish community blogs like