/[drupal]/drupal/modules/system/system.install
ViewVC logotype

Contents of /drupal/modules/system/system.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.415 - (show annotations) (download) (as text)
Sat Oct 24 23:19:21 2009 UTC (5 weeks ago) by webchick
Branch: MAIN
Changes since 1.414: +2 -88 lines
File MIME type: text/x-php
#613238 by catch: Add more missing columns and tables required for upgrade.
1 <?php
2 // $Id: system.install,v 1.414 2009/10/24 03:20:43 webchick Exp $
3
4 /**
5 * @file
6 * Install, update and uninstall functions for the system module.
7 */
8
9 /**
10 * Test and report Drupal installation requirements.
11 *
12 * @param $phase
13 * The current system installation phase.
14 * @return
15 * An array of system requirements.
16 */
17 function system_requirements($phase) {
18 global $base_url;
19 $requirements = array();
20 // Ensure translations don't break at install time
21 $t = get_t();
22
23 // Report Drupal version
24 if ($phase == 'runtime') {
25 $requirements['drupal'] = array(
26 'title' => $t('Drupal'),
27 'value' => VERSION,
28 'severity' => REQUIREMENT_INFO,
29 'weight' => -10,
30 );
31
32 // Display the currently active install profile, if the site
33 // is not running the default install profile.
34 $profile = drupal_get_profile();
35 if ($profile != 'default') {
36 $info = install_profile_info($profile);
37 $requirements['install_profile'] = array(
38 'title' => $t('Install profile'),
39 'value' => $t('%profile_name (%profile-%version)', array(
40 '%profile_name' => $info['name'],
41 '%profile' => $profile,
42 '%version' => $info['version']
43 )),
44 'severity' => REQUIREMENT_INFO,
45 'weight' => -9
46 );
47 }
48 }
49
50 // Web server information.
51 $software = $_SERVER['SERVER_SOFTWARE'];
52 $requirements['webserver'] = array(
53 'title' => $t('Web server'),
54 'value' => $software,
55 );
56
57 // Test PHP version and show link to phpinfo() if it's available
58 $phpversion = phpversion();
59 if (function_exists('phpinfo')) {
60 $requirements['php'] = array(
61 'title' => $t('PHP'),
62 'value' => ($phase == 'runtime') ? $phpversion .' ('. l($t('more information'), 'admin/reports/status/php') .')' : $phpversion,
63 );
64 }
65 else {
66 $requirements['php'] = array(
67 'title' => $t('PHP'),
68 'value' => $phpversion,
69 'description' => $t('The phpinfo() function has been disabled for security reasons. To see your server\'s phpinfo() information, change your PHP settings or contact your server administrator. For more information, please read the <a href="@phpinfo">Enabling and disabling phpinfo()</a> handbook page.', array('@phpinfo' => 'http://drupal.org/node/243993')),
70 'severity' => REQUIREMENT_INFO,
71 );
72 }
73
74 if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) {
75 $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
76 $requirements['php']['severity'] = REQUIREMENT_ERROR;
77 }
78
79 // Test PHP register_globals setting.
80 $requirements['php_register_globals'] = array(
81 'title' => $t('PHP register globals'),
82 );
83 $register_globals = trim(ini_get('register_globals'));
84 // Unfortunately, ini_get() may return many different values, and we can't
85 // be certain which values mean 'on', so we instead check for 'not off'
86 // since we never want to tell the user that their site is secure
87 // (register_globals off), when it is in fact on. We can only guarantee
88 // register_globals is off if the value returned is 'off', '', or 0.
89 if (!empty($register_globals) && strtolower($register_globals) != 'off') {
90 $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>.');
91 $requirements['php_register_globals']['severity'] = REQUIREMENT_ERROR;
92 $requirements['php_register_globals']['value'] = $t("Enabled ('@value')", array('@value' => $register_globals));
93 }
94 else {
95 $requirements['php_register_globals']['value'] = $t('Disabled');
96 }
97
98 // Test PHP memory_limit
99 $memory_limit = ini_get('memory_limit');
100 $requirements['php_memory_limit'] = array(
101 'title' => $t('PHP memory limit'),
102 'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
103 );
104
105 if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)) {
106 $description = '';
107 if ($phase == 'install') {
108 $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));
109 }
110 elseif ($phase == 'update') {
111 $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));
112 }
113 elseif ($phase == 'runtime') {
114 $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));
115 }
116
117 if (!empty($description)) {
118 if ($php_ini_path = get_cfg_var('cfg_file_path')) {
119 $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));
120 }
121 else {
122 $description .= ' ' . $t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
123 }
124
125 $requirements['php_memory_limit']['description'] = $description . ' ' . $t('See the <a href="@url">Drupal requirements</a> for more information.', array('@url' => 'http://drupal.org/requirements'));
126 $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
127 }
128 }
129
130 // Test settings.php file writability
131 if ($phase == 'runtime') {
132 $conf_dir = drupal_verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir');
133 $conf_file = drupal_verify_install_file(conf_path() . '/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE);
134 if (!$conf_dir || !$conf_file) {
135 $requirements['settings.php'] = array(
136 'value' => $t('Not protected'),
137 'severity' => REQUIREMENT_ERROR,
138 'description' => '',
139 );
140 if (!$conf_dir) {
141 $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()));
142 }
143 if (!$conf_file) {
144 $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'));
145 }
146 }
147 else {
148 $requirements['settings.php'] = array(
149 'value' => $t('Protected'),
150 );
151 }
152 $requirements['settings.php']['title'] = $t('Configuration file');
153 }
154
155 // Report cron status.
156 if ($phase == 'runtime') {
157 // Cron warning threshold defaults to two days.
158 $threshold_warning = variable_get('cron_threshold_warning', 172800);
159 // Cron error threshold defaults to two weeks.
160 $threshold_error = variable_get('cron_threshold_error', 1209600);
161 // Cron configuration help text.
162 $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'));
163
164 // Determine when cron last ran.
165 $cron_last = variable_get('cron_last');
166 if (!is_numeric($cron_last)) {
167 $cron_last = variable_get('install_time', 0);
168 }
169
170 // Determine severity based on time since cron last ran.
171 $severity = REQUIREMENT_OK;
172 if (REQUEST_TIME - $cron_last > $threshold_error) {
173 $severity = REQUIREMENT_ERROR;
174 }
175 elseif (REQUEST_TIME - $cron_last > $threshold_warning) {
176 $severity = REQUIREMENT_WARNING;
177 }
178
179 // Set summary and description based on values determined above.
180 $summary = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last)));
181 $description = '';
182 if ($severity != REQUIREMENT_OK) {
183 $description = $t('Cron has not run recently.') . ' ' . $help;
184 }
185
186 $description .= ' ' . $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
187 $description .= '<br />' . $t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal'))))));
188
189 $requirements['cron'] = array(
190 'title' => $t('Cron maintenance tasks'),
191 'severity' => $severity,
192 'value' => $summary,
193 'description' => $description
194 );
195 }
196
197 // Test files directories.
198 $directories = array(
199 variable_get('file_public_path', conf_path() . '/files'),
200 variable_get('file_private_path', conf_path() . '/private/files'),
201 variable_get('file_temporary_path', conf_path() . '/private/temp'),
202 );
203 $requirements['file system'] = array(
204 'title' => $t('File system'),
205 );
206
207 $error = '';
208 // For installer, create the directories if possible.
209 foreach ($directories as $directory) {
210 if ($phase == 'install') {
211 file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
212 }
213 $is_writable = is_writable($directory);
214 $is_directory = is_dir($directory);
215 if (!$is_writable || !$is_directory) {
216 $description = '';
217 $requirements['file system']['value'] = $t('Not writable');
218 if (!$is_directory) {
219 $error .= $t('The directory %directory does not exist.', array('%directory' => $directory)) . ' ';
220 }
221 else {
222 $error .= $t('The directory %directory is not writable.', array('%directory' => $directory)) . ' ';
223 }
224 // The files directory requirement check is done only during install and runtime.
225 if ($phase == 'runtime') {
226 $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/config/media/file-system')));
227 }
228 elseif ($phase == 'install') {
229 // For the installer UI, we need different wording. 'value' will
230 // be treated as version, so provide none there.
231 $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">online handbook</a>.', array('@handbook_url' => 'http://drupal.org/server-permissions'));
232 $requirements['file system']['value'] = '';
233 }
234 if (!empty($description)) {
235 $requirements['file system']['description'] = $description;
236 $requirements['file system']['severity'] = REQUIREMENT_ERROR;
237 }
238 }
239 else {
240 if (variable_get('file_default_scheme', 'public') == 'public') {
241 $requirements['file system']['value'] = $t('Writable (<em>public</em> download method)');
242 }
243 else {
244 $requirements['file system']['value'] = $t('Writable (<em>private</em> download method)');
245 }
246 }
247 }
248
249 // See if updates are available in update.php.
250 if ($phase == 'runtime') {
251 $requirements['update'] = array(
252 'title' => $t('Database updates'),
253 'severity' => REQUIREMENT_OK,
254 'value' => $t('Up to date'),
255 );
256
257 // Check installed modules.
258 foreach (module_list() as $module) {
259 $updates = drupal_get_schema_versions($module);
260 if ($updates !== FALSE) {
261 $default = drupal_get_installed_schema_version($module);
262 if (max($updates) > $default) {
263 $requirements['update']['severity'] = REQUIREMENT_ERROR;
264 $requirements['update']['value'] = $t('Out of date');
265 $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'));
266 break;
267 }
268 }
269 }
270 }
271
272 // Verify the update.php access setting
273 if ($phase == 'runtime') {
274 if (!empty($GLOBALS['update_free_access'])) {
275 $requirements['update access'] = array(
276 'value' => $t('Not protected'),
277 'severity' => REQUIREMENT_ERROR,
278 '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.'),
279 );
280 }
281 else {
282 $requirements['update access'] = array(
283 'value' => $t('Protected'),
284 );
285 }
286 $requirements['update access']['title'] = $t('Access to update.php');
287 }
288
289 // Test Unicode library
290 include_once DRUPAL_ROOT . '/includes/unicode.inc';
291 $requirements = array_merge($requirements, unicode_requirements());
292
293 // Verify if the DOM PHP 5 extension is available.
294 $has_dom = class_exists('DOMDocument');
295 if (!$has_dom) {
296 $requirements['php_dom'] = array(
297 'title' => $t('PHP DOM Extension'),
298 'value' => $t('Not found'),
299 'severity' => REQUIREMENT_ERROR,
300 'description' => $t("The DOM extension is part of PHP 5 core, but doesn't seem to be enabled on your system. You need to enable the DOM extension on your PHP installation."),
301 );
302 }
303
304 if ($phase == 'runtime') {
305 // Check for update status module.
306 if (!module_exists('update')) {
307 $requirements['update status'] = array(
308 'value' => $t('Not enabled'),
309 'severity' => REQUIREMENT_WARNING,
310 '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/config/modules'))),
311 );
312 }
313 else {
314 $requirements['update status'] = array(
315 'value' => $t('Enabled'),
316 );
317 }
318 $requirements['update status']['title'] = $t('Update notifications');
319
320 // Check that Drupal can issue HTTP requests.
321 if (variable_get('drupal_http_request_fails', TRUE) && !system_check_http_request()) {
322 $requirements['http requests'] = array(
323 'title' => $t('HTTP request status'),
324 'value' => $t('Fails'),
325 'severity' => REQUIREMENT_ERROR,
326 '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. If you are certain that Drupal can access web pages but you are still seeing this message, you may add <code>$conf[\'drupal_http_request_fails\'] = FALSE;</code> to the bottom of your settings.php file.'),
327 );
328 }
329 }
330
331 return $requirements;
332 }
333
334 /**
335 * Implement hook_install().
336 */
337 function system_install() {
338 // Create tables.
339 $modules = array('system', 'filter', 'user', 'node');
340 foreach ($modules as $module) {
341 drupal_install_schema($module);
342 $versions = drupal_get_schema_versions($module);
343 $version = $versions ? max($versions) : SCHEMA_INSTALLED;
344 drupal_set_installed_schema_version($module, $version);
345 }
346
347 // Clear out module list and hook implementation statics before calling
348 // system_rebuild_theme_data().
349 module_list(TRUE);
350 module_implements('', FALSE, TRUE);
351
352 // Load system theme data appropriately.
353 system_rebuild_theme_data();
354
355 db_insert('users')
356 ->fields(array(
357 'uid' => 0,
358 'name' => '',
359 'mail' => '',
360 ))
361 ->execute();
362 // We need some placeholders here as name and mail are uniques and data is
363 // presumed to be a serialized array. This will be changed by the settings
364 // form.
365 db_insert('users')
366 ->fields(array(
367 'uid' => 1,
368 'name' => 'placeholder-for-uid-1',
369 'mail' => 'placeholder-for-uid-1',
370 'created' => REQUEST_TIME,
371 'status' => 1,
372 'data' => serialize(array()),
373 ))
374 ->execute();
375 // Built-in roles.
376 $rid_anonymous = db_insert('role')
377 ->fields(array('name' => 'anonymous user'))
378 ->execute();
379
380 $rid_authenticated = db_insert('role')
381 ->fields(array('name' => 'authenticated user'))
382 ->execute();
383
384 // Sanity check to ensure the anonymous and authenticated role IDs are the
385 // same as the drupal defined constants. In certain situations, this will
386 // not be true.
387 if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) {
388 db_update('role')
389 ->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
390 ->condition('rid', $rid_anonymous)
391 ->execute();
392 }
393
394 if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) {
395 db_update('role')
396 ->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
397 ->condition('rid', $rid_authenticated)
398 ->execute();
399 }
400
401 variable_set('theme_default', 'garland');
402
403 db_update('system')
404 ->fields(array('status' => 1))
405 ->condition('type', 'theme')
406 ->condition('name', 'garland')
407 ->execute();
408
409 db_insert('node_access')
410 ->fields(array(
411 'nid' => 0,
412 'gid' => 0,
413 'realm' => 'all',
414 'grant_view' => 1,
415 'grant_update' => 0,
416 'grant_delete' => 0,
417 ))
418 ->execute();
419
420 // Add text formats.
421 $filtered_html_format = db_insert('filter_format')
422 ->fields(array(
423 'name' => 'Filtered HTML',
424 'cache' => 1,
425 'weight' => 0,
426 ))
427 ->execute();
428 $full_html_format = db_insert('filter_format')
429 ->fields(array(
430 'name' => 'Full HTML',
431 'cache' => 1,
432 'weight' => 0,
433 ))
434 ->execute();
435 $plain_text_format = db_insert('filter_format')
436 ->fields(array(
437 'name' => 'Plain text',
438 'cache' => 1,
439 'weight' => 1,
440 ))
441 ->execute();
442
443 // Enable filters for each text format.
444
445 // Filtered HTML:
446 db_insert('filter')
447 ->fields(array('format', 'module', 'name', 'weight', 'status'))
448 // URL filter.
449 ->values(array(
450 'format' => $filtered_html_format,
451 'module' => 'filter',
452 'name' => 'filter_url',
453 'weight' => 0,
454 'status' => 1,
455 ))
456 // HTML filter.
457 ->values(array(
458 'format' => $filtered_html_format,
459 'module' => 'filter',
460 'name' => 'filter_html',
461 'weight' => 1,
462 'status' => 1,
463 ))
464 // Line break filter.
465 ->values(array(
466 'format' => $filtered_html_format,
467 'module' => 'filter',
468 'name' => 'filter_autop',
469 'weight' => 2,
470 'status' => 1,
471 ))
472 // HTML corrector filter.
473 ->values(array(
474 'format' => $filtered_html_format,
475 'module' => 'filter',
476 'name' => 'filter_htmlcorrector',
477 'weight' => 10,
478 'status' => 1,
479 ))
480 // Full HTML:
481 // URL filter.
482 ->values(array(
483 'format' => $full_html_format,
484 'module' => 'filter',
485 'name' => 'filter_url',
486 'weight' => 0,
487 'status' => 1,
488 ))
489 // Line break filter.
490 ->values(array(
491 'format' => $full_html_format,
492 'module' => 'filter',
493 'name' => 'filter_autop',
494 'weight' => 1,
495 'status' => 1,
496 ))
497 // HTML corrector filter.
498 ->values(array(
499 'format' => $full_html_format,
500 'module' => 'filter',
501 'name' => 'filter_htmlcorrector',
502 'weight' => 10,
503 'status' => 1,
504 ))
505 // Plain text:
506 // Escape all HTML.
507 ->values(array(
508 'format' => $plain_text_format,
509 'module' => 'filter',
510 'name' => 'filter_html_escape',
511 'weight' => 0,
512 'status' => 1,
513 ))
514 // Line break filter.
515 ->values(array(
516 'format' => $plain_text_format,
517 'module' => 'filter',
518 'name' => 'filter_autop',
519 'weight' => 1,
520 'status' => 1,
521 ))
522 ->execute();
523
524 // Set the fallback format to plain text.
525 variable_set('filter_fallback_format', $plain_text_format);
526
527 $cron_key = md5(mt_rand());
528
529 variable_set('cron_key', $cron_key);
530 }
531
532 /**
533 * Implement hook_schema().
534 */
535 function system_schema() {
536 // NOTE: {variable} needs to be created before all other tables, as
537 // some database drivers, e.g. Oracle and DB2, will require variable_get()
538 // and variable_set() for overcoming some database specific limitations.
539 $schema['variable'] = array(
540 '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.',
541 'fields' => array(
542 'name' => array(
543 'description' => 'The name of the variable.',
544 'type' => 'varchar',
545 'length' => 128,
546 'not null' => TRUE,
547 'default' => '',
548 ),
549 'value' => array(
550 'description' => 'The value of the variable.',
551 'type' => 'text',
552 'not null' => TRUE,
553 'size' => 'big',
554 'translatable' => TRUE,
555 ),
556 ),
557 'primary key' => array('name'),
558 );
559
560 $schema['actions'] = array(
561 'description' => 'Stores action information.',
562 'fields' => array(
563 'aid' => array(
564 'description' => 'Primary Key: Unique actions ID.',
565 'type' => 'varchar',
566 'length' => 255,
567 'not null' => TRUE,
568 'default' => '0',
569 ),
570 'type' => array(
571 'description' => 'The object that that action acts on (node, user, comment, system or custom types.)',
572 'type' => 'varchar',
573 'length' => 32,
574 'not null' => TRUE,
575 'default' => '',
576 ),
577 'callback' => array(
578 'description' => 'The callback function that executes when the action runs.',
579 'type' => 'varchar',
580 'length' => 255,
581 'not null' => TRUE,
582 'default' => '',
583 ),
584 'parameters' => array(
585 'description' => 'Parameters to be passed to the callback function.',
586 'type' => 'text',
587 'not null' => TRUE,
588 'size' => 'big',
589 ),
590 'label' => array(
591 'description' => 'Label of the action.',
592 'type' => 'varchar',
593 'length' => 255,
594 'not null' => TRUE,
595 'default' => '0',
596 ),
597 ),
598 'primary key' => array('aid'),
599 );
600
601 $schema['batch'] = array(
602 'description' => 'Stores details about batches (processes that run in multiple HTTP requests).',
603 'fields' => array(
604 'bid' => array(
605 'description' => 'Primary Key: Unique batch ID.',
606 'type' => 'serial',
607 'unsigned' => TRUE,
608 'not null' => TRUE,
609 ),
610 'token' => array(
611 '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.",
612 'type' => 'varchar',
613 'length' => 64,
614 'not null' => TRUE,
615 ),
616 'timestamp' => array(
617 'description' => 'A Unix timestamp indicating when this batch was submitted for processing. Stale batches are purged at cron time.',
618 'type' => 'int',
619 'not null' => TRUE,
620 ),
621 'batch' => array(
622 'description' => 'A serialized array containing the processing data for the batch.',
623 'type' => 'text',
624 'not null' => FALSE,
625 'size' => 'big',
626 ),
627 ),
628 'primary key' => array('bid'),
629 'indexes' => array(
630 'token' => array('token'),
631 ),
632 );
633
634 $schema['blocked_ips'] = array(
635 'description' => 'Stores blocked IP addresses.',
636 'fields' => array(
637 'iid' => array(
638 'description' => 'Primary Key: unique ID for IP addresses.',
639 'type' => 'serial',
640 'unsigned' => TRUE,
641 'not null' => TRUE,
642 ),
643 'ip' => array(
644 'description' => 'IP address',
645 'type' => 'varchar',
646 'length' => 32,
647 'not null' => TRUE,
648 'default' => '',
649 ),
650 ),
651 'indexes' => array(
652 'blocked_ip' => array('ip'),
653 ),
654 'primary key' => array('iid'),
655 );
656
657 $schema['cache'] = array(
658 'description' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.',
659 'fields' => array(
660 'cid' => array(
661 'description' => 'Primary Key: Unique cache ID.',
662 'type' => 'varchar',
663 'length' => 255,
664 'not null' => TRUE,
665 'default' => '',
666 ),
667 'data' => array(
668 'description' => 'A collection of data to cache.',
669 'type' => 'blob',
670 'not null' => FALSE,
671 'size' => 'big',
672 ),
673 'expire' => array(
674 'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
675 'type' => 'int',
676 'not null' => TRUE,
677 'default' => 0,
678 ),
679 'created' => array(
680 'description' => 'A Unix timestamp indicating when the cache entry was created.',
681 'type' => 'int',
682 'not null' => TRUE,
683 'default' => 0,
684 ),
685 'headers' => array(
686 'description' => 'Any custom HTTP headers to be added to cached data.',
687 'type' => 'text',
688 'not null' => FALSE,
689 ),
690 'serialized' => array(
691 'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
692 'type' => 'int',
693 'size' => 'small',
694 'not null' => TRUE,
695 'default' => 0,
696 ),
697 ),
698 'indexes' => array(
699 'expire' => array('expire'),
700 ),
701 'primary key' => array('cid'),
702 );
703
704 $schema['cache_form'] = $schema['cache'];
705 $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.';
706 $schema['cache_page'] = $schema['cache'];
707 $schema['cache_page']['description'] = 'Cache table used to store compressed pages for anonymous users, if page caching is enabled.';
708 $schema['cache_menu'] = $schema['cache'];
709 $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.';
710 $schema['cache_path'] = $schema['cache'];
711 $schema['cache_path']['description'] = 'Cache table for path alias lookup.';
712 $schema['cache_registry'] = $schema['cache'];
713 $schema['cache_registry']['description'] = 'Cache table for the code registry system to remember what code files need to be loaded on any given page.';
714
715 $schema['date_format_type'] = array(
716 'description' => 'Stores configured date format types.',
717 'fields' => array(
718 'type' => array(
719 'description' => 'The date format type, e.g. medium.',
720 'type' => 'varchar',
721 'length' => 64,
722 'not null' => TRUE,
723 ),
724 'title' => array(
725 'description' => 'The human readable name of the format type.',
726 'type' => 'varchar',
727 'length' => 255,
728 'not null' => TRUE,
729 ),
730 'locked' => array(
731 'description' => 'Whether or not this is a system provided format.',
732 'type' => 'int',
733 'size' => 'tiny',
734 'default' => 0,
735 'not null' => TRUE,
736 ),
737 ),
738 'primary key' => array('type'),
739 );
740
741 // This table's name is plural as some versions of MySQL can't create a
742 // table named 'date_format'.
743 $schema['date_formats'] = array(
744 'description' => 'Stores configured date formats.',
745 'fields' => array(
746 'dfid' => array(
747 'description' => 'The date format identifier.',
748 'type' => 'serial',
749 'not null' => TRUE,
750 'unsigned' => TRUE,
751 ),
752 'format' => array(
753 'description' => 'The date format string.',
754 'type' => 'varchar',
755 'length' => 100,
756 'not null' => TRUE,
757 ),
758 'type' => array(
759 'description' => 'The date format type, e.g. medium.',
760 'type' => 'varchar',
761 'length' => 64,
762 'not null' => TRUE,
763 ),
764 'locked' => array(
765 'description' => 'Whether or not this format can be modified.',
766 'type' => 'int',
767 'size' => 'tiny',
768 'default' => 0,
769 'not null' => TRUE,
770 ),
771 ),
772 'primary key' => array('dfid'),
773 'unique keys' => array('formats' => array('format', 'type')),
774 );
775
776 $schema['date_format_locale'] = array(
777 'description' => 'Stores configured date formats for each locale.',
778 'fields' => array(
779 'format' => array(
780 'description' => 'The date format string.',
781 'type' => 'varchar',
782 'length' => 100,
783 'not null' => TRUE,
784 ),
785 'type' => array(
786 'description' => 'The date format type, e.g. medium.',
787 'type' => 'varchar',
788 'length' => 64,
789 'not null' => TRUE,
790 ),
791 'language' => array(
792 'description' => 'A {languages}.language for this format to be used with.',
793 'type' => 'varchar',
794 'length' => 12,
795 'not null' => TRUE,
796 ),
797 ),
798 'primary key' => array('type', 'language'),
799 );
800
801 $schema['file'] = array(
802 'description' => 'Stores information for uploaded files.',
803 'fields' => array(
804 'fid' => array(
805 'description' => 'File ID.',
806 'type' => 'serial',
807 'unsigned' => TRUE,
808 'not null' => TRUE,
809 ),
810 'uid' => array(
811 'description' => 'The {users}.uid of the user who is associated with the file.',
812 'type' => 'int',
813 'unsigned' => TRUE,
814 'not null' => TRUE,
815 'default' => 0,
816 ),
817 'filename' => array(
818 'description' => 'Name of the file with no path components. This may differ from the basename of the filepath if the file is renamed to avoid overwriting an existing file.',
819 'type' => 'varchar',
820 'length' => 255,
821 'not null' => TRUE,
822 'default' => '',
823 ),
824 'uri' => array(
825 'description' => 'Path of the file relative to Drupal root.',
826 'type' => 'varchar',
827 'length' => 255,
828 'not null' => TRUE,
829 'default' => '',
830 ),
831 'filemime' => array(
832 'description' => "The file's MIME type.",
833 'type' => 'varchar',
834 'length' => 255,
835 'not null' => TRUE,
836 'default' => '',
837 ),
838 'filesize' => array(
839 'description' => 'The size of the file in bytes.',
840 'type' => 'int',
841 'unsigned' => TRUE,
842 'not null' => TRUE,
843 'default' => 0,
844 ),
845 'status' => array(
846 'description' => 'A bitmapped field indicating the status of the file. The least significant bit indicates temporary (0) or permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
847 'type' => 'int',
848 'not null' => TRUE,
849 'default' => 0,
850 ),
851 'timestamp' => array(
852 'description' => 'UNIX timestamp for when the file was added.',
853 'type' => 'int',
854 'unsigned' => TRUE,
855 'not null' => TRUE,
856 'default' => 0,
857 ),
858 ),
859 'indexes' => array(
860 'uid' => array('uid'),
861 'status' => array('status'),
862 'timestamp' => array('timestamp'),
863 ),
864 'unique keys' => array(
865 'uri' => array('uri'),
866 ),
867 'primary key' => array('fid'),
868 'foreign keys' => array(
869 'uid' => array('users' => 'uid'),
870 ),
871 );
872
873 $schema['flood'] = array(
874 'description' => 'Flood controls the threshold of events, such as the number of contact attempts.',
875 'fields' => array(
876 'fid' => array(
877 'description' => 'Unique flood event ID.',
878 'type' => 'serial',
879 'not null' => TRUE,
880 ),
881 'event' => array(
882 'description' => 'Name of event (e.g. contact).',
883 'type' => 'varchar',
884 'length' => 64,
885 'not null' => TRUE,
886 'default' => '',
887 ),
888 'identifier' => array(
889 'description' => 'Identifier of the visitor, such as an IP address or hostname.',
890 'type' => 'varchar',
891 'length' => 128,
892 'not null' => TRUE,
893 'default' => '',
894 ),
895 'timestamp' => array(
896 'description' => 'Timestamp of the event.',
897 'type' => 'int',
898 'not null' => TRUE,
899 'default' => 0,
900 ),
901 'expiration' => array(
902 'description' => 'Expiration timestamp. Expired events are purged on cron run.',
903 'type' => 'int',
904 'not null' => TRUE,
905 'default' => 0,
906 ),
907 ),
908 'primary key' => array('fid'),
909 'indexes' => array(
910 'allow' => array('event', 'identifier', 'timestamp'),
911 'purge' => array('expiration'),
912 ),
913 );
914
915 $schema['history'] = array(
916 'description' => 'A record of which {users} have read which {node}s.',
917 'fields' => array(
918 'uid' => array(
919 'description' => 'The {users}.uid that read the {node} nid.',
920 'type' => 'int',
921 'not null' => TRUE,
922 'default' => 0,
923 ),
924 'nid' => array(
925 'description' => 'The {node}.nid that was read.',
926 'type' => 'int',
927 'not null' => TRUE,
928 'default' => 0,
929 ),
930 'timestamp' => array(
931 'description' => 'The Unix timestamp at which the read occurred.',
932 'type' => 'int',
933 'not null' => TRUE,
934 'default' => 0,
935 ),
936 ),
937 'primary key' => array('uid', 'nid'),
938 'indexes' => array(
939 'nid' => array('nid'),
940 ),
941 );
942 $schema['menu_router'] = array(
943 'description' => 'Maps paths to various callbacks (access, page and title)',
944 'fields' => array(
945 'path' => array(
946 'description' => 'Primary Key: the Drupal path this entry describes',
947 'type' => 'varchar',
948 'length' => 255,
949 'not null' => TRUE,
950 'default' => '',
951 ),
952 'load_functions' => array(
953 '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.',
954 'type' => 'text',
955 'not null' => TRUE,
956 ),
957 'to_arg_functions' => array(
958 '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.',
959 'type' => 'text',
960 'not null' => TRUE,
961 ),
962 'access_callback' => array(
963 'description' => 'The callback which determines the access to this router path. Defaults to user_access.',
964 'type' => 'varchar',
965 'length' => 255,
966 'not null' => TRUE,
967 'default' => '',
968 ),
969 'access_arguments' => array(
970 'description' => 'A serialized array of arguments for the access callback.',
971 'type' => 'text',
972 'not null' => FALSE,
973 ),
974 'page_callback' => array(
975 'description' => 'The name of the function that renders the page.',
976 'type' => 'varchar',
977 'length' => 255,
978 'not null' => TRUE,
979 'default' => '',
980 ),
981 'page_arguments' => array(
982 'description' => 'A serialized array of arguments for the page callback.',
983 'type' => 'text',
984 'not null' => FALSE,
985 ),
986 'delivery_callback' => array(
987 'description' => 'The name of the function that sends the result of the page_callback function to the browser.',
988 'type' => 'varchar',
989 'length' => 255,
990 'not null' => TRUE,
991 'default' => '',
992 ),
993 'fit' => array(
994 'description' => 'A numeric representation of how specific the path is.',
995 'type' => 'int',
996 'not null' => TRUE,
997 'default' => 0,
998 ),
999 'number_parts' => array(
1000 'description' => 'Number of parts in this router path.',
1001 'type' => 'int',
1002 'not null' => TRUE,
1003 'default' => 0,
1004 'size' => 'small',
1005 ),
1006 'context' => array(
1007 'description' => 'Only for local tasks (tabs) - the context of a local task to control its placement.',
1008 'type' => 'int',
1009 'not null' => TRUE,
1010 'default' => 0,
1011 ),
1012 'tab_parent' => array(
1013 'description' => 'Only for local tasks (tabs) - the router path of the parent page (which may also be a local task).',
1014 'type' => 'varchar',
1015 'length' => 255,
1016 'not null' => TRUE,
1017 'default' => '',
1018 ),
1019 'tab_root' => array(
1020 '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.',
1021 'type' => 'varchar',
1022 'length' => 255,
1023 'not null' => TRUE,
1024 'default' => '',
1025 ),
1026 'title' => array(
1027 'description' => 'The title for the current page, or the title for the tab if this is a local task.',
1028 'type' => 'varchar',
1029 'length' => 255,
1030 'not null' => TRUE,
1031 'default' => '',
1032 ),
1033 'title_callback' => array(
1034 'description' => 'A function which will alter the title. Defaults to t()',
1035 'type' => 'varchar',
1036 'length' => 255,
1037 'not null' => TRUE,
1038 'default' => '',
1039 ),
1040 'title_arguments' => array(
1041 '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.',
1042 'type' => 'varchar',
1043 'length' => 255,
1044 'not null' => TRUE,
1045 'default' => '',
1046 ),
1047 'theme_callback' => array(
1048 'description' => 'A function which returns the name of the theme that will be used to render this page. If left empty, the default theme will be used.',
1049 'type' => 'varchar',
1050 'length' => 255,
1051 'not null' => TRUE,
1052 'default' => '',
1053 ),
1054 'theme_arguments' => array(
1055 'description' => 'A serialized array of arguments for the theme callback.',
1056 'type' => 'varchar',
1057 'length' => 255,
1058 'not null' => TRUE,
1059 'default' => '',
1060 ),
1061 'type' => array(
1062 'description' => 'Numeric representation of the type of the menu item, like MENU_LOCAL_TASK.',
1063 'type' => 'int',
1064 'not null' => TRUE,
1065 'default' => 0,
1066 ),
1067 'block_callback' => array(
1068 'description' => 'Name of a function used to render the block on the system administration page for this item.',
1069 'type' => 'varchar',
1070 'length' => 255,
1071 'not null' => TRUE,
1072 'default' => '',
1073 ),
1074 'description' => array(
1075 'description' => 'A description of this item.',
1076 'type' => 'text',
1077 'not null' => TRUE,
1078 ),
1079 'position' => array(
1080 'description' => 'The position of the block (left or right) on the system administration page for this item.',
1081 'type' => 'varchar',
1082 'length' => 255,
1083 'not null' => TRUE,
1084 'default' => '',
1085 ),
1086 'weight' => array(
1087 'description' => 'Weight of the element. Lighter weights are higher up, heavier weights go down.',
1088 'type' => 'int',
1089 'not null' => TRUE,
1090 'default' => 0,
1091 ),
1092 'file' => array(
1093 'description' => 'The file to include for this element, usually the page callback function lives in this file.',
1094 'type' => 'text',
1095 'size' => 'medium'
1096 ),
1097 ),
1098 'indexes' => array(
1099 'fit' => array('fit'),
1100 'tab_parent' => array('tab_parent'),
1101 'tab_root_weight_title' => array(array('tab_root', 64), 'weight', 'title'),
1102 ),
1103 'primary key' => array('path'),
1104 );
1105
1106 $schema['menu_links'] = array(
1107 'description' => 'Contains the individual links within a menu.',
1108 'fields' => array(
1109 'menu_name' => array(
1110 'description' => "The menu name. All links with the same menu name (such as 'navigation') are part of the same menu.",
1111 'type' => 'varchar',
1112