summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-15 08:23:07 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-15 08:23:07 +0000
commit10104ba94ac7a70b2be3594cb769034582533e1f (patch)
tree343f80cc45db74bee38b959b601875f22af2b532
parent4595edbfc8930ce84e374dc6183266dab7dbecfd (diff)
downloadbrdo-10104ba94ac7a70b2be3594cb769034582533e1f.tar.gz
brdo-10104ba94ac7a70b2be3594cb769034582533e1f.tar.bz2
- Patch #331570 by recidive: rename block module tables to singular. Requires you to run update.php.
-rw-r--r--includes/database/database.inc4
-rw-r--r--modules/aggregator/aggregator.module4
-rw-r--r--modules/block/block.admin.inc28
-rw-r--r--modules/block/block.install12
-rw-r--r--modules/block/block.module20
-rw-r--r--modules/block/block.test6
-rw-r--r--modules/filter/filter.admin.inc2
-rw-r--r--modules/menu/menu.admin.inc4
-rw-r--r--modules/system/system.install18
-rw-r--r--modules/system/system.module8
10 files changed, 59 insertions, 47 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc
index f6f0659c7..e9b2ff0b6 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -2313,7 +2313,7 @@ function db_affected_rows() {
* Query to be rewritten.
* @param $primary_table
* Name or alias of the table which has the primary key field for this query.
- * Typical table names would be: {blocks}, {comments}, {forum}, {node},
+ * Typical table names would be: {block}, {comments}, {forum}, {node},
* {menu}, {term_data} or {vocabulary}. However, in most cases the usual
* table alias (b, c, f, n, m, t or v) is used instead of the table name.
* @param $primary_field
@@ -2360,7 +2360,7 @@ function _db_rewrite_sql($query = '', $primary_table = 'n', $primary_field = 'ni
* Query to be rewritten.
* @param $primary_table
* Name or alias of the table which has the primary key field for this query.
- * Typical table names would be: {blocks}, {comments}, {forum}, {node},
+ * Typical table names would be: {block}, {comments}, {forum}, {node},
* {menu}, {term_data} or {vocabulary}. However, it is more common to use the
* the usual table aliases: b, c, f, n, m, t or v.
* @param $primary_field
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 1c76fbd9d..ce900b047 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -392,7 +392,7 @@ function aggregator_save_category($edit) {
->condition('cid', $edit['cid'])
->execute();
// Make sure there is no active block for this category.
- db_delete('blocks')
+ db_delete('block')
->condition('module', 'aggregator')
->condition('delta', 'category-' . $edit['cid'])
->execute();
@@ -453,7 +453,7 @@ function aggregator_save_feed($edit) {
->condition('fid', $edit['fid'])
->execute();
// Make sure there is no active block for this feed.
- db_delete('blocks')
+ db_delete('block')
->condition('module', 'aggregator')
->condition('delta', 'feed-' . $edit['fid'])
->execute();
diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc
index 773ce2514..10d5e7257 100644
--- a/modules/block/block.admin.inc
+++ b/modules/block/block.admin.inc
@@ -95,7 +95,7 @@ function block_admin_display_form_submit($form, &$form_state) {
foreach ($form_state['values'] as $block) {
$block['status'] = $block['region'] != BLOCK_REGION_NONE;
$block['region'] = $block['status'] ? $block['region'] : '';
- db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s' WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], $block['module'], $block['delta'], $block['theme']);
+ db_query("UPDATE {block} SET status = %d, weight = %d, region = '%s' WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], $block['module'], $block['delta'], $block['theme']);
}
drupal_set_message(t('The block settings have been updated.'));
cache_clear_all();
@@ -148,7 +148,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
'#value' => $delta,
);
- $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
+ $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {block} WHERE module = '%s' AND delta = '%s'", $module, $delta));
$form['block_settings'] = array(
'#type' => 'fieldset',
@@ -197,7 +197,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
// Role-based visibility settings.
$default_role_options = array();
- $result = db_query("SELECT rid FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $module, $delta);
+ $result = db_query("SELECT rid FROM {block_role} WHERE module = '%s' AND delta = '%s'", $module, $delta);
while ($role = db_fetch_object($result)) {
$default_role_options[] = $role->rid;
}
@@ -263,7 +263,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
function block_admin_configure_validate($form, &$form_state) {
if ($form_state['values']['module'] == 'block') {
- if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) {
+ if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {box} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) {
form_set_error('info', t('Please ensure that each block description is unique.'));
}
}
@@ -271,10 +271,10 @@ function block_admin_configure_validate($form, &$form_state) {
function block_admin_configure_submit($form, &$form_state) {
if (!form_get_errors()) {
- db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']);
- db_query("DELETE FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $form_state['values']['module'], $form_state['values']['delta']);
+ db_query("UPDATE {block} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']);
+ db_query("DELETE FROM {block_role} WHERE module = '%s' AND delta = '%s'", $form_state['values']['module'], $form_state['values']['delta']);
foreach (array_filter($form_state['values']['roles']) as $rid) {
- db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']);
+ db_query("INSERT INTO {block_role} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']);
}
module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']);
drupal_set_message(t('The block configuration has been saved.'));
@@ -292,7 +292,7 @@ function block_add_block_form(&$form_state) {
}
function block_add_block_form_validate($form, &$form_state) {
- if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE info = '%s'", $form_state['values']['info']))) {
+ if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {box} WHERE info = '%s'", $form_state['values']['info']))) {
form_set_error('info', t('Please ensure that each block description is unique.'));
}
}
@@ -301,17 +301,17 @@ function block_add_block_form_validate($form, &$form_state) {
* Save the new custom block.
*/
function block_add_block_form_submit($form, &$form_state) {
- db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['body_format']);
- $delta = db_last_insert_id('boxes', 'bid');
+ db_query("INSERT INTO {box} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['body_format']);
+ $delta = db_last_insert_id('box', 'bid');
foreach (list_themes() as $key => $theme) {
if ($theme->status) {
- db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, '%s', %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE);
+ db_query("INSERT INTO {block} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, '%s', %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE);
}
}
foreach (array_filter($form_state['values']['roles']) as $rid) {
- db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta);
+ db_query("INSERT INTO {block_role} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta);
}
drupal_set_message(t('The block has been created.'));
@@ -335,8 +335,8 @@ function block_box_delete(&$form_state, $bid = 0) {
* Deletion of custom blocks.
*/
function block_box_delete_submit($form, &$form_state) {
- db_query('DELETE FROM {boxes} WHERE bid = %d', $form_state['values']['bid']);
- db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = '%s'", $form_state['values']['bid']);
+ db_query('DELETE FROM {box} WHERE bid = %d', $form_state['values']['bid']);
+ db_query("DELETE FROM {block} WHERE module = 'block' AND delta = '%s'", $form_state['values']['bid']);
drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info'])));
cache_clear_all();
$form_state['redirect'] = 'admin/build/block';
diff --git a/modules/block/block.install b/modules/block/block.install
index 25e8186a6..0a7fda73f 100644
--- a/modules/block/block.install
+++ b/modules/block/block.install
@@ -5,7 +5,7 @@
* Implementation of hook_schema().
*/
function block_schema() {
- $schema['blocks'] = array(
+ $schema['block'] = array(
'description' => t('Stores block settings, such as region and visibility settings.'),
'fields' => array(
'bid' => array(
@@ -98,20 +98,20 @@ function block_schema() {
),
);
- $schema['blocks_roles'] = array(
+ $schema['block_role'] = array(
'description' => t('Sets up access permissions for blocks based on user roles'),
'fields' => array(
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
- 'description' => t("The block's origin module, from {blocks}.module."),
+ 'description' => t("The block's origin module, from {block}.module."),
),
'delta' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
- 'description' => t("The block's unique delta within module, from {blocks}.delta."),
+ 'description' => t("The block's unique delta within module, from {block}.delta."),
),
'rid' => array(
'type' => 'int',
@@ -126,14 +126,14 @@ function block_schema() {
),
);
- $schema['boxes'] = array(
+ $schema['box'] = array(
'description' => t('Stores contents of custom-made blocks.'),
'fields' => array(
'bid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- 'description' => t("The block's {blocks}.bid."),
+ 'description' => t("The block's {block}.bid."),
),
'body' => array(
'type' => 'text',
diff --git a/modules/block/block.module b/modules/block/block.module
index 95756a943..641f1cdea 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -189,7 +189,7 @@ function block_block($op = 'list', $delta = 0, $edit = array()) {
case 'list':
$blocks = array();
- $result = db_query('SELECT bid, info FROM {boxes} ORDER BY info');
+ $result = db_query('SELECT bid, info FROM {box} ORDER BY info');
while ($block = db_fetch_object($result)) {
$blocks[$block->bid]['info'] = $block->info;
// Not worth caching.
@@ -212,14 +212,14 @@ function block_block($op = 'list', $delta = 0, $edit = array()) {
break;
case 'view':
- $block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta));
+ $block = db_fetch_object(db_query('SELECT body, format FROM {box} WHERE bid = %d', $delta));
$data['content'] = check_markup($block->body, $block->format, '', FALSE);
return $data;
}
}
/**
- * Update the 'blocks' DB table with the blocks currently exported by modules.
+ * Update the 'block' DB table with the blocks currently exported by modules.
*
* @return
* Blocks currently exported by modules.
@@ -229,7 +229,7 @@ function _block_rehash() {
init_theme();
- $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
+ $result = db_query("SELECT * FROM {block} WHERE theme = '%s'", $theme_key);
$old_blocks = array();
while ($old_block = db_fetch_array($result)) {
$old_blocks[$old_block['module']][$old_block['delta']] = $old_block;
@@ -255,7 +255,7 @@ function _block_rehash() {
$block['pages'] = '';
}
// Add defaults and save it into the database.
- drupal_write_record('blocks', $block);
+ drupal_write_record('block', $block);
// Set region to none if not enabled.
$block['region'] = $block['status'] ? $block['region'] : BLOCK_REGION_NONE;
// Add to the list of blocks we return.
@@ -289,14 +289,14 @@ function _block_rehash() {
// Remove blocks that are no longer defined by the code from the database.
foreach ($old_blocks as $module => $old_module_blocks) {
foreach ($old_module_blocks as $delta => $block) {
- db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme_key);
+ db_query("DELETE FROM {block} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme_key);
}
}
return $blocks;
}
function block_box_get($bid) {
- return db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid));
+ return db_fetch_array(db_query("SELECT * FROM {box} WHERE bid = %d", $bid));
}
/**
@@ -335,7 +335,7 @@ function block_box_save($edit, $delta) {
$edit['body_format'] = FILTER_FORMAT_DEFAULT;
}
- db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['body_format'], $delta);
+ db_query("UPDATE {box} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['body_format'], $delta);
return TRUE;
}
@@ -346,7 +346,7 @@ function block_box_save($edit, $delta) {
function block_user_form(&$edit, &$account, $category = NULL) {
if ($category == 'account') {
$rids = array_keys($account->roles);
- $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids);
+ $result = db_query("SELECT DISTINCT b.* FROM {block} b LEFT JOIN {block_role} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids);
$form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, 'block', 'list');
@@ -413,7 +413,7 @@ function _block_load_blocks() {
$blocks = array();
$rids = array_keys($user->roles);
- $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
+ $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {block} b LEFT JOIN {block_role} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
while ($block = db_fetch_object($result)) {
if (!isset($blocks[$block->region])) {
$blocks[$block->region] = array();
diff --git a/modules/block/block.test b/modules/block/block.test
index 94e0d6e1d..c54e13213 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -37,7 +37,7 @@ class BlockTestCase extends DrupalWebTestCase {
// Confirm that the box has been created, and then query the created bid.
$this->assertText(t('The block has been created.'), t('Box successfully created.'));
- $bid = db_result(db_query("SELECT bid FROM {boxes} WHERE info = '%s'", array($box['info'])));
+ $bid = db_result(db_query("SELECT bid FROM {box} WHERE info = '%s'", array($box['info'])));
// Check to see if the box was created by checking that it's in the database..
$this->assertNotNull($bid, t('Box found in database'));
@@ -73,7 +73,7 @@ class BlockTestCase extends DrupalWebTestCase {
$this->drupalPost('admin/build/block/add', $box, t('Save block'));
// Set the created box to a specific region.
- $bid = db_result(db_query("SELECT bid FROM {boxes} WHERE info = '%s'", array($box['info'])));
+ $bid = db_result(db_query("SELECT bid FROM {box} WHERE info = '%s'", array($box['info'])));
$edit = array();
$edit['block_' . $bid . '[region]'] = 'left';
$this->drupalPost('admin/build/block', $edit, t('Save blocks'));
@@ -95,7 +95,7 @@ class BlockTestCase extends DrupalWebTestCase {
// Set block title to confirm that interface works and override any custom titles.
$this->drupalPost('admin/build/block/configure/' . $block['module'] . '/' . $block['delta'], array('title' => $block['title']), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block title set.'));
- $bid = db_result(db_query("SELECT bid FROM {blocks} WHERE module = '%s' AND delta = %d", array($block['module'], $block['delta'])));
+ $bid = db_result(db_query("SELECT bid FROM {block} WHERE module = '%s' AND delta = %d", array($block['module'], $block['delta'])));
// Check to see if the block was created by checking that it's in the database.
$this->assertNotNull($bid, t('Block found in database'));
diff --git a/modules/filter/filter.admin.inc b/modules/filter/filter.admin.inc
index f74fd2d6b..99449b1ce 100644
--- a/modules/filter/filter.admin.inc
+++ b/modules/filter/filter.admin.inc
@@ -288,7 +288,7 @@ function filter_admin_delete_submit($form, &$form_state) {
// Replace existing instances of the deleted format with the default format.
db_query("UPDATE {node_revisions} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
db_query("UPDATE {comments} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
- db_query("UPDATE {boxes} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
+ db_query("UPDATE {box} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
cache_clear_all($form_state['values']['format'] . ':', 'cache_filter', TRUE);
drupal_set_message(t('Deleted input format %format.', array('%format' => $form_state['values']['name'])));
diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc
index 300229247..5af961dc7 100644
--- a/modules/menu/menu.admin.inc
+++ b/modules/menu/menu.admin.inc
@@ -484,8 +484,8 @@ function menu_delete_menu_confirm_submit($form, &$form_state) {
db_query("DELETE FROM {menu_links} WHERE menu_name = '%s'", $menu['menu_name']);
db_query("DELETE FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']);
// Delete all the blocks for this menu.
- db_query("DELETE FROM {blocks} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']);
- db_query("DELETE FROM {blocks_roles} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']);
+ db_query("DELETE FROM {block} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']);
+ db_query("DELETE FROM {block_role} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']);
menu_cache_clear_all();
cache_clear_all();
$t_args = array('%title' => $menu['title']);
diff --git a/modules/system/system.install b/modules/system/system.install
index 4472c5a68..ff29e8b70 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -378,9 +378,9 @@ function system_install() {
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'theme_default', 's:7:"garland";');
db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'theme', 'garland');
- db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
- db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'navigation', 'garland', 1, 0, 'left', '', -1);
- db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', '', -1);
+ db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
+ db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'navigation', 'garland', 1, 0, 'left', '', -1);
+ db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', '', -1);
db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", 0, 0, 'all', 1, 0, 0);
@@ -3085,6 +3085,18 @@ function system_update_7011() {
}
/**
+ * Rename {blocks} table to {block}, {blocks_roles} to {block_role} and
+ * {boxes} to {box}.
+ */
+function system_update_7012() {
+ $ret = array();
+ db_rename_table($ret, 'blocks', 'block');
+ db_rename_table($ret, 'blocks_roles', 'block_role');
+ db_rename_table($ret, 'boxes', 'box');
+ return $ret;
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
diff --git a/modules/system/system.module b/modules/system/system.module
index 3b8d74500..9be9edbfd 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -840,7 +840,7 @@ function system_admin_menu_block($item) {
function system_admin_theme_submit($form, &$form_state) {
// If we're changing themes, make sure the theme has its blocks initialized.
if ($form_state['values']['admin_theme'] && $form_state['values']['admin_theme'] != variable_get('admin_theme', '0')) {
- $result = db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme']));
+ $result = db_result(db_query("SELECT COUNT(*) FROM {block} WHERE theme = '%s'", $form_state['values']['admin_theme']));
if (!$result) {
system_initialize_theme_blocks($form_state['values']['admin_theme']);
}
@@ -1181,16 +1181,16 @@ function system_default_region($theme) {
*/
function system_initialize_theme_blocks($theme) {
// Initialize theme's blocks if none already registered.
- if (!(db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $theme)))) {
+ if (!(db_result(db_query("SELECT COUNT(*) FROM {block} WHERE theme = '%s'", $theme)))) {
$default_theme = variable_get('theme_default', 'garland');
$regions = system_region_list($theme);
- $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
+ $result = db_query("SELECT * FROM {block} WHERE theme = '%s'", $default_theme);
while ($block = db_fetch_array($result)) {
// If the region isn't supported by the theme, assign the block to the theme's default region.
if (!array_key_exists($block['region'], $regions)) {
$block['region'] = system_default_region($theme);
}
- db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)",
+ db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, custom, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)",
$block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['cache']);
}
}