summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-03-20 15:06:51 +0000
committerDries Buytaert <dries@buytaert.net>2010-03-20 15:06:51 +0000
commitaadc94a102375f3e8656c23cb711097f827be96e (patch)
tree1f2c1d13750bdb63f55e55c962360ad1c0ed3300
parent5717ba536ec238e9b587e3fed6e3304e3d0d8056 (diff)
downloadbrdo-aadc94a102375f3e8656c23cb711097f827be96e.tar.gz
brdo-aadc94a102375f3e8656c23cb711097f827be96e.tar.bz2
- Patch #582948 by David_Rothstein: improve safety of schema manipulation.
-rw-r--r--includes/database/database.inc4
-rw-r--r--includes/update.inc92
-rw-r--r--modules/system/system.install5
-rw-r--r--modules/tracker/tracker.install9
4 files changed, 48 insertions, 62 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc
index bf8f0b549..287847d99 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -2477,9 +2477,7 @@ function db_next_id($existing_id = 0) {
* A Schema API table definition array.
*/
function db_create_table($name, $table) {
- if (!db_table_exists($name)) {
- return Database::getConnection()->schema()->createTable($name, $table);
- }
+ return Database::getConnection()->schema()->createTable($name, $table);
}
/**
diff --git a/includes/update.inc b/includes/update.inc
index 8157eeabe..3574f2d94 100644
--- a/includes/update.inc
+++ b/includes/update.inc
@@ -106,53 +106,55 @@ function update_prepare_d7_bootstrap() {
// The new cache_bootstrap bin is required to bootstrap to
// DRUPAL_BOOTSTRAP_SESSION, so create it here rather than in
// update_fix_d7_requirements().
- $cache_bootstrap = array(
- 'description' => 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.',
- 'fields' => array(
- 'cid' => array(
- 'description' => 'Primary Key: Unique cache ID.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- ),
- 'data' => array(
- 'description' => 'A collection of data to cache.',
- 'type' => 'blob',
- 'not null' => FALSE,
- 'size' => 'big',
- ),
- 'expire' => array(
- 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'created' => array(
- 'description' => 'A Unix timestamp indicating when the cache entry was created.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'headers' => array(
- 'description' => 'Any custom HTTP headers to be added to cached data.',
- 'type' => 'text',
- 'not null' => FALSE,
+ if (!db_table_exists('cache_bootstrap')) {
+ $cache_bootstrap = array(
+ 'description' => 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.',
+ 'fields' => array(
+ 'cid' => array(
+ 'description' => 'Primary Key: Unique cache ID.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'data' => array(
+ 'description' => 'A collection of data to cache.',
+ 'type' => 'blob',
+ 'not null' => FALSE,
+ 'size' => 'big',
+ ),
+ 'expire' => array(
+ 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'created' => array(
+ 'description' => 'A Unix timestamp indicating when the cache entry was created.',
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'headers' => array(
+ 'description' => 'Any custom HTTP headers to be added to cached data.',
+ 'type' => 'text',
+ 'not null' => FALSE,
+ ),
+ 'serialized' => array(
+ 'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
+ 'type' => 'int',
+ 'size' => 'small',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
),
- 'serialized' => array(
- 'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
- 'type' => 'int',
- 'size' => 'small',
- 'not null' => TRUE,
- 'default' => 0,
+ 'indexes' => array(
+ 'expire' => array('expire'),
),
- ),
- 'indexes' => array(
- 'expire' => array('expire'),
- ),
- 'primary key' => array('cid'),
- );
- db_create_table('cache_bootstrap', $cache_bootstrap);
+ 'primary key' => array('cid'),
+ );
+ db_create_table('cache_bootstrap', $cache_bootstrap);
+ }
}
/**
diff --git a/modules/system/system.install b/modules/system/system.install
index 32eb9eb1a..f4a7898a1 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -2274,11 +2274,6 @@ function system_update_7042() {
db_drop_field('url_alias', 'source');
db_drop_field('url_alias', 'alias');
- // Add the cache_path table.
- $schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
- $schema['cache_path']['description'] = 'Cache table used for path alias lookups.';
- db_create_table('cache_path', $schema['cache_path']);
-
// Drop indexes.
db_drop_index('url_alias', 'src_language_pid');
db_drop_unique_key('url_alias', 'dst_language_pid');
diff --git a/modules/tracker/tracker.install b/modules/tracker/tracker.install
index 5d8f86fb7..f377ff007 100644
--- a/modules/tracker/tracker.install
+++ b/modules/tracker/tracker.install
@@ -2,18 +2,9 @@
// $Id$
/**
- * Implements hook_install().
- */
-function tracker_install() {
- drupal_install_schema('tracker');
-}
-
-/**
* Implements hook_uninstall().
*/
function tracker_uninstall() {
- drupal_uninstall_schema('tracker');
-
variable_del('tracker_index_nid');
variable_del('tracker_batch_size');
}