| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Test and report Drupal installation requirements. 5 * 6 * @param $phase 7 * The current system installation phase. 8 * @return 9 * An array of system requirements. 10 */ 11 function system_requirements($phase) { 12 $requirements = array(); 13 // Ensure translations don't break at install time 14 $t = get_t(); 15 16 // Report Drupal version 17 if ($phase == 'runtime') { 18 $requirements['drupal'] = array( 19 'title' => $t('Drupal'), 20 'value' => VERSION, 21 'severity' => REQUIREMENT_INFO, 22 'weight' => -10, 23 ); 24 } 25 26 // Web server information. 27 $software = $_SERVER['SERVER_SOFTWARE']; 28 $requirements['webserver'] = array( 29 'title' => $t('Web server'), 30 'value' => $software, 31 ); 32 33 // Test PHP version 34 $requirements['php'] = array( 35 'title' => $t('PHP'), 36 'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/reports/status/php') : phpversion(), 37 ); 38 if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) { 39 $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP)); 40 $requirements['php']['severity'] = REQUIREMENT_ERROR; 41 } 42 43 // Test PHP register_globals setting. 44 $requirements['php_register_globals'] = array( 45 'title' => $t('PHP register globals'), 46 ); 47 $register_globals = trim(ini_get('register_globals')); 48 // Unfortunately, ini_get() may return many different values, and we can't 49 // be certain which values mean 'on', so we instead check for 'not off' 50 // since we never want to tell the user that their site is secure 51 // (register_globals off), when it is in fact on. We can only guarantee 52 // register_globals is off if the value returned is 'off', '', or 0. 53 if (!empty($register_globals) && strtolower($register_globals) != 'off') { 54 $requirements['php_register_globals']['description'] = $t('<em>register_globals</em> is enabled. Drupal requires this configuration directive to be disabled. Your site may not be secure when <em>register_globals</em> is enabled. The PHP manual has instructions for <a href="http://php.net/configuration.changes">how to change configuration settings</a>.'); 55 $requirements['php_register_globals']['severity'] = REQUIREMENT_ERROR; 56 $requirements['php_register_globals']['value'] = $t("Enabled ('@value')", array('@value' => $register_globals)); 57 } 58 else { 59 $requirements['php_register_globals']['value'] = $t('Disabled'); 60 } 61 62 // Test PHP memory_limit 63 $memory_limit = ini_get('memory_limit'); 64 $requirements['php_memory_limit'] = array( 65 'title' => $t('PHP memory limit'), 66 'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit, 67 ); 68 69 if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)) { 70 $description = ''; 71 if ($phase == 'install') { 72 $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)); 73 } 74 elseif ($phase == 'update') { 75 $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)); 76 } 77 elseif ($phase == 'runtime') { 78 $description = $t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)); 79 } 80 81 if (!empty($description)) { 82 if ($php_ini_path = get_cfg_var('cfg_file_path')) { 83 $description .= ' '. $t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array('%configuration-file' => $php_ini_path)); 84 } 85 else { 86 $description .= ' '. $t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.'); 87 } 88 89 $requirements['php_memory_limit']['description'] = $description .' '. $t('See the <a href="@url">Drupal requirements</a> for more information.', array('@url' => 'http://drupal.org/requirements')); 90 $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING; 91 } 92 } 93 94 // Test DB version 95 global $db_type; 96 if (function_exists('db_status_report')) { 97 $requirements += db_status_report($phase); 98 } 99 100 // Test settings.php file writability 101 if ($phase == 'runtime') { 102 $conf_dir = drupal_verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir'); 103 $conf_file = drupal_verify_install_file(conf_path() .'/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE); 104 if (!$conf_dir || !$conf_file) { 105 $requirements['settings.php'] = array( 106 'value' => $t('Not protected'), 107 'severity' => REQUIREMENT_ERROR, 108 'description' => '', 109 ); 110 if (!$conf_dir) { 111 $requirements['settings.php']['description'] .= $t('The directory %file is not protected from modifications and poses a security risk. You must change the directory\'s permissions to be non-writable. ', array('%file' => conf_path())); 112 } 113 if (!$conf_file) { 114 $requirements['settings.php']['description'] .= $t('The file %file is not protected from modifications and poses a security risk. You must change the file\'s permissions to be non-writable.', array('%file' => conf_path() .'/settings.php')); 115 } 116 } 117 else { 118 $requirements['settings.php'] = array( 119 'value' => $t('Protected'), 120 ); 121 } 122 $requirements['settings.php']['title'] = $t('Configuration file'); 123 } 124 125 // Report cron status. 126 if ($phase == 'runtime') { 127 // Cron warning threshold defaults to two days. 128 $threshold_warning = variable_get('cron_threshold_warning', 172800); 129 // Cron error threshold defaults to two weeks. 130 $threshold_error = variable_get('cron_threshold_error', 1209600); 131 // Cron configuration help text. 132 $help = $t('For more information, see the online handbook entry for <a href="@cron-handbook">configuring cron jobs</a>.', array('@cron-handbook' => 'http://drupal.org/cron')); 133 134 // Determine when cron last ran. If never, use the install time to 135 // determine the warning or error status. 136 $cron_last = variable_get('cron_last', NULL); 137 $never_run = FALSE; 138 if (!is_numeric($cron_last)) { 139 $never_run = TRUE; 140 $cron_last = variable_get('install_time', 0); 141 } 142 143 // Determine severity based on time since cron last ran. 144 $severity = REQUIREMENT_OK; 145 if (time() - $cron_last > $threshold_error) { 146 $severity = REQUIREMENT_ERROR; 147 } 148 else if ($never_run || (time() - $cron_last > $threshold_warning)) { 149 $severity = REQUIREMENT_WARNING; 150 } 151 152 // If cron hasn't been run, and the user is viewing the main 153 // administration page, instead of an error, we display a helpful reminder 154 // to configure cron jobs. 155 if ($never_run && $severity != REQUIREMENT_ERROR && $_GET['q'] == 'admin' && user_access('administer site configuration')) { 156 drupal_set_message($t('Cron has not run. Please visit the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status')))); 157 } 158 159 // Set summary and description based on values determined above. 160 if ($never_run) { 161 $summary = $t('Never run'); 162 $description = $t('Cron has not run.') .' '. $help; 163 } 164 else { 165 $summary = $t('Last run !time ago', array('!time' => format_interval(time() - $cron_last))); 166 $description = ''; 167 if ($severity != REQUIREMENT_OK) { 168 $description = $t('Cron has not run recently.') .' '. $help; 169 } 170 } 171 172 $requirements['cron'] = array( 173 'title' => $t('Cron maintenance tasks'), 174 'severity' => $severity, 175 'value' => $summary, 176 'description' => $description .' '. $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron'))), 177 ); 178 } 179 180 // Test files directory 181 $directory = file_directory_path(); 182 $requirements['file system'] = array( 183 'title' => $t('File system'), 184 ); 185 186 // For installer, create the directory if possible. 187 if ($phase == 'install' && !is_dir($directory) && @mkdir($directory)) { 188 @chmod($directory, 0775); // Necessary for non-webserver users. 189 } 190 191 $is_writable = is_writable($directory); 192 $is_directory = is_dir($directory); 193 if (!$is_writable || !$is_directory) { 194 $description = ''; 195 $requirements['file system']['value'] = $t('Not writable'); 196 if (!$is_directory) { 197 $error = $t('The directory %directory does not exist.', array('%directory' => $directory)); 198 } 199 else { 200 $error = $t('The directory %directory is not writable.', array('%directory' => $directory)); 201 } 202 // The files directory requirement check is done only during install and runtime. 203 if ($phase == 'runtime') { 204 $description = $error .' '. $t('You may need to set the correct directory at the <a href="@admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', array('@admin-file-system' => url('admin/settings/file-system'))); 205 } 206 elseif ($phase == 'install') { 207 // For the installer UI, we need different wording. 'value' will 208 // be treated as version, so provide none there. 209 $description = $error .' '. $t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually, or ensure that the installer has the permissions to create it automatically. For more information, please see INSTALL.txt or the <a href="@handbook_url">on-line handbook</a>.', array('@handbook_url' => 'http://drupal.org/server-permissions')); 210 $requirements['file system']['value'] = ''; 211 } 212 if (!empty($description)) { 213 $requirements['file system']['description'] = $description; 214 $requirements['file system']['severity'] = REQUIREMENT_ERROR; 215 } 216 } 217 else { 218 if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) { 219 $requirements['file system']['value'] = $t('Writable (<em>public</em> download method)'); 220 } 221 else { 222 $requirements['file system']['value'] = $t('Writable (<em>private</em> download method)'); 223 } 224 } 225 226 // See if updates are available in update.php. 227 if ($phase == 'runtime') { 228 $requirements['update'] = array( 229 'title' => $t('Database updates'), 230 'severity' => REQUIREMENT_OK, 231 'value' => $t('Up to date'), 232 ); 233 234 // Check installed modules. 235 foreach (module_list() as $module) { 236 $updates = drupal_get_schema_versions($module); 237 if ($updates !== FALSE) { 238 $default = drupal_get_installed_schema_version($module); 239 if (max($updates) > $default) { 240 $requirements['update']['severity'] = REQUIREMENT_ERROR; 241 $requirements['update']['value'] = $t('Out of date'); 242 $requirements['update']['description'] = $t('Some modules have database schema updates to install. You should run the <a href="@update">database update script</a> immediately.', array('@update' => base_path() .'update.php')); 243 break; 244 } 245 } 246 } 247 } 248 249 // Verify the update.php access setting 250 if ($phase == 'runtime') { 251 if (!empty($GLOBALS['update_free_access'])) { 252 $requirements['update access'] = array( 253 'value' => $t('Not protected'), 254 'severity' => REQUIREMENT_ERROR, 255 'description' => $t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the $update_free_access value in your settings.php back to FALSE.'), 256 ); 257 } 258 else { 259 $requirements['update access'] = array( 260 'value' => $t('Protected'), 261 ); 262 } 263 $requirements['update access']['title'] = $t('Access to update.php'); 264 } 265 266 // Test Unicode library 267 include_once './includes/unicode.inc'; 268 $requirements = array_merge($requirements, unicode_requirements()); 269 270 if ($phase == 'runtime') { 271 // Check for update status module. 272 if (!module_exists('update')) { 273 $requirements['update status'] = array( 274 'value' => $t('Not enabled'), 275 'severity' => REQUIREMENT_WARNING, 276 'description' => $t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the update status module from the <a href="@module">module administration page</a> in order to stay up-to-date on new releases. For more information please read the <a href="@update">Update status handbook page</a>.', array('@update' => 'http://drupal.org/handbook/modules/update', '@module' => url('admin/build/modules'))), 277 ); 278 } 279 else { 280 $requirements['update status'] = array( 281 'value' => $t('Enabled'), 282 ); 283 } 284 $requirements['update status']['title'] = $t('Update notifications'); 285 286 // Check that Drupal can issue HTTP requests. 287 if (variable_get('drupal_http_request_fails', TRUE) && !system_check_http_request()) { 288 $requirements['http requests'] = array( 289 'title' => $t('HTTP request status'), 290 'value' => $t('Fails'), 291 'severity' => REQUIREMENT_ERROR, 292 'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services.'), 293 ); 294 } 295 } 296 297 return $requirements; 298 } 299 300 /** 301 * Implementation of hook_install(). 302 */ 303 function system_install() { 304 if ($GLOBALS['db_type'] == 'pgsql') { 305 // We create some custom types and functions using global names instead of 306 // prefixing them like we do with table names. If this function is ever 307 // called again (for example, by the test framework when creating prefixed 308 // test databases), the global names will already exist. We therefore avoid 309 // trying to create them again in that case. 310 311 // Create unsigned types. 312 if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'int_unsigned_check'"))) { 313 db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)"); 314 } 315 if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'smallint_unsigned_check'"))) { 316 db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)"); 317 } 318 if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'bigint_unsigned_check'"))) { 319 db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)"); 320 } 321 322 // Create functions. 323 db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS 324 \'SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;\' 325 LANGUAGE \'sql\'' 326 ); 327 db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS 328 \'SELECT greatest($1, greatest($2, $3));\' 329 LANGUAGE \'sql\'' 330 ); 331 if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'"))) { 332 db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS 333 \'SELECT random();\' 334 LANGUAGE \'sql\'' 335 ); 336 } 337 338 if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat'"))) { 339 db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS 340 \'SELECT $1 || $2;\' 341 LANGUAGE \'sql\'' 342 ); 343 } 344 db_query('CREATE OR REPLACE FUNCTION "if"(boolean, text, text) RETURNS text AS 345 \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\' 346 LANGUAGE \'sql\'' 347 ); 348 db_query('CREATE OR REPLACE FUNCTION "if"(boolean, integer, integer) RETURNS integer AS 349 \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\' 350 LANGUAGE \'sql\'' 351 ); 352 } 353 354 // Create tables. 355 $modules = array('system', 'filter', 'block', 'user', 'node', 'comment', 'taxonomy'); 356 foreach ($modules as $module) { 357 drupal_install_schema($module); 358 } 359 360 // Clear out module list and hook implementation statics before calling 361 // system_theme_data(). 362 module_list(TRUE, FALSE); 363 module_implements('', FALSE, TRUE); 364 365 // Load system theme data appropriately. 366 system_theme_data(); 367 368 // Inserting uid 0 here confuses MySQL -- the next user might be created as 369 // uid 2 which is not what we want. So we insert the first user here, the 370 // anonymous user. uid is 1 here for now, but very soon it will be changed 371 // to 0. 372 db_query("INSERT INTO {users} (name, mail) VALUES('%s', '%s')", '', ''); 373 374 // We need some placeholders here as name and mail are uniques and data is 375 // presumed to be a serialized array. Install will change uid 1 immediately 376 // anyways. So we insert the superuser here, the uid is 2 here for now, but 377 // very soon it will be changed to 1. 378 db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', time(), serialize(array())); 379 380 // This sets the above two users uid 0 (anonymous). We avoid an explicit 0 381 // otherwise MySQL might insert the next auto_increment value. 382 db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", ''); 383 384 // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem. 385 db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1'); 386 387 db_query("INSERT INTO {role} (name) VALUES ('%s')", 'anonymous user'); 388 $rid_anonymous = db_last_insert_id('role', 'rid'); 389 390 db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user'); 391 $rid_authenticated = db_last_insert_id('role', 'rid'); 392 393 // Sanity check to ensure the anonymous and authenticated role IDs are the 394 // same as the drupal defined constants. In certain situations, this will 395 // not be true 396 if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) { 397 db_query("UPDATE {role} SET rid = %d WHERE rid = %d", DRUPAL_ANONYMOUS_RID, $rid_anonymous); 398 } 399 400 if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) { 401 db_query("UPDATE {role} SET rid = %d WHERE rid = %d", DRUPAL_AUTHENTICATED_RID, $rid_authenticated); 402 } 403 404 db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", DRUPAL_ANONYMOUS_RID, 'access content', 0); 405 db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", DRUPAL_AUTHENTICATED_RID, 'access comments, access content, post comments, post comments without approval', 0); 406 407 db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'theme_default', 's:7:"garland";'); 408 409 db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'theme', 'garland'); 410 db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '0', 'garland', 1, 0, 'left', '', -1); 411 db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '1', 'garland', 1, 0, 'left', '', -1); 412 db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', '0', 'garland', 1, 10, 'footer', '', -1); 413 414 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); 415 416 // Add input formats. 417 db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Filtered HTML', ',' . DRUPAL_ANONYMOUS_RID . ',' . DRUPAL_AUTHENTICATED_RID . ',', 1); 418 $filtered_html_format = db_last_insert_id('filter_formats', 'format'); 419 db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Full HTML', '', 1); 420 $full_html_format = db_last_insert_id('filter_formats', 'format'); 421 422 // Enable filters for each input format. 423 424 // Filtered HTML: 425 // URL filter. 426 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $filtered_html_format, 'filter', 2, 0); 427 // HTML filter. 428 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $filtered_html_format, 'filter', 0, 1); 429 // Line break filter. 430 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $filtered_html_format, 'filter', 1, 2); 431 // HTML corrector filter. 432 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $filtered_html_format, 'filter', 3, 10); 433 434 // Full HTML: 435 // URL filter. 436 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $full_html_format, 'filter', 2, 0); 437 // Line break filter. 438 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $full_html_format, 'filter', 1, 1); 439 // HTML corrector filter. 440 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $full_html_format, 'filter', 3, 10); 441 442 db_query("INSERT INTO {variable} (name, value) VALUES ('%s','%s')", 'filter_html_1', 'i:1;'); 443 db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'node_options_forum', 'a:1:{i:0;s:6:"status";}'); 444 } 445 446 /** 447 * Implementation of hook_schema(). 448 */ 449 function system_schema() { 450 // NOTE: {variable} needs to be created before all other tables, as 451 // some database drivers, e.g. Oracle and DB2, will require variable_get() 452 // and variable_set() for overcoming some database specific limitations. 453 $schema['variable'] = array( 454 'description' => 'Named variable/value pairs created by Drupal core or any other module or theme. All variables are cached in memory at the start of every Drupal request so developers should not be careless about what is stored here.', 455 'fields' => array( 456 'name' => array( 457 'description' => 'The name of the variable.', 458 'type' => 'varchar', 459 'length' => 128, 460 'not null' => TRUE, 461 'default' => ''), 462 'value' => array( 463 'description' => 'The value of the variable.', 464 'type' => 'text', 465 'not null' => TRUE, 466 'size' => 'big'), 467 ), 468 'primary key' => array('name'), 469 ); 470 471 $schema['actions'] = array( 472 'description' => 'Stores action information.', 473 'fields' => array( 474 'aid' => array( 475 'description' => 'Primary Key: Unique actions ID.', 476 'type' => 'varchar', 477 'length' => 255, 478 'not null' => TRUE, 479 'default' => '0'), 480 'type' => array( 481 'description' => 'The object that that action acts on (node, user, comment, system or custom types.)', 482 'type' => 'varchar', 483 'length' => 32, 484 'not null' => TRUE, 485 'default' => ''), 486 'callback' => array( 487 'description' => 'The callback function that executes when the action runs.', 488 'type' => 'varchar', 489 'length' => 255, 490 'not null' => TRUE, 491 'default' => ''), 492 'parameters' => array( 493 'description' => 'Parameters to be passed to the callback function.', 494 'type' => 'text', 495 'not null' => TRUE, 496 'size' => 'big'), 497 'description' => array( 498 'description' => 'Description of the action.', 499 'type' => 'varchar', 500 'length' => 255, 501 'not null' => TRUE, 502 'default' => '0'), 503 ), 504 'primary key' => array('aid'), 505 ); 506 507 $schema['actions_aid'] = array( 508 'description' => 'Stores action IDs for non-default actions.', 509 'fields' => array( 510 'aid' => array( 511 'description' => 'Primary Key: Unique actions ID.', 512 'type' => 'serial', 513 'unsigned' => TRUE, 514 'not null' => TRUE), 515 ), 516 'primary key' => array('aid'), 517 ); 518 519 $schema['batch'] = array( 520 'description' => t('Stores details about batches (processes that run in multiple HTTP requests).'), 521 'fields' => array( 522 'bid' => array( 523 'description' => 'Primary Key: Unique batch ID.', 524 'type' => 'serial', 525 'unsigned' => TRUE, 526 'not null' => TRUE), 527 'token' => array( 528 'description' => "A string token generated against the current user's session id and the batch id, used to ensure that only the user who submitted the batch can effectively access it.", 529 'type' => 'varchar', 530 'length' => 64, 531 'not null' => TRUE), 532 'timestamp' => array( 533 'description' => 'A Unix timestamp indicating when this batch was submitted for processing. Stale batches are purged at cron time.', 534 'type' => 'int', 535 'not null' => TRUE), 536 'batch' => array( 537 'description' => 'A serialized array containing the processing data for the batch.', 538 'type' => 'text', 539 'not null' => FALSE, 540 'size' => 'big') 541 ), 542 'primary key' => array('bid'), 543 'indexes' => array('token' => array('token')), 544 ); 545 546 $schema['cache'] = array( 547 'description' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.', 548 'fields' => array( 549 'cid' => array( 550 'description' => 'Primary Key: Unique cache ID.', 551 'type' => 'varchar', 552 'length' => 255, 553 'not null' => TRUE, 554 'default' => ''), 555 'data' => array( 556 'description' => 'A collection of data to cache.', 557 'type' => 'blob', 558 'not null' => FALSE, 559 'size' => 'big'), 560 'expire' => array( 561 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.', 562 'type' => 'int', 563 'not null' => TRUE, 564 'default' => 0), 565 'created' => array( 566 'description' => 'A Unix timestamp indicating when the cache entry was created.', 567 'type' => 'int', 568 'not null' => TRUE, 569 'default' => 0), 570 'headers' => array( 571 'description' => 'Any custom HTTP headers to be added to cached data.', 572 'type' => 'text', 573 'not null' => FALSE), 574 'serialized' => array( 575 'description' => 'A flag to indicate whether content is serialized (1) or not (0).', 576 'type' => 'int', 577 'size' => 'small', 578 'not null' => TRUE, 579 'default' => 0) 580 ), 581 'indexes' => array('expire' => array('expire')), 582 'primary key' => array('cid'), 583 ); 584 585 $schema['cache_form'] = $schema['cache']; 586 $schema['cache_form']['description'] = 'Cache table for the form system to store recently built forms and their storage data, to be used in subsequent page requests.'; 587 $schema['cache_page'] = $schema['cache']; 588 $schema['cache_page']['description'] = 'Cache table used to store compressed pages for anonymous users, if page caching is enabled.'; 589 $schema['cache_menu'] = $schema['cache']; 590 $schema['cache_menu']['description'] = 'Cache table for the menu system to store router information as well as generated link trees for various menu/page/user combinations.'; 591 592 $schema['files'] = array( 593 'description' => 'Stores information for uploaded files.', 594 'fields' => array( 595 'fid' => array( 596 'description' => 'Primary Key: Unique files ID.', 597 'type' => 'serial', 598 'unsigned' => TRUE, 599 'not null' => TRUE), 600 'uid' => array( 601 'description' => 'The {users}.uid of the user who is associated with the file.', 602 'type' => 'int', 603 'unsigned' => TRUE, 604 'not null' => TRUE, 605 'default' => 0), 606 'filename' => array( 607 'description' => 'Name of the file.', 608 'type' => 'varchar', 609 'length' => 255, 610 'not null' => TRUE, 611 'default' => ''), 612 'filepath' => array( 613 'description' => 'Path of the file relative to Drupal root.', 614 'type' => 'varchar', 615 'length' => 255, 616 'not null' => TRUE, 617 'default' => ''), 618 'filemime' => array( 619 'description' => 'The file MIME type.', 620 'type' => 'varchar', 621 'length' => 255, 622 'not null' => TRUE, 623 'default' => ''), 624 'filesize' => array( 625 'description' => 'The size of the file in bytes.', 626 'type' => 'int', 627 'unsigned' => TRUE, 628 'not null' => TRUE, 629 'default' => 0), 630 'status' => array( 631 'description' => 'A flag indicating whether file is temporary (0) or permanent (1).', 632 'type' => 'int', 633 'not null' => TRUE, 634 'default' => 0), 635 'timestamp' => array( 636 'description' => 'UNIX timestamp for when the file was added.', 637 'type' => 'int', 638 'unsigned' => TRUE, 639 'not null' => TRUE, 640 'default' => 0), 641 ), 642 'indexes' => array( 643 'uid' => array('uid'), 644 'status' => array('status'), 645 'timestamp' => array('timestamp'), 646 ), 647 'primary key' => array('fid'), 648 ); 649 650 $schema['flood'] = array( 651 'description' => 'Flood controls the threshold of events, such as the number of contact attempts.', 652 'fields' => array( 653 'fid' => array( 654 'description' => 'Unique flood event ID.', 655 'type' => 'serial', 656 'not null' => TRUE), 657 'event' => array( 658 'description' => 'Name of event (e.g. contact).', 659 'type' => 'varchar', 660 'length' => 64, 661 'not null' => TRUE, 662 'default' => ''), 663 'hostname' => array( 664 'description' => 'Hostname of the visitor.', 665 'type' => 'varchar', 666 'length' => 128, 667 'not null' => TRUE, 668 'default' => ''), 669 'timestamp' => array( 670 'description' => 'Timestamp of the event.', 671 'type' => 'int', 672 'not null' => TRUE, 673 'default' => 0) 674 ), 675 'primary key' => array('fid'), 676 'indexes' => array( 677 'allow' => array('event', 'hostname', 'timestamp'), 678 ), 679 ); 680 681 $schema['history'] = array( 682 'description' => 'A record of which {users} have read which {node}s.', 683 'fields' => array( 684 'uid' => array( 685 'description' => 'The {users}.uid that read the {node} nid.', 686 'type' => 'int', 687 'not null' => TRUE, 688 'default' => 0), 689 'nid' => array( 690 'description' => 'The {node}.nid that was read.', 691 'type' => 'int', 692 'not null' => TRUE, 693 'default' => 0), 694 'timestamp' => array( 695 'description' => 'The Unix timestamp at which the read occurred.', 696 'type' => 'int', 697 'not null' => TRUE, 698 'default' => 0) 699 ), 700 'primary key' => array('uid', 'nid'), 701 'indexes' => array( 702 'nid' => array('nid'), 703 ), 704 ); 705 $schema['menu_router'] = array( 706 'description' => 'Maps paths to various callbacks (access, page and title)', 707 'fields' => array( 708 'path' => array( 709 'description' => 'Primary Key: the Drupal path this entry describes', 710 'type' => 'varchar', 711 'length' => 255, 712 'not null' => TRUE, 713 'default' => ''), 714 'load_functions' => array( 715 'description' => 'A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.', 716 'type' => 'text', 717 'not null' => TRUE,), 718 'to_arg_functions' => array( 719 'description' => 'A serialized array of function names (like user_uid_optional_to_arg) to be called to replace a part of the router path with another string.', 720 'type' => 'text', 721 'not null' => TRUE,), 722 'access_callback' => array( 723 'description' => 'The callback which determines the access to this router path. Defaults to user_access.', 724 'type' => 'varchar', 725 'length' => 255, 726 'not null' => TRUE, 727 'default' => ''), 728 'access_arguments' => array( 729 'description' => 'A serialized array of arguments for the access callback.', 730 'type' => 'text', 731 'not null' => FALSE), 732 'page_callback' => array( 733 'description' => 'The name of the function that renders the page.', 734 'type' => 'varchar', 735 'length' => 255, 736 'not null' => TRUE, 737 'default' => ''), 738 'page_arguments' => array( 739 'description' => 'A serialized array of arguments for the page callback.', 740 'type' => 'text', 741 'not null' => FALSE), 742 'fit' => array( 743 'description' => 'A numeric representation of how specific the path is.', 744 'type' => 'int', 745 'not null' => TRUE, 746 'default' => 0), 747 'number_parts' => array( 748 'description' => 'Number of parts in this router path.', 749 'type' => 'int', 750 'not null' => TRUE, 751 'default' => 0, 752 'size' => 'small'), 753 'tab_parent' => array( 754 'description' => 'Only for local tasks (tabs) - the router path of the parent page (which may also be a local task).', 755 'type' => 'varchar', 756 'length' => 255, 757 'not null' => TRUE, 758 'default' => ''), 759 'tab_root' => array( 760 'description' => 'Router path of the closest non-tab parent page. For pages that are not local tasks, this will be the same as the path.', 761 'type' => 'varchar', 762 'length' => 255, 763 'not null' => TRUE, 764 'default' => ''), 765 'title' => array( 766 'description' => 'The title for the current page, or the title for the tab if this is a local task.', 767 'type' => 'varchar', 768 'length' => 255, 769 'not null' => TRUE, 770 'default' => ''), 771 'title_callback' => array( 772 'description' => 'A function which will alter the title. Defaults to t()', 773 'type' => 'varchar', 774 'length' => 255, 775 'not null' => TRUE, 776 'default' => ''), 777 'title_arguments' => array( 778 'description' => 'A serialized array of arguments for the title callback. If empty, the title will be used as the sole argument for the title callback.', 779 'type' => 'varchar', 780 'length' => 255, 781 'not null' => TRUE, 782 'default' => ''), 783 'type' => array( 784 'description' => 'Numeric representation of the type of the menu item, like MENU_LOCAL_TASK.', 785 'type' => 'int', 786 'not null' => TRUE, 787 'default' => 0), 788 'block_callback' => array( 789 'description' => 'Name of a function used to render the block on the system administration page for this item.', 790 'type' => 'varchar', 791 'length' => 255, 792 'not null' => TRUE, 793 'default' => ''), 794 'description' => array( 795 'description' => 'A description of this item.', 796 'type' => 'text', 797 'not null' => TRUE), 798 'position' => array( 799 'description' => 'The position of the block (left or right) on the system administration page for this item.', 800 'type' => 'varchar', 801 'length' => 255, 802 'not null' => TRUE, 803 'default' => ''), 804 'weight' => array( 805 'description' => 'Weight of the element. Lighter weights are higher up, heavier weights go down.', 806 'type' => 'int', 807 'not null' => TRUE, 808 'default' => 0), 809 'file' => array( 810 'description' => 'The file to include for this element, usually the page callback function lives in this file.', 811 'type' => 'text', 812 'size' => 'medium') 813 ), 814 'indexes' => array( 815 'fit' => array('fit'), 816 'tab_parent' => array('tab_parent'), 817 'tab_root_weight_title' => array(array('tab_root', 64), 'weight', 'title'), 818 ), 819 'primary key' => array('path'), 820 ); 821 822 $schema['menu_links'] = array( 823 'description' => 'Contains the individual links within a menu.', 824 'fields' => array( 825 'menu_name' => array( 826 'description' => "The menu name. All links with the same menu name (such as 'navigation') are part of the same menu.", 827 'type' => 'varchar', 828 'length' => 32, 829 'not null' => TRUE, 830 'default' => ''), 831 'mlid' => array( 832 'description' => 'The menu link ID (mlid) is the integer primary key.', 833 'type' => 'serial', 834 'unsigned' => TRUE, 835 'not null' => TRUE), 836 'plid' => array( 837 'description' => 'The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.', 838 'type' => 'int', 839 'unsigned' => TRUE, 840 'not null' => TRUE, 841 'default' => 0), 842 'link_path' => array( 843 'description' => 'The Drupal path or external path this link points to.', 844 'type' => 'varchar', 845 'length' => 255, 846 'not null' => TRUE, 847 'default' => ''), 848 'router_path' => array( 849 'description' => 'For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.', 850 'type' => 'varchar', 851 'length' => 255, 852 'not null' => TRUE, 853 'default' => ''), 854 'link_title' => array( 855 'description' => 'The text displayed for the link, which may be modified by a title callback stored in {menu_router}.', 856 'type' => 'varchar', 857 'length' => 255, 858 'not null' => TRUE, 859 'default' => ''), 860 'options' => array( 861 'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.', 862 'type' => 'text', 863 'not null' => FALSE), 864 'module' => array( 865 'description' => 'The name of the module that generated this link.', 866 'type' => 'varchar', 867 'length' => 255, 868 'not null' => TRUE, 869 'default' => 'system'), 870 'hidden' => array( 871 'description' => 'A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)', 872 'type' => 'int', 873 'not null' => TRUE, 874 'default' => 0, 875 'size' => 'small'), 876 'external' => array( 877 'description' => 'A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).', 878 'type' => 'int', 879 'not null' => TRUE, 880 'default' => 0, 881 'size' => 'small'), 882 'has_children' => array( 883 'description' => 'Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).', 884 'type' => 'int', 885 'not null' => TRUE, 886 'default' => 0, 887 'size' => 'small'), 888 'expanded' => array( 889 'description' => 'Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)', 890 'type' => 'int', 891 'not null' => TRUE, 892 'default' => 0, 893 'size' => 'small'), 894 'weight' => array( 895 'description' => 'Link weight among links in the same menu at the same depth.', 896 'type' => 'int', 897 'not null' => TRUE, 898 'default' => 0), 899 'depth' => array( 900 'description' => 'The depth relative to the top level. A link with plid == 0 will have depth == 1.', 901 'type' => 'int', 902 'not null' => TRUE, 903 'default' => 0, 904 'size' => 'small'), 905 'customized' => array( 906 'description' => 'A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).', 907 'type' => 'int', 908 'not null' => TRUE, 909 'default' => 0, 910 'size' => 'small'), 911 'p1' => array( 912 'description' => 'The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.', 913 'type' => 'int', 914 'unsigned' => TRUE, 915 'not null' => TRUE, 916 'default' => 0), 917 'p2' => array( 918 'description' => 'The second mlid in the materialized path. See p1.', 919 'type' => 'int', 920 'unsigned' => TRUE, 921 'not null' => TRUE, 922 'default' => 0), 923 'p3' => array( 924 'description' => 'The third mlid in the materialized path. See p1.', 925 'type' => 'int', 926 'unsigned' => TRUE, 927 'not null' => TRUE, 928 'default' => 0), 929 'p4' => array( 930 'description' => 'The fourth mlid in the materialized path. See p1.', 931 'type' => 'int', 932 'unsigned' => TRUE, 933 'not null' => TRUE, 934 'default' => 0), 935 'p5' => array( 936 'description' => 'The fifth mlid in the materialized path. See p1.', 937 'type' => 'int', 938 'unsigned' => TRUE, 939 'not null' => TRUE, 940 'default' => 0), 941 'p6' => array( 942 'description' => 'The sixth mlid in the materialized path. See p1.', 943 'type' => 'int', 944 'unsigned' => TRUE, 945 'not null' => TRUE, 946 'default' => 0), 947 'p7' => array( 948 'description' => 'The seventh mlid in the materialized path. See p1.', 949 'type' => 'int', 950 'unsigned' => TRUE, 951 'not null' => TRUE, 952 'default' => 0), 953 'p8' => array( 954 'description' => 'The eighth mlid in the materialized path. See p1.', 955 'type' => 'int', 956 'unsigned' => TRUE, 957 'not null' => TRUE, 958 'default' => 0), 959 'p9' => array( 960 'description' => 'The ninth mlid in the materialized path. See p1.', 961 'type' => 'int', 962 'unsigned' => TRUE, 963 'not null' => TRUE, 964 'default' => 0), 965 'updated' => array( 966 'description' => 'Flag that indicates that this link was generated during the update from Drupal 5.', 967 'type' => 'int', 968 'not null' => TRUE, 969 'default' => 0, 970 'size' => 'small'), 971 ), 972 'indexes' => array( 973 'path_menu' => array(array('link_path', 128), 'menu_name'), 974 'menu_plid_expand_child' => array( 975 'menu_name', 'plid', 'expanded', 'has_children'), 976 'menu_parents' => array( 977 'menu_name', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'), 978 'router_path' => array(array('router_path', 128)), 979 ), 980 'primary key' => array('mlid'), 981 ); 982 983 $schema['semaphore'] = array( 984 'description' => 'Table for holding semaphores, locks, flags, etc. that cannot be stored as Drupal variables since they must not be cached.', 985 'fields' => array( 986 'name' => array( 987 'description' => 'Primary Key: Unique name.', 988 'type' => 'varchar', 989 'length' => 255, 990 'not null' => TRUE, 991 'default' => ''), 992 'value' => array( 993 'description' => 'A value.', 994 'type' => 'varchar', 995 'length' => 255, 996 'not null' => TRUE, 997 'default' => ''), 998 'expire' => array( 999 'description' => 'A Unix timestamp with microseconds indicating when the semaphore should expire.', 1000 'type' => 'float', 1001 'size' => 'big', 1002 'not null' => TRUE), 1003 ), 1004 'indexes' => array('expire' => array('expire')), 1005 'primary key' => array('name'), 1006 ); 1007 1008 $schema['sessions'] = array( 1009 'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.", 1010 'fields' => array( 1011 'uid' => array( 1012 'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.', 1013 'type' => 'int', 1014 'unsigned' => TRUE, 1015 'not null' => TRUE), 1016 'sid' => array( 1017 'description' => "Primary key: A session ID. The value is generated by PHP's Session API.", 1018 'type' => 'varchar', 1019 'length' => 64, 1020 'not null' => TRUE, 1021 'default' => ''), 1022 'hostname' => array( 1023 'description' => 'The IP address that last used this session ID (sid).', 1024 'type' => 'varchar', 1025 'length' => 128, 1026 'not null' => TRUE, 1027 'default' => ''), 1028 'timestamp' => array( 1029 'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.', 1030 'type' => 'int', 1031 'not null' => TRUE, 1032 'default' => 0), 1033 'cache' => array( 1034 'description' => "The time of this user's last post. This is used when the site has specified a minimum_cache_lifetime. See cache_get().", 1035 'type' => 'int', 1036 'not null' => TRUE, 1037 'default' => 0), 1038 'session' => array( 1039 'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.', 1040 'type' => 'text', 1041 'not null' => FALSE, 1042 'size' => 'big') 1043 ), 1044 'primary key' => array('sid'), 1045 'indexes' => array( 1046 'timestamp' => array('timestamp'), 1047 'uid' => array('uid') 1048 ), 1049 ); 1050 1051 $schema['system'] = array( 1052 'description' => "A list of all modules, themes, and theme engines that are or have been installed in Drupal's file system.", 1053 'fields' => array( 1054 'filename' => array( 1055 'description' => 'The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.', 1056 'type' => 'varchar', 1057 'length' => 255, 1058 'not null' => TRUE, 1059 'default' => ''), 1060 'name' => array( 1061 'description' => 'The name of the item; e.g. node.', 1062 'type' => 'varchar', 1063 'length' => 255, 1064 'not null' => TRUE, 1065 'default' => ''), 1066 'type' => array( 1067 'description' => 'The type of the item, either module, theme, or theme_engine.', 1068 'type' => 'varchar', 1069 'length' => 255, 1070 'not null' => TRUE, 1071 'default' => ''), 1072 'owner' => array( 1073 'description' => "A theme's 'parent'. Can be either a theme or an engine.", 1074 'type' => 'varchar', 1075 'length' => 255, 1076 'not null' => TRUE, 1077 'default' => ''), 1078 'status' => array( 1079 'description' => 'Boolean indicating whether or not this item is enabled.', 1080 'type' => 'int', 1081 'not null' => TRUE, 1082 'default' => 0), 1083 'throttle' => array( 1084 'description' => 'Boolean indicating whether this item is disabled when the throttle.module disables throttleable items.', 1085 'type' => 'int', 1086 'not null' => TRUE, 1087 'default' => 0, 1088 'size' => 'tiny'), 1089 'bootstrap' => array( 1090 'description' => "Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted).", 1091 'type' => 'int', 1092 'not null' => TRUE, 1093 'default' => 0), 1094 'schema_version' => array( 1095 'description' => "The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed.", 1096 'type' => 'int', 1097 'not null' => TRUE, 1098 'default' => -1, 1099 'size' => 'small'), 1100 'weight' => array( 1101 'description' => "The order in which this module's hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name.", 1102 'type' => 'int', 1103 'not null' => TRUE, 1104 'default' => 0), 1105 'info' => array( 1106 'description' => "A serialized array containing information from the module's .info file; keys can include name, description, package, version, core, dependencies, dependents, and php.", 1107 'type' => 'text', 1108 'not null' => FALSE) 1109 ), 1110 'primary key' => array('filename'), 1111 'indexes' => 1112 array( 1113 'modules' => array(array('type', 12), 'status', 'weight', 'filename'), 1114 'bootstrap' => array(array('type', 12), 'status', 'bootstrap', 'weight', 'filename'), 1115 'type_name' => array(array('type', 12), 'name'), 1116 ), 1117 ); 1118 1119 $schema['url_alias'] = array( 1120 'description' => 'A list of URL aliases for Drupal paths; a user may visit either the source or destination path.', 1121 'fields' => array( 1122 'pid' => array( 1123 'description' => 'A unique path alias identifier.', 1124 'type' => 'serial', 1125 'unsigned' => TRUE, 1126 'not null' => TRUE), 1127 'src' => array( 1128 'description' => 'The Drupal path this alias is for; e.g. node/12.', 1129 'type' => 'varchar', 1130 'length' => 128, 1131 'not null' => TRUE, 1132 'default' => ''), 1133 'dst' => array( 1134 'description' => 'The alias for this path; e.g. title-of-the-story.', 1135 'type' => 'varchar', 1136 'length' => 128, 1137 'not null' => TRUE, 1138 'default' => ''), 1139 'language' => array( 1140 'description' => 'The language this alias is for; if blank, the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.', 1141 'type' => 'varchar', 1142 'length' => 12, 1143 'not null' => TRUE, 1144 'default' => '') 1145 ), 1146 'unique keys' => array('dst_language_pid' => array('dst', 'language', 'pid')), 1147 'primary key' => array('pid'), 1148 'indexes' => array('src_language_pid' => array('src', 'language', 'pid')), 1149 ); 1150 1151 return $schema; 1152 } 1153 1154 // Updates for core. 1155 1156 function system_update_last_removed() { 1157 return 1021; 1158 } 1159 1160 /** 1161 * @defgroup updates-5.x-extra Extra system updates for 5.x 1162 * @{ 1163 */ 1164 1165 /** 1166 * Add index on users created column. 1167 */ 1168 function system_update_1022() { 1169 $ret = array(); 1170 db_add_index($ret, 'users', 'created', array('created')); 1171 // Also appears as system_update_6004(). Ensure we don't update twice. 1172 variable_set('system_update_1022', TRUE); 1173 return $ret; 1174 } 1175 1176 /** 1177 * @} End of "defgroup updates-5.x-extra" 1178 */ 1179 1180 /** 1181 * @defgroup updates-5.x-to-6.x System updates from 5.x to 6.x 1182 * @{ 1183 */ 1184 1185 /** 1186 * Remove auto_increment from {boxes} to allow adding custom blocks with 1187 * visibility settings. 1188 */ 1189 function system_update_6000() { 1190 $ret = array(); 1191 switch ($GLOBALS['db_type']) { 1192 case 'mysql': 1193 case 'mysqli': 1194 $max = (int)db_result(db_query('SELECT MAX(bid) FROM {boxes}')); 1195 $ret[] = update_sql('ALTER TABLE {boxes} CHANGE COLUMN bid bid int NOT NULL'); 1196 $ret[] = update_sql("REPLACE INTO {sequences} VALUES ('{boxes}_bid', $max)"); 1197 break; 1198 } 1199 return $ret; 1200 } 1201 1202 /** 1203 * Add version id column to {term_node} to allow taxonomy module to use revisions. 1204 */ 1205 function system_update_6001() { 1206 $ret = array(); 1207 1208 // Add vid to term-node relation. The schema says it is unsigned. 1209 db_add_field($ret, 'term_node', 'vid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 1210 db_drop_primary_key($ret, 'term_node'); 1211 db_add_primary_key($ret, 'term_node', array('vid', 'tid', 'nid')); 1212 db_add_index($ret, 'term_node', 'vid', array('vid')); 1213 1214 db_query('UPDATE {term_node} SET vid = (SELECT vid FROM {node} n WHERE {term_node}.nid = n.nid)'); 1215 return $ret; 1216 } 1217 1218 /** 1219 * Increase the maximum length of variable names from 48 to 128. 1220 */ 1221 function system_update_6002() { 1222 $ret = array(); 1223 db_drop_primary_key($ret, 'variable'); 1224 db_change_field($ret, 'variable', 'name', 'name', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')); 1225 db_add_primary_key($ret, 'variable', array('name')); 1226 return $ret; 1227 } 1228 1229 /** 1230 * Add index on comments status column. 1231 */ 1232 function system_update_6003() { 1233 $ret = array(); 1234 db_add_index($ret, 'comments', 'status', array('status')); 1235 return $ret; 1236 } 1237 1238 /** 1239 * This update used to add an index on users created column (#127941). 1240 * However, system_update_1022() does the same thing. This update 1241 * tried to detect if 1022 had already run but failed to do so, 1242 * resulting in an "index already exists" error. 1243 * 1244 * Adding the index here is never necessary. Sites installed before 1245 * 1022 will run 1022, getting the update. Sites installed on/after 1022 1246 * got the index when the table was first created. Therefore, this 1247 * function is now a no-op. 1248 */ 1249 function system_update_6004() { 1250 return array(); 1251 } 1252 1253 /** 1254 * Add language to url_alias table and modify indexes. 1255 */ 1256 function system_update_6005() { 1257 $ret = array(); 1258 switch ($GLOBALS['db_type']) { 1259 case 'pgsql': 1260 db_add_column($ret, 'url_alias', 'language', 'varchar(12)', array('default' => "''", 'not null' => TRUE)); 1261 1262 // As of system.install:1.85 (before the new language 1263 // subsystem), new installs got a unique key named 1264 // url_alias_dst_key on url_alias.dst. Unfortunately, 1265 // system_update_162 created a unique key inconsistently named 1266 // url_alias_dst_idx on url_alias.dst (keys should have the _key 1267 // suffix, indexes the _idx suffix). Therefore, sites installed 1268 // before system_update_162 have a unique key with a different 1269 // name than sites installed after system_update_162(). Now, we 1270 // want to drop the unique key on dst which may have either one 1271 // of two names and create a new unique key on (dst, language). 1272 // There is no way to know which key name exists so we have to 1273 // drop both, causing an SQL error. Thus, we just hide the 1274 // error and only report the update_sql results that work. 1275 $err = error_reporting(0); 1276 $ret1 = update_sql('DROP INDEX {url_alias}_dst_idx'); 1277 if ($ret1['success']) { 1278 $ret[] = $ret1; 1279 } 1280 $ret1 = array(); 1281 db_drop_unique_key($ret, 'url_alias', 'dst'); 1282 foreach ($ret1 as $r) { 1283 if ($r['success']) { 1284 $ret[] = $r; 1285 } 1286 } 1287 error_reporting($err); 1288 1289 $ret[] = update_sql('CREATE UNIQUE INDEX {url_alias}_dst_language_idx ON {url_alias}(dst, language)'); 1290 break; 1291 case 'mysql': 1292 case 'mysqli': 1293 $ret[] = update_sql("ALTER TABLE {url_alias} ADD language varchar(12) NOT NULL default ''"); 1294 $ret[] = update_sql("ALTER TABLE {url_alias} DROP INDEX dst"); 1295 $ret[] = update_sql("ALTER TABLE {url_alias} ADD UNIQUE dst_language (dst, language)"); 1296 break; 1297 } 1298 return $ret; 1299 } 1300 1301 /** 1302 * Drop useless indices on node_counter table. 1303 */ 1304 function system_update_6006() { 1305 $ret = array(); 1306 switch ($GLOBALS['db_type']) { 1307 case 'pgsql': 1308 $ret[] = update_sql('DROP INDEX {node_counter}_daycount_idx'); 1309 $ret[] = update_sql('DROP INDEX {node_counter}_totalcount_idx'); 1310 $ret[] = update_sql('DROP INDEX {node_counter}_timestamp_idx'); 1311 break; 1312 case 'mysql': 1313 case 'mysqli': 1314 $ret[] = update_sql("ALTER TABLE {node_counter} DROP INDEX daycount"); 1315 $ret[] = update_sql("ALTER TABLE {node_counter} DROP INDEX totalcount"); 1316 $ret[] = update_sql("ALTER TABLE {node_counter} DROP INDEX timestamp"); 1317 break; 1318 } 1319 return $ret; 1320 } 1321 1322 /** 1323 * Change the severity column in the watchdog table to the new values. 1324 */ 1325 function system_update_6007() { 1326 $ret = array(); 1327 $ret[] = update_sql("UPDATE {watchdog} SET severity = ". WATCHDOG_NOTICE ." WHERE severity = 0"); 1328 $ret[] = update_sql("UPDATE {watchdog} SET severity = ". WATCHDOG_WARNING ." WHERE severity = 1"); 1329 $ret[] = update_sql("UPDATE {watchdog} SET severity = ". WATCHDOG_ERROR ." WHERE severity = 2"); 1330 return $ret; 1331 } 1332 1333 /** 1334 * Add info files to themes. The info and owner columns are added by 1335 * update_fix_d6_requirements() in update.php to avoid a large number 1336 * of error messages from update.php. All we need to do here is copy 1337 * description to owner and then drop description. 1338 */ 1339 function system_update_6008() { 1340 $ret = array(); 1341 $ret[] = update_sql('UPDATE {system} SET owner = description'); 1342 db_drop_field($ret, 'system', 'description'); 1343 1344 // Rebuild system table contents. 1345 module_rebuild_cache(); 1346 system_theme_data(); 1347 1348 return $ret; 1349 } 1350 1351 /** 1352 * The PHP filter is now a separate module. 1353 */ 1354 function system_update_6009() { 1355 $ret = array(); 1356 1357 // If any input format used the Drupal 5 PHP filter. 1358 if (db_result(db_query("SELECT COUNT(format) FROM {filters} WHERE module = 'filter' AND delta = 1"))) { 1359 // Enable the PHP filter module. 1360 $ret[] = update_sql("UPDATE {system} SET status = 1 WHERE name = 'php' AND type = 'module'"); 1361 // Update the input filters. 1362 $ret[] = update_sql("UPDATE {filters} SET delta = 0, module = 'php' WHERE module = 'filter' AND delta = 1"); 1363 } 1364 1365 // With the removal of the PHP evaluator filter, the deltas of the line break 1366 // and URL filter have changed. 1367 $ret[] = update_sql("UPDATE {filters} SET delta = 1 WHERE module = 'filter' AND delta = 2"); 1368 $ret[] = update_sql("UPDATE {filters} SET delta = 2 WHERE module = 'filter' AND delta = 3"); 1369 1370 return $ret; 1371 } 1372 1373 /** 1374 * Add variable replacement for watchdog messages. 1375 * 1376 * The variables field is NOT NULL and does not have a default value. 1377 * Existing log messages should not be translated in the new system, 1378 * so we insert 'N;' (serialize(NULL)) as the temporary default but 1379 * then remove the default value to match the schema. 1380 */ 1381 function system_update_6010() { 1382 $ret = array(); 1383 db_add_field($ret, 'watchdog', 'variables', array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'initial' => 'N;')); 1384 return $ret; 1385 } 1386 1387 /** 1388 * Add language support to nodes 1389 */ 1390 function system_update_6011() { 1391 $ret = array(); 1392 switch ($GLOBALS['db_type']) { 1393 case 'pgsql': 1394 db_add_column($ret, 'node', 'language', 'varchar(12)', array('default' => "''", 'not null' => TRUE)); 1395 break; 1396 case 'mysql': 1397 case 'mysqli': 1398 $ret[] = update_sql("ALTER TABLE {node} ADD language varchar(12) NOT NULL default ''"); 1399 break; 1400 } 1401 return $ret; 1402 } 1403 1404 /** 1405 * Add serialized field to cache tables. This is now handled directly 1406 * by update.php, so this function is a no-op. 1407 */ 1408 function system_update_6012() { 1409 return array(); 1410 } 1411 1412 /** 1413 * Rebuild cache data for theme system changes 1414 */ 1415 function system_update_6013() { 1416 // Rebuild system table contents. 1417 module_rebuild_cache(); 1418 system_theme_data(); 1419 1420 return array(array('success' => TRUE, 'query' => 'Cache rebuilt.')); 1421 } 1422 1423 /** 1424 * Record that the installer is done, so it is not 1425 * possible to run the installer on upgraded sites. 1426 */ 1427 function system_update_6014() { 1428 variable_set('install_task', 'done'); 1429 1430 return array(array('success' => TRUE, 'query' => "variable_set('install_task')")); 1431 } 1432 1433 /** 1434 * Add the form cache table. 1435 */ 1436 function system_update_6015() { 1437 $ret = array(); 1438 1439 switch ($GLOBALS['db_type']) { 1440 case 'pgsql': 1441 $ret[] = update_sql("CREATE TABLE {cache_form} ( 1442 cid varchar(255) NOT NULL default '', 1443 data bytea, 1444 expire int NOT NULL default '0', 1445 created int NOT NULL default '0', 1446 headers text, 1447 serialized smallint NOT NULL default '0', 1448 PRIMARY KEY (cid) 1449 )"); 1450 $ret[] = update_sql("CREATE INDEX {cache_form}_expire_idx ON {cache_form} (expire)"); 1451 break; 1452 case 'mysql': 1453 case 'mysqli': 1454 $ret[] = update_sql("CREATE TABLE {cache_form} ( 1455 cid varchar(255) NOT NULL default '', 1456 data longblob, 1457 expire int NOT NULL default '0', 1458 created int NOT NULL default '0', 1459 headers text, 1460 serialized int(1) NOT NULL default '0', 1461 PRIMARY KEY (cid), 1462 INDEX expire (expire) 1463 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); 1464 break; 1465 } 1466 1467 return $ret; 1468 } 1469 1470 /** 1471 * Make {node}'s primary key be nid, change nid,vid to a unique key. 1472 * Add primary keys to block, filters, flood, permission, and term_relation. 1473 */ 1474 function system_update_6016() { 1475 $ret = array(); 1476 1477 switch ($GLOBALS['db_type']) { 1478 case 'pgsql': 1479 $ret[] = update_sql("ALTER TABLE {node} ADD CONSTRAINT {node}_nid_vid_key UNIQUE (nid, vid)"); 1480 db_add_column($ret, 'blocks', 'bid', 'serial'); 1481 $ret[] = update_sql("ALTER TABLE {blocks} ADD PRIMARY KEY (bid)"); 1482 db_add_column($ret, 'filters', 'fid', 'serial'); 1483 $ret[] = update_sql("ALTER TABLE {filters} ADD PRIMARY KEY (fid)"); 1484 db_add_column($ret, 'flood', 'fid', 'serial'); 1485 $ret[] = update_sql("ALTER TABLE {flood} ADD PRIMARY KEY (fid)"); 1486 db_add_column($ret, 'permission', 'pid', 'serial'); 1487 $ret[] = update_sql("ALTER TABLE {permission} ADD PRIMARY KEY (pid)"); 1488 db_add_column($ret, 'term_relation', 'trid', 'serial'); 1489 $ret[] = update_sql("ALTER TABLE {term_relation} ADD PRIMARY KEY (trid)"); 1490 db_add_column($ret, 'term_synonym', 'tsid', 'serial'); 1491 $ret[] = update_sql("ALTER TABLE {term_synonym} ADD PRIMARY KEY (tsid)"); 1492 break; 1493 case 'mysql': 1494 case 'mysqli': 1495 $ret[] = update_sql('ALTER TABLE {node} ADD UNIQUE KEY nid_vid (nid, vid)'); 1496 $ret[] = update_sql("ALTER TABLE {blocks} ADD bid int NOT NULL AUTO_INCREMENT PRIMARY KEY"); 1497 $ret[] = update_sql("ALTER TABLE {filters} ADD fid int NOT NULL AUTO_INCREMENT PRIMARY KEY"); 1498 $ret[] = update_sql("ALTER TABLE {flood} ADD fid int NOT NULL AUTO_INCREMENT PRIMARY KEY"); 1499 $ret[] = update_sql("ALTER TABLE {permission} ADD pid int NOT NULL AUTO_INCREMENT PRIMARY KEY"); 1500 $ret[] = update_sql("ALTER TABLE {term_relation} ADD trid int NOT NULL AUTO_INCREMENT PRIMARY KEY"); 1501 $ret[] = update_sql("ALTER TABLE {term_synonym} ADD tsid int NOT NULL AUTO_INCREMENT PRIMARY KEY"); 1502 break; 1503 } 1504 1505 return $ret; 1506 } 1507 1508 /** 1509 * Rename settings related to user.module email notifications. 1510 */ 1511 function system_update_6017() { 1512 $ret = array(); 1513 // Maps old names to new ones. 1514 $var_names = array( 1515 'admin' => 'register_admin_created', 1516 'approval' => 'register_pending_approval', 1517 'welcome' => 'register_no_approval_required', 1518 'pass' => 'password_reset', 1519 ); 1520 foreach ($var_names as $old => $new) { 1521 foreach (array('_subject', '_body') as $suffix) { 1522 $old_name = 'user_mail_'. $old . $suffix; 1523 $new_name = 'user_mail_'. $new . $suffix; 1524 if ($old_val = variable_get($old_name, FALSE)) { 1525 variable_set($new_name, $old_val); 1526 variable_del($old_name); 1527 $ret[] = array('success' => TRUE, 'query' => "variable_set($new_name)"); 1528 $ret[] = array('success' => TRUE, 'query' => "variable_del($old_name)"); 1529 if ($old_name == 'user_mail_approval_body') { 1530 drupal_set_message('Saving an old value of the welcome message body for users that are pending administrator approval. However, you should consider modifying this text, since Drupal can now be configured to automatically notify users and send them their login information when their accounts are approved. See the <a href="'. url('admin/user/settings') .'">User settings</a> page for details.'); 1531 } 1532 } 1533 } 1534 } 1535 return $ret; 1536 } 1537 1538 /** 1539 * Add HTML corrector to HTML formats or replace the old module if it was in use. 1540 */ 1541 function system_update_6018() { 1542 $ret = array(); 1543 1544 // Disable htmlcorrector.module, if it exists and replace its filter. 1545 if (module_exists('htmlcorrector')) { 1546 module_disable(array('htmlcorrector')); 1547 $ret[] = update_sql("UPDATE {filter_formats} SET module = 'filter', delta = 3 WHERE module = 'htmlcorrector'"); 1548 $ret[] = array('success' => TRUE, 'query' => 'HTML Corrector module was disabled; this functionality has now been added to core.'); 1549 return $ret; 1550 } 1551 1552 // Otherwise, find any format with 'HTML' in its name and add the filter at the end. 1553 $result = db_query("SELECT format, name FROM {filter_formats} WHERE name LIKE '%HTML%'"); 1554 while ($format = db_fetch_object($result)) { 1555 $weight = db_result(db_query("SELECT MAX(weight) FROM {filters} WHERE format = %d", $format->format)); 1556 db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format->format, 'filter', 3, max(10, $weight + 1)); 1557 $ret[] = array('success' => TRUE, 'query' => "HTML corrector filter added to the '". $format->name ."' input format."); 1558 } 1559 1560 return $ret; 1561 } 1562 1563 /** 1564 * Reconcile small differences in the previous, manually created mysql 1565 * and pgsql schemas so they are the same and can be represented by a 1566 * single schema structure. 1567 * 1568 * Note that the mysql and pgsql cases make different changes. This 1569 * is because each schema needs to be tweaked in different ways to 1570 * conform to the new schema structure. Also, since they operate on 1571 * tables defined by many optional core modules which may not ever 1572 * have been installed, they must test each table for existence. If 1573 * the modules are first installed after this update exists the tables 1574 * will be created from the schema structure and will start out 1575 * correct. 1576 */ 1577 function system_update_6019() { 1578 $ret = array(); 1579 1580 switch ($GLOBALS['db_type']) { 1581 case 'pgsql': 1582 // Remove default ''. 1583 if (db_table_exists('aggregator_feed')) { 1584 db_field_set_no_default($ret, 'aggregator_feed', 'description'); 1585 db_field_set_no_default($ret, 'aggregator_feed', 'image'); 1586 } 1587 db_field_set_no_default($ret, 'blocks', 'pages'); 1588 if (db_table_exists('contact')) { 1589 db_field_set_no_default($ret, 'contact', 'recipients'); 1590 db_field_set_no_default($ret, 'contact', 'reply'); 1591 } 1592 db_field_set_no_default($ret, 'watchdog', 'location'); 1593 db_field_set_no_default($ret, 'node_revisions', 'body'); 1594 db_field_set_no_default($ret, 'node_revisions', 'teaser'); 1595 db_field_set_no_default($ret, 'node_revisions', 'log'); 1596 1597 // Update from pgsql 'float' (which means 'double precision') to 1598 // schema 'float' (which in pgsql means 'real'). 1599 if (db_table_exists('search_index')) { 1600 db_change_field($ret, 'search_index', 'score', 'score', array('type' => 'float')); 1601 } 1602 if (db_table_exists('search_total')) { 1603 db_change_field($ret, 'search_total', 'count', 'count', array('type' => 'float')); 1604 } 1605 1606 // Replace unique index dst_language with a unique constraint. The 1607 // result is the same but the unique key fits our current schema 1608 // structure. Also, the postgres documentation implies that 1609 // unique constraints are preferable to unique indexes. See 1610 // http://www.postgresql.org/docs/8.2/interactive/indexes-unique.html. 1611 if (db_table_exists('url_alias')) { 1612 db_drop_index($ret, 'url_alias', 'dst_language'); 1613 db_add_unique_key($ret, 'url_alias', 'dst_language', 1614 array('dst', 'language')); 1615 } 1616 1617 // Fix term_node pkey: mysql and pgsql code had different orders. 1618 if (db_table_exists('term_node')) { 1619 db_drop_primary_key($ret, 'term_node'); 1620 db_add_primary_key($ret, 'term_node', array('vid', 'tid', 'nid')); 1621 } 1622 1623 // Make boxes.bid unsigned. 1624 db_drop_primary_key($ret, 'boxes'); 1625 db_change_field($ret, 'boxes', 'bid', 'bid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('bid'))); 1626 1627 // Fix primary key 1628 db_drop_primary_key($ret, 'node'); 1629 db_add_primary_key($ret, 'node', array('nid')); 1630 1631 break; 1632 1633 case 'mysql': 1634 case 'mysqli': 1635 // Rename key 'link' to 'url'. 1636 if (db_table_exists('aggregator_feed')) { 1637 db_drop_unique_key($ret, 'aggregator_feed', 'link'); 1638 db_add_unique_key($ret, 'aggregator_feed', 'url', array('url')); 1639 } 1640 1641 // Change to size => small. 1642 if (db_table_exists('boxes')) { 1643 db_change_field($ret, 'boxes', 'format', 'format', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)); 1644 } 1645 1646 // Change to size => small. 1647 // Rename index 'lid' to 'nid'. 1648 if (db_table_exists('comments')) { 1649 db_change_field($ret, 'comments', 'format', 'format', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)); 1650 db_drop_index($ret, 'comments', 'lid'); 1651 db_add_index($ret, 'comments', 'nid', array('nid')); 1652 } 1653 1654 // Change to size => small. 1655 db_change_field($ret, 'cache', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)); 1656 db_change_field($ret, 'cache_filter', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)); 1657 db_change_field($ret, 'cache_page', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)); 1658 db_change_field($ret, 'cache_form', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)); 1659 1660 // Remove default => 0, set auto increment. 1661 $new_uid = 1 + db_result(db_query('SELECT MAX(uid) FROM {users}')); 1662 $ret[] = update_sql('UPDATE {users} SET uid = '. $new_uid .' WHERE uid = 0'); 1663 db_drop_primary_key($ret, 'users'); 1664 db_change_field($ret, 'users', 'uid', 'uid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('uid'))); 1665 $ret[] = update_sql('UPDATE {users} SET uid = 0 WHERE uid = '. $new_uid); 1666 1667 // Special field names. 1668 $map = array('node_revisions' => 'vid'); 1669 // Make sure these tables have proper auto_increment fields. 1670 foreach (array('boxes', 'files', 'node', 'node_revisions') as $table) { 1671 $field = isset($map[$table]) ? $map[$table] : $table[0] .'id'; 1672 db_drop_primary_key($ret, $table); 1673 db_change_field($ret, $table, $field, $field, array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array($field))); 1674 } 1675 1676 break; 1677 } 1678 1679 return $ret; 1680 } 1681 1682 /** 1683 * Create the tables for the new menu system. 1684 */ 1685 function system_update_6020() { 1686 $ret = array(); 1687 1688 $schema['menu_router'] = array( 1689 'fields' => array( 1690 'path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1691 'load_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1692 'to_arg_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1693 'access_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1694 'access_arguments' => array('type' => 'text', 'not null' => FALSE), 1695 'page_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1696 'page_arguments' => array('type' => 'text', 'not null' => FALSE), 1697 'fit' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 1698 'number_parts' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1699 'tab_parent' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1700 'tab_root' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1701 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1702 'title_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1703 'title_arguments' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1704 'type' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 1705 'block_callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1706 'description' => array('type' => 'text', 'not null' => TRUE), 1707 'position' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1708 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 1709 'file' => array('type' => 'text', 'size' => 'medium') 1710 ), 1711 'indexes' => array( 1712 'fit' => array('fit'), 1713 'tab_parent' => array('tab_parent') 1714 ), 1715 'primary key' => array('path'), 1716 ); 1717 1718 $schema['menu_links'] = array( 1719 'fields' => array( 1720 'menu_name' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 1721 'mlid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 1722 'plid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1723 'link_path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1724 'router_path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1725 'link_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1726 'options' => array('type' => 'text', 'not null' => FALSE), 1727 'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'), 1728 'hidden' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1729 'external' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1730 'has_children' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1731 'expanded' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1732 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 1733 'depth' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1734 'customized' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1735 'p1' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1736 'p2' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1737 'p3' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1738 'p4' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1739 'p5' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1740 'p6' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1741 'p7' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1742 'p8' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1743 'p9' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 1744 'updated' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'), 1745 ), 1746 'indexes' => array( 1747 'path_menu' => array(array('link_path', 128), 'menu_name'), 1748 'menu_plid_expand_child' => array('menu_name', 'plid', 'expanded', 'has_children'), 1749 'menu_parents' => array('menu_name', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'), 1750 'router_path' => array(array('router_path', 128)), 1751 ), 1752 'primary key' => array('mlid'), 1753 ); 1754 1755 foreach ($schema as $name => $table) { 1756 db_create_table($ret, $name, $table); 1757 } 1758 return $ret; 1759 } 1760 1761 /** 1762 * Migrate the menu items from the old menu system to the new menu_links table. 1763 */ 1764 function system_update_6021() { 1765 $ret = array('#finished' => 0); 1766 $menus = array( 1767 'navigation' => array( 1768 'menu_name' => 'navigation', 1769 'title' => 'Navigation', 1770 'description' => 'The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.', 1771 ), 1772 'primary-links' => array( 1773 'menu_name' => 'primary-links', 1774 'title' => 'Primary links', 1775 'description' => 'Primary links are often used at the theme layer to show the major sections of a site. A typical representation for primary links would be tabs along the top.', 1776 ), 1777 'secondary-links' => array( 1778 'menu_name' => 'secondary-links', 1779 'title' => 'Secondary links', 1780 'description' => 'Secondary links are often used for pages like legal notices, contact details, and other secondary navigation items that play a lesser role than primary links.', 1781 ), 1782 ); 1783 // Multi-part update 1784 if (!isset($_SESSION['system_update_6021'])) { 1785 db_add_field($ret, 'menu', 'converted', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')); 1786 $_SESSION['system_update_6021_max'] = db_result(db_query('SELECT COUNT(*) FROM {menu}')); 1787 $_SESSION['menu_menu_map'] = array(1 => 'navigation'); 1788 // 0 => FALSE is for new menus, 1 => FALSE is for the navigation. 1789 $_SESSION['menu_item_map'] = array(0 => FALSE, 1 => FALSE); 1790 $table = array( 1791 'fields' => array( 1792 'menu_name' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 1793 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 1794 'description' => array('type' => 'text', 'not null' => FALSE), 1795 ), 1796 'primary key' => array('menu_name'), 1797 ); 1798 db_create_table($ret, 'menu_custom', $table); 1799 db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menus['navigation']); 1800 $_SESSION['system_update_6021'] = 0; 1801 } 1802 1803 $limit = 50; 1804 while ($limit-- && ($item = db_fetch_array(db_query_range('SELECT * FROM {menu} WHERE converted = 0', 0, 1)))) { 1805 // If it's not a menu... 1806 if ($item['pid']) { 1807 // Let's climb up until we find an item with a converted parent. 1808 $item_original = $item; 1809 while ($item && !isset($_SESSION['menu_item_map'][$item['pid']])) { 1810 $item = db_fetch_array(db_query('SELECT * FROM {menu} WHERE mid = %d', $item['pid'])); 1811 } 1812 // This can only occur if the menu entry is a leftover in the menu table. 1813 // These do not appear in Drupal 5 anyways, so we skip them. 1814 if (!$item) { 1815 db_query('UPDATE {menu} SET converted = %d WHERE mid = %d', 1, $item_original['mid']); 1816 $_SESSION['system_update_6021']++; 1817 continue; 1818 } 1819 } 1820 // We need to recheck because item might have changed. 1821 if ($item['pid']) { 1822 // Fill the new fields. 1823 $item['link_title'] = $item['title']; 1824 $item['link_path'] = drupal_get_normal_path($item['path']); 1825 // We know the parent is already set. If it's not FALSE then it's an item. 1826 if ($_SESSION['menu_item_map'][$item['pid']]) { 1827 // The new menu system parent link id. 1828 $item['plid'] = $_SESSION['menu_item_map'][$item['pid']]['mlid']; 1829 // The new menu system menu name. 1830 $item['menu_name'] = $_SESSION['menu_item_map'][$item['pid']]['menu_name']; 1831 } 1832 else { 1833 // This a top level element. 1834 $item['plid'] = 0; 1835 // The menu name is stored among the menus. 1836 $item['menu_name'] = $_SESSION['menu_menu_map'][$item['pid']]; 1837 } 1838 // Is the element visible in the menu block? 1839 $item['hidden'] = !($item['type'] & MENU_VISIBLE_IN_TREE); 1840 // Is it a custom(ized) element? 1841 if ($item['type'] & (MENU_CREATED_BY_ADMIN | MENU_MODIFIED_BY_ADMIN)) { 1842 $item['customized'] = TRUE; 1843 } 1844 // Items created via the menu module need to be assigned to it. 1845 if ($item['type'] & MENU_CREATED_BY_ADMIN) { 1846 $item['module'] = 'menu'; 1847 $item['router_path'] = ''; 1848 $item['updated'] = TRUE; 1849 } 1850 else { 1851 $item['module'] = 'system'; 1852 $item['router_path'] = $item['path']; 1853 $item['updated'] = FALSE; 1854 } 1855 if ($item['description']) { 1856 $item['options']['attributes']['title'] = $item['description']; 1857 } 1858 1859 // Save the link. 1860 menu_link_save($item); 1861 $_SESSION['menu_item_map'][$item['mid']] = array('mlid' => $item['mlid'], 'menu_name' => $item['menu_name']); 1862 } 1863 elseif (!isset($_SESSION['menu_menu_map'][$item['mid']])) { 1864 $item['menu_name'] = 'menu-'. preg_replace('/[^a-zA-Z0-9]/', '-', strtolower($item['title'])); 1865 $item['menu_name'] = substr($item['menu_name'], 0, 20); 1866 $original_menu_name = $item['menu_name']; 1867 $i = 0; 1868 while (db_result(db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = '%s'", $item['menu_name']))) { 1869 $item['menu_name'] = $original_menu_name . ($i++); 1870 } 1871 if ($item['path']) { 1872 // Another bunch of bogus entries. Apparently, these are leftovers 1873 // from Drupal 4.7 . 1874 $_SESSION['menu_bogus_menus'][] = $item['menu_name']; 1875 } 1876 else { 1877 // Add this menu to the list of custom menus. 1878 db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '')", $item['menu_name'], $item['title']); 1879 } 1880 $_SESSION['menu_menu_map'][$item['mid']] = $item['menu_name']; 1881 $_SESSION['menu_item_map'][$item['mid']] = FALSE; 1882 } 1883 db_query('UPDATE {menu} SET converted = %d WHERE mid = %d', 1, $item['mid']); 1884 $_SESSION['system_update_6021']++; 1885 } 1886 1887 if ($_SESSION['system_update_6021'] >= $_SESSION['system_update_6021_max']) { 1888 if (!empty($_SESSION['menu_bogus_menus'])) { 1889 // Remove entries in bogus menus. This is secure because we deleted 1890 // every non-alpanumeric character from the menu name. 1891 $ret[] = update_sql("DELETE FROM {menu_links} WHERE menu_name IN ('". implode("', '", $_SESSION['menu_bogus_menus']) ."')"); 1892 } 1893 1894 $menu_primary_menu = variable_get('menu_primary_menu', 0); 1895 // Ensure that we wind up with a system menu named 'primary-links'. 1896 if (isset($_SESSION['menu_menu_map'][2])) { 1897 // The primary links menu that ships with Drupal 5 has mid = 2. If this 1898 // menu hasn't been deleted by the site admin, we use that. 1899 $updated_primary_links_menu = 2; 1900 } 1901 elseif (isset($_SESSION['menu_menu_map'][$menu_primary_menu]) && $menu_primary_menu > 1) { 1902 // Otherwise, we use the menu that is currently assigned to the primary 1903 // links region of the theme, as long as it exists and isn't the 1904 // Navigation menu. 1905 $updated_primary_links_menu = $menu_primary_menu; 1906 } 1907 else { 1908 // As a last resort, create 'primary-links' as a new menu. 1909 $updated_primary_links_menu = 0; 1910 db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menus['primary-links']); 1911 } 1912 1913 if ($updated_primary_links_menu) { 1914 // Change the existing menu name to 'primary-links'. 1915 $replace = array('%new_name' => 'primary-links', '%desc' => $menus['primary-links']['description'], '%old_name' => $_SESSION['menu_menu_map'][$updated_primary_links_menu]); 1916 $ret[] = update_sql(strtr("UPDATE {menu_custom} SET menu_name = '%new_name', description = '%desc' WHERE menu_name = '%old_name'", $replace)); 1917 $ret[] = update_sql("UPDATE {menu_links} SET menu_name = 'primary-links' WHERE menu_name = '". $_SESSION['menu_menu_map'][$updated_primary_links_menu] ."'"); 1918 $_SESSION['menu_menu_map'][$updated_primary_links_menu] = 'primary-links'; 1919 } 1920 1921 $menu_secondary_menu = variable_get('menu_secondary_menu', 0); 1922 // Ensure that we wind up with a system menu named 'secondary-links'. 1923 if (isset($_SESSION['menu_menu_map'][$menu_secondary_menu]) && $menu_secondary_menu > 1 && $menu_secondary_menu != $updated_primary_links_menu) { 1924 // We use the menu that is currently assigned to the secondary links 1925 // region of the theme, as long as (a) it exists, (b) it isn't the 1926 // Navigation menu, (c) it isn't the same menu we assigned as the 1927 // system 'primary-links' menu above, and (d) it isn't the same menu 1928 // assigned to the primary links region of the theme. 1929 $updated_secondary_links_menu = $menu_secondary_menu; 1930 } 1931 else { 1932 // Otherwise, create 'secondary-links' as a new menu. 1933 $updated_secondary_links_menu = 0; 1934 db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menus['secondary-links']); 1935 } 1936 1937 if ($updated_secondary_links_menu) { 1938 // Change the existing menu name to 'secondary-links'. 1939 $replace = array('%new_name' => 'secondary-links', '%desc' => $menus['secondary-links']['description'], '%old_name' => $_SESSION['menu_menu_map'][$updated_secondary_links_menu]); 1940 $ret[] = update_sql(strtr("UPDATE {menu_custom} SET menu_name = '%new_name', description = '%desc' WHERE menu_name = '%old_name'", $replace)); 1941 $ret[] = update_sql("UPDATE {menu_links} SET menu_name = 'secondary-links' WHERE menu_name = '". $_SESSION['menu_menu_map'][$updated_secondary_links_menu] ."'"); 1942 $_SESSION['menu_menu_map'][$updated_secondary_links_menu] = 'secondary-links'; 1943 } 1944 1945 // Update menu OTF preferences. 1946 $mid = variable_get('menu_parent_items', 0); 1947 $menu_name = ($mid && isset($_SESSION['menu_menu_map'][$mid])) ? $_SESSION['menu_menu_map'][$mid] : 'navigation'; 1948 variable_set('menu_default_node_menu', $menu_name); 1949 variable_del('menu_parent_items'); 1950 1951 // Update the source of the primary and secondary links. 1952 $menu_name = ($menu_primary_menu && isset($_SESSION['menu_menu_map'][$menu_primary_menu])) ? $_SESSION['menu_menu_map'][$menu_primary_menu] : ''; 1953 variable_set('menu_primary_links_source', $menu_name); 1954 variable_del('menu_primary_menu'); 1955 1956 $menu_name = ($menu_secondary_menu && isset($_SESSION['menu_menu_map'][$menu_secondary_menu])) ? $_SESSION['menu_menu_map'][$menu_secondary_menu] : ''; 1957 variable_set('menu_secondary_links_source', $menu_name); 1958 variable_del('menu_secondary_menu'); 1959 1960 // Skip the navigation menu - it is handled by the user module. 1961 unset($_SESSION['menu_menu_map'][1]); 1962 // Update the deltas for all menu module blocks. 1963 foreach ($_SESSION['menu_menu_map'] as $mid => $menu_name) { 1964 // This is again secure because we deleted every non-alpanumeric 1965 // character from the menu name. 1966 $ret[] = update_sql("UPDATE {blocks} SET delta = '". $menu_name ."' WHERE module = 'menu' AND delta = '". $mid ."'"); 1967 $ret[] = update_sql("UPDATE {blocks_roles} SET delta = '". $menu_name ."' WHERE module = 'menu' AND delta = '". $mid ."'"); 1968 } 1969 $ret[] = array('success' => TRUE, 'query' => 'Relocated '. $_SESSION['system_update_6021'] .' existing items to the new menu system.'); 1970 $ret[] = update_sql("DROP TABLE {menu}"); 1971 unset($_SESSION['system_update_6021'], $_SESSION['system_update_6021_max'], $_SESSION['menu_menu_map'], $_SESSION['menu_item_map'], $_SESSION['menu_bogus_menus']); 1972 // Create the menu overview links - also calls menu_rebuild(). If menu is 1973 // disabled, then just call menu_rebuild. 1974 if (function_exists('menu_enable')) { 1975 menu_enable(); 1976 } 1977 else { 1978 menu_rebuild(); 1979 } 1980 $ret['#finished'] = 1; 1981 } 1982 else { 1983 $ret['#finished'] = $_SESSION['system_update_6021'] / $_SESSION['system_update_6021_max']; 1984 } 1985 return $ret; 1986 } 1987 1988 /** 1989 * Update files tables to associate files to a uid by default instead of a nid. 1990 * Rename file_revisions to upload since it should only be used by the upload 1991 * module used by upload to link files to nodes. 1992 */ 1993 function system_update_6022() { 1994 $ret = array(); 1995 1996 // Rename the nid field to vid, add status and timestamp fields, and indexes. 1997 db_drop_index($ret, 'files', 'nid'); 1998 db_change_field($ret, 'files', 'nid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 1999 db_add_field($ret, 'files', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); 2000 db_add_field($ret, 'files', 'timestamp', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 2001 db_add_index($ret, 'files', 'uid', array('uid')); 2002 db_add_index($ret, 'files', 'status', array('status')); 2003 db_add_index($ret, 'files', 'timestamp', array('timestamp')); 2004 2005 // Rename the file_revisions table to upload then add nid column. Since we're 2006 // changing the table name we need to drop and re-add the indexes and 2007 // the primary key so both mysql and pgsql end up with the correct index 2008 // names. 2009 db_drop_primary_key($ret, 'file_revisions'); 2010 db_drop_index($ret, 'file_revisions', 'vid'); 2011 db_rename_table($ret, 'file_revisions', 'upload'); 2012 db_add_field($ret, 'upload', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 2013 db_add_index($ret, 'upload', 'nid', array('nid')); 2014 db_add_primary_key($ret, 'upload', array('vid', 'fid')); 2015 db_add_index($ret, 'upload', 'fid', array('fid')); 2016 2017 // The nid column was renamed to uid. Use the old nid to find the node's uid. 2018 update_sql('UPDATE {files} SET uid = (SELECT n.uid FROM {node} n WHERE {files}.uid = n.nid)'); 2019 update_sql('UPDATE {upload} SET nid = (SELECT r.nid FROM {node_revisions} r WHERE {upload}.vid = r.vid)'); 2020 2021 // Mark all existing files as FILE_STATUS_PERMANENT. 2022 $ret[] = update_sql('UPDATE {files} SET status = 1'); 2023 2024 return $ret; 2025 } 2026 2027 function system_update_6023() { 2028 $ret = array(); 2029 2030 // nid is DEFAULT 0 2031 db_drop_index($ret, 'node_revisions', 'nid'); 2032 db_change_field($ret, 'node_revisions', 'nid', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 2033 db_add_index($ret, 'node_revisions', 'nid', array('nid')); 2034 return $ret; 2035 } 2036 2037 /** 2038 * Add translation fields to nodes used by translation module. 2039 */ 2040 function system_update_6024() { 2041 $ret = array(); 2042 db_add_field($ret, 'node', 'tnid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 2043 db_add_field($ret, 'node', 'translate', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); 2044 db_add_index($ret, 'node', 'tnid', array('tnid')); 2045 db_add_index($ret, 'node', 'translate', array('translate')); 2046 return $ret; 2047 } 2048 2049 /** 2050 * Increase the maximum length of node titles from 128 to 255. 2051 */ 2052 function system_update_6025() { 2053 $ret = array(); 2054 db_drop_index($ret, 'node', 'node_title_type'); 2055 db_change_field($ret, 'node', 'title', 'title', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); 2056 db_add_index($ret, 'node', 'node_title_type', array('title', array('type', 4))); 2057 db_change_field($ret, 'node_revisions', 'title', 'title', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); 2058 return $ret; 2059 } 2060 2061 /** 2062 * Display warning about new Update status module. 2063 */ 2064 function system_update_6026() { 2065 $ret = array(); 2066 2067 // Notify user that new update module exists. 2068 drupal_set_message('Drupal can check periodically for important bug fixes and security releases using the new update status module. This module can be turned on from the <a href="'. url('admin/build/modules') .'">modules administration page</a>. For more information please read the <a href="http://drupal.org/handbook/modules/update">Update status handbook page</a>.'); 2069 2070 return $ret; 2071 } 2072 2073 /** 2074 * Add block cache. 2075 */ 2076 function system_update_6027() { 2077 $ret = array(); 2078 2079 // Create the blocks.cache column. 2080 db_add_field($ret, 'blocks', 'cache', array('type' => 'int', 'not null' => TRUE, 'default' => 1, 'size' => 'tiny')); 2081 2082 // The cache_block table is created in update_fix_d6_requirements() since 2083 // calls to cache_clear_all() would otherwise cause warnings. 2084 2085 // Fill in the values for the new 'cache' column in the {blocks} table. 2086 foreach (module_list() as $module) { 2087 if ($module_blocks = module_invoke($module, 'block', 'list')) { 2088 foreach ($module_blocks as $delta => $block) { 2089 if (isset($block['cache'])) { 2090 db_query("UPDATE {blocks} SET cache = %d WHERE module = '%s' AND delta = '%s'", $block['cache'], $module, $delta); 2091 } 2092 } 2093 } 2094 } 2095 2096 return $ret; 2097 } 2098 2099 /** 2100 * Add the node load cache table. 2101 */ 2102 function system_update_6028() { 2103 // Removed node_load cache to discuss it more for Drupal 7. 2104 return array(); 2105 } 2106 2107 /** 2108 * Enable the dblog module on sites that upgrade, since otherwise 2109 * watchdog logging will stop unexpectedly. 2110 */ 2111 function system_update_6029() { 2112 // The watchdog table is now owned by dblog, which is not yet 2113 // "installed" according to the system table, but the table already 2114 // exists. We set the module as "installed" here to avoid an error 2115 // later. 2116 // 2117 // Although not the case for the initial D6 release, it is likely 2118 // that dblog.install will have its own update functions eventually. 2119 // However, dblog did not exist in D5 and this update is part of the 2120 // initial D6 release, so we know that dblog is not installed yet. 2121 // It is therefore correct to install it as version 0. If 2122 // dblog updates exist, the next run of update.php will get them. 2123 drupal_set_installed_schema_version('dblog', 0); 2124 module_enable(array('dblog')); 2125 menu_rebuild(); 2126 return array(array('success' => TRUE, 'query' => "'dblog' module enabled.")); 2127 } 2128 2129 /** 2130 * Add the tables required by actions.inc. 2131 */ 2132 function system_update_6030() { 2133 $ret = array(); 2134 2135 // Rename the old contrib actions table if it exists so the contrib version 2136 // of the module can do something with the old data. 2137 if (db_table_exists('actions')) { 2138 db_rename_table($ret, 'actions', 'actions_old_contrib'); 2139 } 2140 2141 $schema['actions'] = array( 2142 'fields' => array( 2143 'aid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'), 2144 'type' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''), 2145 'callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 2146 'parameters' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), 2147 'description' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'), 2148 ), 2149 'primary key' => array('aid'), 2150 ); 2151 2152 $schema['actions_aid'] = array( 2153 'fields' => array( 2154 'aid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 2155 ), 2156 'primary key' => array('aid'), 2157 ); 2158 2159 db_create_table($ret, 'actions', $schema['actions']); 2160 db_create_table($ret, 'actions_aid', $schema['actions_aid']); 2161 2162 return $ret; 2163 } 2164 2165 /** 2166 * Ensure that installer cannot be run again after updating from Drupal 5.x to 6.x 2167 * Actually, this is already done by system_update_6014(), so this is now a no-op. 2168 */ 2169 function system_update_6031() { 2170 return array(); 2171 } 2172 2173 /** 2174 * profile_fields.name used to be nullable but is part of a unique key 2175 * and so shouldn't be. 2176 */ 2177 function system_update_6032() { 2178 $ret = array(); 2179 if (db_table_exists('profile_fields')) { 2180 db_drop_unique_key($ret, 'profile_fields', 'name'); 2181 db_change_field($ret, 'profile_fields', 'name', 'name', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')); 2182 db_add_unique_key($ret, 'profile_fields', 'name', array('name')); 2183 } 2184 return $ret; 2185 } 2186 2187 /** 2188 * Change node_comment_statistics to be not autoincrement. 2189 */ 2190 function system_update_6033() { 2191 $ret = array(); 2192 if (db_table_exists('node_comment_statistics')) { 2193 // On pgsql but not mysql, db_change_field() drops all keys 2194 // involving the changed field, which in this case is the primary 2195 // key. The normal approach is explicitly drop the pkey, change the 2196 // field, and re-create the pkey. 2197 // 2198 // Unfortunately, in this case that won't work on mysql; we CANNOT 2199 // drop the pkey because on mysql auto-increment fields must be 2200 // included in at least one key or index. 2201 // 2202 // Since we cannot drop the pkey before db_change_field(), after 2203 // db_change_field() we may or may not still have a pkey. The 2204 // simple way out is to re-create the pkey only when using pgsql. 2205 // Realistic requirements trump idealistic purity. 2206 db_change_field($ret, 'node_comment_statistics', 'nid', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 2207 if ($GLOBALS['db_type'] == 'pgsql') { 2208 db_add_primary_key($ret, 'node_comment_statistics', array('nid')); 2209 } 2210 } 2211 return $ret; 2212 } 2213 2214 /** 2215 * Rename permission "administer access control" to "administer permissions". 2216 */ 2217 function system_update_6034() { 2218 $ret = array(); 2219 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid"); 2220 while ($role = db_fetch_object($result)) { 2221 $renamed_permission = preg_replace('/administer access control/', 'administer permissions', $role->perm); 2222 if ($renamed_permission != $role->perm) { 2223 $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid"); 2224 } 2225 } 2226 return $ret; 2227 } 2228 2229 /** 2230 * Change index on system table for better performance. 2231 */ 2232 function system_update_6035() { 2233 $ret = array(); 2234 db_drop_index($ret, 'system', 'weight'); 2235 db_add_index($ret, 'system', 'modules', array(array('type', 12), 'status', 'weight', 'filename')); 2236 db_add_index($ret, 'system', 'bootstrap', array(array('type', 12), 'status', 'bootstrap', 'weight', 'filename')); 2237 return $ret; 2238 } 2239 2240 /** 2241 * Change the search schema and indexing. 2242 * 2243 * The table data is preserved where possible in MYSQL and MYSQLi using 2244 * ALTER IGNORE. Other databases don't support that, so for them the 2245 * tables are dropped and re-created, and will need to be re-indexed 2246 * from scratch. 2247 */ 2248 function system_update_6036() { 2249 $ret = array(); 2250 if (db_table_exists('search_index')) { 2251 // Create the search_dataset.reindex column. 2252 db_add_field($ret, 'search_dataset', 'reindex', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); 2253 2254 // Drop the search_index.from fields which are no longer used. 2255 db_drop_index($ret, 'search_index', 'from_sid_type'); 2256 db_drop_field($ret, 'search_index', 'fromsid'); 2257 db_drop_field($ret, 'search_index', 'fromtype'); 2258 2259 // Drop the search_dataset.sid_type index, so that it can be made unique. 2260 db_drop_index($ret, 'search_dataset', 'sid_type'); 2261 2262 // Create the search_node_links Table. 2263 $search_node_links_schema = array( 2264 'fields' => array( 2265 'sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 2266 'type' => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''), 2267 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 2268 'caption' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE), 2269 ), 2270 'primary key' => array('sid', 'type', 'nid'), 2271 'indexes' => array('nid' => array('nid')), 2272 ); 2273 db_create_table($ret, 'search_node_links', $search_node_links_schema); 2274 2275 // with the change to search_dataset.reindex, the search queue is handled differently, 2276 // and this is no longer needed 2277 variable_del('node_cron_last'); 2278 2279 // Add a unique index for the search_index. 2280 if ($GLOBALS['db_type'] == 'mysql' || $GLOBALS['db_type'] == 'mysqli') { 2281 // Since it's possible that some existing sites have duplicates, 2282 // create the index using the IGNORE keyword, which ignores duplicate errors. 2283 // However, pgsql doesn't support it 2284 $ret[] = update_sql("ALTER IGNORE TABLE {search_index} ADD UNIQUE KEY word_sid_type (word, sid, type)"); 2285 $ret[] = update_sql("ALTER IGNORE TABLE {search_dataset} ADD UNIQUE KEY sid_type (sid, type)"); 2286 2287 // Everything needs to be reindexed. 2288 $ret[] = update_sql("UPDATE {search_dataset} SET reindex = 1"); 2289 } 2290 else { 2291 // Delete the existing tables if there are duplicate values 2292 if (db_result(db_query("SELECT sid FROM {search_dataset} GROUP BY sid, type HAVING COUNT(*) > 1")) || db_result(db_query("SELECT sid FROM {search_index} GROUP BY word, sid, type HAVING COUNT(*) > 1"))) { 2293 $ret[] = update_sql('DELETE FROM {search_dataset}'); 2294 $ret[] = update_sql('DELETE FROM {search_index}'); 2295 $ret[] = update_sql('DELETE FROM {search_total}'); 2296 } 2297 else { 2298 // Everything needs to be reindexed. 2299 $ret[] = update_sql("UPDATE {search_dataset} SET reindex = 1"); 2300 } 2301 2302 // create the new indexes 2303 db_add_unique_key($ret, 'search_index', 'word_sid_type', array('word', 'sid', 'type')); 2304 db_add_unique_key($ret, 'search_dataset', 'sid_type', array('sid', 'type')); 2305 } 2306 } 2307 return $ret; 2308 } 2309 2310 /** 2311 * Create consistent empty region for disabled blocks. 2312 */ 2313 function system_update_6037() { 2314 $ret = array(); 2315 db_change_field($ret, 'blocks', 'region', 'region', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '')); 2316 $ret[] = update_sql("UPDATE {blocks} SET region = '' WHERE status = 0"); 2317 return $ret; 2318 } 2319 2320 /** 2321 * Ensure that "Account" is not used as a Profile category. 2322 */ 2323 function system_update_6038() { 2324 $ret = array(); 2325 if (db_table_exists('profile_fields')) { 2326 $ret[] = update_sql("UPDATE {profile_fields} SET category = 'Account settings' WHERE LOWER(category) = 'account'"); 2327 if ($affectedrows = db_affected_rows()) { 2328 drupal_set_message('There were '. $affectedrows .' profile fields that used a reserved category name. They have been assigned to the category "Account settings".'); 2329 } 2330 } 2331 return $ret; 2332 } 2333 2334 /** 2335 * Rename permissions "edit foo content" to "edit any foo content". 2336 * Also update poll module permission "create polls" to "create 2337 * poll content". 2338 */ 2339 function system_update_6039() { 2340 $ret = array(); 2341 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid"); 2342 while ($role = db_fetch_object($result)) { 2343 $renamed_permission = preg_replace('/(?<=^|,\ )edit\ ([a-zA-Z0-9_\-]+)\ content(?=,|$)/', 'edit any $1 content', $role->perm); 2344 $renamed_permission = preg_replace('/(?<=^|,\ )create\ polls(?=,|$)/', 'create poll content', $renamed_permission); 2345 if ($renamed_permission != $role->perm) { 2346 $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid"); 2347 } 2348 } 2349 return $ret; 2350 } 2351 2352 /** 2353 * Add a weight column to the upload table. 2354 */ 2355 function system_update_6040() { 2356 $ret = array(); 2357 if (db_table_exists('upload')) { 2358 db_add_field($ret, 'upload', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')); 2359 } 2360 return $ret; 2361 } 2362 2363 /** 2364 * Change forum vocabulary not to be required by default and set the weight of the forum.module 1 higher than the taxonomy.module. 2365 */ 2366 function system_update_6041() { 2367 $weight = intval((db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'"))) + 1); 2368 $ret = array(); 2369 $vid = intval(variable_get('forum_nav_vocabulary', '')); 2370 if (db_table_exists('vocabulary') && $vid) { 2371 $ret[] = update_sql("UPDATE {vocabulary} SET required = 0 WHERE vid = " . $vid); 2372 $ret[] = update_sql("UPDATE {system} SET weight = ". $weight ." WHERE name = 'forum'"); 2373 } 2374 return $ret; 2375 } 2376 2377 /** 2378 * Upgrade recolored theme stylesheets to new array structure. 2379 */ 2380 function system_update_6042() { 2381 foreach (list_themes() as $theme) { 2382 $stylesheet = variable_get('color_'. $theme->name .'_stylesheet', NULL); 2383 if (!empty($stylesheet)) { 2384 variable_set('color_'. $theme->name .'_stylesheets', array($stylesheet)); 2385 variable_del('color_'. $theme->name .'_stylesheet'); 2386 } 2387 } 2388 return array(); 2389 } 2390 2391 /** 2392 * Update table indices to make them more rational and useful. 2393 */ 2394 function system_update_6043() { 2395 $ret = array(); 2396 // Required modules first. 2397 // Add new system module indexes. 2398 db_add_index($ret, 'flood', 'allow', array('event', 'hostname', 'timestamp')); 2399 db_add_index($ret, 'history', 'nid', array('nid')); 2400 // Change length of theme field in {blocks} to be consistent with module, and 2401 // to avoid a MySQL error regarding a too-long index. Also add new indices. 2402 db_change_field($ret, 'blocks', 'theme', 'theme', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),array( 2403 'unique keys' => array('tmd' => array('theme', 'module', 'delta'),), 2404 'indexes' => array('list' => array('theme', 'status', 'region', 'weight', 'module'),),)); 2405 db_add_index($ret, 'blocks_roles', 'rid', array('rid')); 2406 // Improve filter module indices. 2407 db_drop_index($ret, 'filters', 'weight'); 2408 db_add_unique_key($ret, 'filters', 'fmd', array('format', 'module', 'delta')); 2409 db_add_index($ret, 'filters', 'list', array('format', 'weight', 'module', 'delta')); 2410 // Drop unneeded keys form the node table. 2411 db_drop_index($ret, 'node', 'status'); 2412 db_drop_unique_key($ret, 'node', 'nid_vid'); 2413 // Improve user module indices. 2414 db_add_index($ret, 'users', 'mail', array('mail')); 2415 db_add_index($ret, 'users_roles', 'rid', array('rid')); 2416 2417 // Optional modules - need to check if the tables exist. 2418 // Alter aggregator module's tables primary keys to make them more useful. 2419 if (db_table_exists('aggregator_category_feed')) { 2420 db_drop_primary_key($ret, 'aggregator_category_feed'); 2421 db_add_primary_key($ret, 'aggregator_category_feed', array('cid', 'fid')); 2422 db_add_index($ret, 'aggregator_category_feed', 'fid', array('fid')); 2423 } 2424 if (db_table_exists('aggregator_category_item')) { 2425 db_drop_primary_key($ret, 'aggregator_category_item'); 2426 db_add_primary_key($ret, 'aggregator_category_item', array('cid', 'iid')); 2427 db_add_index($ret, 'aggregator_category_item', 'iid', array('iid')); 2428 } 2429 // Alter contact module's table to add an index. 2430 if (db_table_exists('contact')) { 2431 db_add_index($ret, 'contact', 'list', array('weight', 'category')); 2432 } 2433 // Alter locale table to add a primary key, drop an index. 2434 if (db_table_exists('locales_target')) { 2435 db_add_primary_key($ret, 'locales_target', array('language', 'lid', 'plural')); 2436 } 2437 // Alter a poll module table to add a primary key. 2438 if (db_table_exists('poll_votes')) { 2439 db_drop_index($ret, 'poll_votes', 'nid'); 2440 db_add_primary_key($ret, 'poll_votes', array('nid', 'uid', 'hostname')); 2441 } 2442 // Alter a profile module table to add a primary key. 2443 if (db_table_exists('profile_values')) { 2444 db_drop_index($ret, 'profile_values', 'uid'); 2445 db_drop_index($ret, 'profile_values', 'fid'); 2446 db_change_field($ret,'profile_values' ,'fid', 'fid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0,), array('indexes' => array('fid' => array('fid'),))); 2447 db_change_field($ret,'profile_values' ,'uid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0,)); 2448 db_add_primary_key($ret, 'profile_values', array('uid', 'fid')); 2449 } 2450 // Alter a statistics module table to add an index. 2451 if (db_table_exists('accesslog')) { 2452 db_add_index($ret, 'accesslog', 'uid', array('uid')); 2453 } 2454 // Alter taxonomy module's tables. 2455 if (db_table_exists('term_data')) { 2456 db_drop_index($ret, 'term_data', 'vid'); 2457 db_add_index($ret, 'term_data', 'vid_name', array('vid', 'name')); 2458 db_add_index($ret, 'term_data', 'taxonomy_tree', array('vid', 'weight', 'name')); 2459 } 2460 if (db_table_exists('term_node')) { 2461 db_drop_primary_key($ret, 'term_node'); 2462 db_drop_index($ret, 'term_node', 'tid'); 2463 db_add_primary_key($ret, 'term_node', array('tid', 'vid')); 2464 } 2465 if (db_table_exists('term_relation')) { 2466 db_drop_index($ret, 'term_relation', 'tid1'); 2467 db_add_unique_key($ret, 'term_relation', 'tid1_tid2', array('tid1', 'tid2')); 2468 } 2469 if (db_table_exists('term_synonym')) { 2470 db_drop_index($ret, 'term_synonym', 'name'); 2471 db_add_index($ret, 'term_synonym', 'name_tid', array('name', 'tid')); 2472 } 2473 if (db_table_exists('vocabulary')) { 2474 db_add_index($ret, 'vocabulary', 'list', array('weight', 'name')); 2475 } 2476 if (db_table_exists('vocabulary_node_types')) { 2477 db_drop_primary_key($ret, 'vocabulary_node_types'); 2478 db_add_primary_key($ret, 'vocabulary_node_types', array('type', 'vid')); 2479 db_add_index($ret, 'vocabulary_node_types', 'vid', array('vid')); 2480 } 2481 // If we updated in RC1 or before ensure we don't update twice. 2482 variable_set('system_update_6043_RC2', TRUE); 2483 2484 return $ret; 2485 } 2486 2487 /** 2488 * RC1 to RC2 index cleanup. 2489 */ 2490 function system_update_6044() { 2491 $ret = array(); 2492 2493 // Delete invalid entries in {term_node} after system_update_6001. 2494 $ret[] = update_sql("DELETE FROM {term_node} WHERE vid = 0"); 2495 2496 // Only execute the rest of this function if 6043 was run in RC1 or before. 2497 if (variable_get('system_update_6043_RC2', FALSE)) { 2498 variable_del('system_update_6043_RC2'); 2499 return $ret; 2500 } 2501 2502 // User module indices. 2503 db_drop_unique_key($ret, 'users', 'mail'); 2504 db_add_index($ret, 'users', 'mail', array('mail')); 2505 2506 // Optional modules - need to check if the tables exist. 2507 // Alter taxonomy module's tables. 2508 if (db_table_exists('term_data')) { 2509 db_drop_unique_key($ret, 'term_data', 'vid_name'); 2510 db_add_index($ret, 'term_data', 'vid_name', array('vid', 'name')); 2511 } 2512 if (db_table_exists('term_synonym')) { 2513 db_drop_unique_key($ret, 'term_synonym', 'name_tid', array('name', 'tid')); 2514 db_add_index($ret, 'term_synonym', 'name_tid', array('name', 'tid')); 2515 } 2516 2517 return $ret; 2518 } 2519 2520 /** 2521 * Update blog, book and locale module permissions. 2522 * 2523 * Blog module got "edit own blog" replaced with the more granular "create 2524 * blog entries", "edit own blog entries" and "delete own blog entries" 2525 * permissions. We grant create and edit to previously privileged users, but 2526 * delete is not granted to be in line with other permission changes in Drupal 6. 2527 * 2528 * Book module's "edit book pages" was upgraded to the bogus "edit book content" 2529 * in Drupal 6 RC1 instead of "edit any book content", which would be correct. 2530 * 2531 * Locale module introduced "administer languages" and "translate interface" 2532 * in place of "administer locales". 2533 * 2534 * Modeled after system_update_6039(). 2535 */ 2536 function system_update_6045() { 2537 $ret = array(); 2538 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid"); 2539 while ($role = db_fetch_object($result)) { 2540 $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ blog(?=,|$)/', 'create blog entries, edit own blog entries', $role->perm); 2541 $renamed_permission = preg_replace('/(?<=^|,\ )edit\ book\ content(?=,|$)/', 'edit any book content', $renamed_permission); 2542 $renamed_permission = preg_replace('/(?<=^|,\ )administer\ locales(?=,|$)/', 'administer languages, translate interface', $renamed_permission); 2543 if ($renamed_permission != $role->perm) { 2544 $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid"); 2545 } 2546 } 2547 2548 // Notify user that delete permissions may have been changed. This was in 2549 // effect since system_update_6039(), but there was no user notice. 2550 drupal_set_message('Drupal now has separate edit and delete permissions. Previously, users who were able to edit content were automatically allowed to delete it. For added security, delete permissions for individual core content types have been <strong>removed</strong> from all roles on your site (only roles with the "administer nodes" permission can now delete these types of content). If you would like to reenable any individual delete permissions, you can do this at the <a href="'. url('admin/user/permissions', array('fragment' => 'module-node')) .'">permissions page</a>.'); 2551 return $ret; 2552 } 2553 2554 /** 2555 * Ensure that the file_directory_path variable is set (using the old 5.x 2556 * default, if necessary), so that the changed 6.x default won't break 2557 * existing sites. 2558 */ 2559 function system_update_6046() { 2560 $ret = array(); 2561 if (!variable_get('file_directory_path', FALSE)) { 2562 variable_set('file_directory_path', 'files'); 2563 $ret[] = array('success' => TRUE, 'query' => "variable_set('file_directory_path')"); 2564 } 2565 return $ret; 2566 } 2567 2568 /** 2569 * Fix cache mode for blocks inserted in system_install() in fresh installs of previous RC. 2570 */ 2571 function system_update_6047() { 2572 $ret = array(); 2573 $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'user' AND delta IN ('0', '1')"); 2574 $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'system' AND delta = '0'"); 2575 return $ret; 2576 } 2577 2578 /** 2579 * @} End of "defgroup updates-5.x-to-6.x" 2580 */ 2581 2582 /** 2583 * @defgroup updates-6.x-extra Extra system updates for 6.x 2584 * @{ 2585 */ 2586 2587 /** 2588 * Increase the size of the 'load_functions' and 'to_arg_functions' fields in table 'menu_router'. 2589 */ 2590 function system_update_6048() { 2591 $ret = array(); 2592 db_change_field($ret, 'menu_router', 'load_functions', 'load_functions', array('type' => 'text', 'not null' => TRUE,)); 2593 db_change_field($ret, 'menu_router', 'to_arg_functions', 'to_arg_functions', array('type' => 'text', 'not null' => TRUE,)); 2594 2595 return $ret; 2596 } 2597 2598 /** 2599 * Replace src index on the {url_alias} table with src, language. 2600 */ 2601 function system_update_6049() { 2602 $ret = array(); 2603 db_drop_index($ret, 'url_alias', 'src'); 2604 db_add_index($ret, 'url_alias', 'src_language', array('src', 'language')); 2605 return $ret; 2606 } 2607 2608 /** 2609 * Clear any menu router blobs stored in the cache table. 2610 */ 2611 function system_update_6050() { 2612 $ret = array(); 2613 cache_clear_all('router:', 'cache_menu', TRUE); 2614 return $ret; 2615 } 2616 2617 /** 2618 * Create a signature_format column. 2619 */ 2620 function system_update_6051() { 2621 $ret = array(); 2622 2623 if (!db_column_exists('users', 'signature_format')) { 2624 2625 // Set future input formats to FILTER_FORMAT_DEFAULT to ensure a safe default 2626 // when incompatible modules insert into the users table. An actual format 2627 // will be assigned when users save their signature. 2628 2629 $schema = array( 2630 'type' => 'int', 2631 'size' => 'small', 2632 'not null' => TRUE, 2633 'default' => FILTER_FORMAT_DEFAULT, 2634 'description' => 'The {filter_formats}.format of the signature.', 2635 ); 2636 2637 db_add_field($ret, 'users', 'signature_format', $schema); 2638 2639 // Set the format of existing signatures to the current default input format. 2640 if ($current_default_filter = variable_get('filter_default_format', 0)) { 2641 $ret[] = update_sql("UPDATE {users} SET signature_format = ". $current_default_filter); 2642 } 2643 2644 drupal_set_message("User signatures no longer inherit comment input formats. Each user's signature now has its own associated format that can be selected on the user's account page. Existing signatures have been set to your site's default input format."); 2645 } 2646 2647 return $ret; 2648 } 2649 2650 /** 2651 * Add a missing index on the {menu_router} table. 2652 */ 2653 function system_update_6052() { 2654 $ret = array(); 2655 db_add_index($ret, 'menu_router', 'tab_root_weight_title', array(array('tab_root', 64), 'weight', 'title')); 2656 return $ret; 2657 } 2658 2659 /** 2660 * Add a {system} index on type and name. 2661 */ 2662 function system_update_6053() { 2663 $ret = array(); 2664 db_add_index($ret, 'system', 'type_name', array(array('type', 12), 'name')); 2665 return $ret; 2666 } 2667 2668 /** 2669 * Add semaphore table. 2670 */ 2671 function system_update_6054() { 2672 $ret = array(); 2673 2674 // The table may have already been added by update_fix_d6_requirements(), so 2675 // check for its existence before creating. 2676 if (!db_table_exists('semaphore')) { 2677 $schema['semaphore'] = array( 2678 'fields' => array( 2679 'name' => array( 2680 'type' => 'varchar', 2681 'length' => 255, 2682 'not null' => TRUE, 2683 'default' => ''), 2684 'value' => array( 2685 'type' => 'varchar', 2686 'length' => 255, 2687 'not null' => TRUE, 2688 'default' => ''), 2689 'expire' => array( 2690 'type' => 'float', 2691 'size' => 'big', 2692 'not null' => TRUE), 2693 ), 2694 'indexes' => array('expire' => array('expire')), 2695 'primary key' => array('name'), 2696 ); 2697 db_create_table($ret, 'semaphore', $schema['semaphore']); 2698 } 2699 2700 return $ret; 2701 } 2702 2703 /** 2704 * Improve indexes on the {url_alias} table. 2705 */ 2706 function system_update_6055() { 2707 $ret = array(); 2708 db_drop_index($ret, 'url_alias', 'src_language'); 2709 db_drop_unique_key($ret, 'url_alias', 'dst_language'); 2710 db_add_index($ret, 'url_alias', 'src_language_pid', array('src', 'language', 'pid')); 2711 db_add_unique_key($ret, 'url_alias', 'dst_language_pid', array('dst', 'language', 'pid')); 2712 return $ret; 2713 } 2714 2715 /** 2716 * @} End of "defgroup updates-6.x-extra" 2717 * The next series of updates should start at 7000. 2718 */ 2719
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |