#629794 follow-up by yched: Fixed batch API in update.php.

merge-requests/26/head
Angie Byron 2010-01-09 02:51:09 +00:00
parent 25747314e2
commit 1f6a553cd2
3 changed files with 35 additions and 24 deletions

View File

@ -383,6 +383,27 @@ function update_fix_d7_requirements() {
); );
db_create_table('queue', $schema['queue']); db_create_table('queue', $schema['queue']);
// Create the sequences table.
$schema['sequences'] = array(
'description' => 'Stores IDs.',
'fields' => array(
'value' => array(
'description' => 'The value of the sequence.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('value'),
);
db_create_table('sequences', $schema['sequences']);
// Initialize the table with the maximum current increment of the tables
// that will rely on it for their ids.
$max_aid = db_query('SELECT MAX(aid) FROM {actions_aid}')->fetchField();
$max_uid = db_query('SELECT MAX(uid) FROM {users}')->fetchField();
$max_batch_id = db_query('SELECT MAX(bid) FROM {batch}')->fetchField();
db_insert('sequences')->fields(array('value' => max($max_aid, $max_uid, $max_batch_id)))->execute();
// Add column for locale context. // Add column for locale context.
if (db_table_exists('locales_source')) { if (db_table_exists('locales_source')) {
db_add_field('locales_source', 'context', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.')); db_add_field('locales_source', 'context', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.'));

View File

@ -2590,25 +2590,11 @@ function system_update_7043() {
} }
/** /**
* Reuse the actions_aid table as sequences. * Drop the actions_aid table.
*/ */
function system_update_7044() { function system_update_7044() {
$schema['sequences'] = array( // The current value of the increment has been taken into account when
'description' => 'Stores IDs.', // creating the sequences table in update_fix_d7_requirements().
'fields' => array(
'value' => array(
'description' => 'The value of the sequence.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('value'),
);
db_create_table('sequences', $schema['sequences']);
$max_aid = db_query('SELECT MAX(aid) FROM {actions_aid}')->fetchField();
$max_uid = db_query('SELECT MAX(uid) FROM {users}')->fetchField();
db_insert('sequences')->fields(array('value' => max($max_aid, $max_uid)))->execute();
db_drop_table('actions_aid'); db_drop_table('actions_aid');
} }

View File

@ -179,13 +179,17 @@ class SystemQueue implements DrupalQueueInterface {
} }
public function createItem($data) { public function createItem($data) {
$record = new stdClass(); // During a Drupal 6.x to 7.x update, drupal_get_schema() does not contain
$record->name = $this->name; // the queue table yet, so we cannot rely on drupal_write_record().
$record->data = $data; $query = db_insert('queue')
// We cannot rely on REQUEST_TIME because many items might be created by a ->fields(array(
// single request which takes longer than 1 second. 'name' => $this->name,
$record->created = time(); 'data' => serialize($data),
return drupal_write_record('queue', $record) !== FALSE; // We cannot rely on REQUEST_TIME because many items might be created
// by a single request which takes longer than 1 second.
'created' => time(),
));
return (bool) $query->execute();
} }
public function numberOfItems() { public function numberOfItems() {