? sites/default/modules ? sites/default/settings.php Index: includes/actions.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/actions.inc,v retrieving revision 1.22 diff -u -p -r1.22 actions.inc --- includes/actions.inc 8 Nov 2008 07:28:03 -0000 1.22 +++ includes/actions.inc 15 Nov 2008 10:02:58 -0000 @@ -236,7 +236,7 @@ function actions_function_lookup($hash) } // Must be an instance; must check database. - return db_query("SELECT aid FROM {actions} WHERE MD5(aid) = :hash AND parameters <> ''", array(':hash' => $hash))->fetchField(); + return db_query("SELECT aid FROM {actions} WHERE MD5(aid) = :hash AND parameters IS NOT NULL", array(':hash' => $hash))->fetchField(); } /** @@ -251,7 +251,7 @@ function actions_synchronize($actions_in if (!$actions_in_code) { $actions_in_code = actions_list(TRUE); } - $actions_in_db = db_query("SELECT aid, callback, description FROM {actions} WHERE parameters = ''")->fetchAllAssoc('callback', PDO::FETCH_ASSOC); + $actions_in_db = db_query("SELECT aid, callback, description FROM {actions} WHERE parameters IS NULL")->fetchAllAssoc('callback', PDO::FETCH_ASSOC); // Go through all the actions provided by modules. foreach ($actions_in_code as $callback => $array) { @@ -269,7 +269,7 @@ function actions_synchronize($actions_in 'aid' => $callback, 'type' => $array['type'], 'callback' => $callback, - 'parameters' => '', + 'parameters' => NULL, 'description' => $array['description'], )) ->execute(); Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.302 diff -u -p -r1.302 form.inc --- includes/form.inc 10 Nov 2008 05:22:59 -0000 1.302 +++ includes/form.inc 15 Nov 2008 10:02:59 -0000 @@ -2603,7 +2603,8 @@ function batch_process($redirect = NULL, // at least an empty string for the (not null) 'token' column. $batch['id'] = db_insert('batch') ->fields(array( - 'token' => '', + // token will soon replace with db_update(). + 'token' => 'default', 'timestamp' => REQUEST_TIME, )) ->execute(); Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.194 diff -u -p -r1.194 locale.inc --- includes/locale.inc 11 Nov 2008 20:22:17 -0000 1.194 +++ includes/locale.inc 15 Nov 2008 10:02:59 -0000 @@ -426,7 +426,7 @@ function locale_languages_delete_form_su _locale_rebuild_js($form_state['values']['langcode']); // Remove the language. db_query("DELETE FROM {languages} WHERE language = '%s'", $form_state['values']['langcode']); - db_query("UPDATE {node} SET language = '' WHERE language = '%s'", $form_state['values']['langcode']); + db_query("UPDATE {node} SET language = NULL WHERE language = '%s'", $form_state['values']['langcode']); $variables = array('%locale' => $languages[$form_state['values']['langcode']]->name); drupal_set_message(t('The language %locale has been removed.', $variables)); watchdog('locale', 'The language %locale has been removed.', $variables); Index: includes/database/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/database.inc,v retrieving revision 1.28 diff -u -p -r1.28 database.inc --- includes/database/database.inc 15 Nov 2008 08:23:06 -0000 1.28 +++ includes/database/database.inc 15 Nov 2008 10:02:59 -0000 @@ -224,6 +224,7 @@ abstract class DatabaseConnection extend // Because the other methods don't seem to work right. $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; + $driver_options[PDO::ATTR_ORACLE_NULLS] = PDO::NULL_EMPTY_STRING; // Call PDO::__construct and PDO::setAttribute. parent::__construct($dsn, $username, $password, $driver_options); @@ -454,6 +455,12 @@ abstract class DatabaseConnection extend // Use default values if not already set. $options += $this->defaultOptions(); + foreach ($args as &$arg) { + if ($arg === '') { + $arg = NULL; + } + } + try { // We allow either a pre-bound statement object or a literal string. // In either case, we want to end up with an executed statement object, @@ -2243,6 +2250,23 @@ function _db_query_process_args($query, $options['target'] = 'default'; } + // TODO: temporary replace '' as NULL here. + foreach ($args as &$arg) { + if ($arg === '') { + $arg = NULL; + } + } + + // TODO: remove debug + openlog("drupal", LOG_PID | LOG_PERROR, LOG_LOCAL0); + if (preg_match("/''/", $query)) { + syslog(LOG_ERR, "INLINE EMPTY STRING: " . $query); + } + if (in_array('', $args, TRUE)) { + syslog(LOG_ERR, "ARGS EMPTY STRING: " . $query . ' ' . array_search('', $args, TRUE)); + } + closelog(); + // Temporary backward-compatibliity hacks. Remove later. $old_query = $query; $query = str_replace(array('%n', '%d', '%f', '%b', "'%s'", '%s'), '?', $old_query); Index: modules/block/block.install =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.install,v retrieving revision 1.13 diff -u -p -r1.13 block.install --- modules/block/block.install 15 Nov 2008 08:23:07 -0000 1.13 +++ modules/block/block.install 15 Nov 2008 10:02:59 -0000 @@ -16,8 +16,7 @@ function block_schema() { 'module' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t("The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks."), ), 'delta' => array( @@ -30,8 +29,7 @@ function block_schema() { 'theme' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('The theme under which the block settings apply.'), ), 'status' => array( @@ -51,8 +49,7 @@ function block_schema() { 'region' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Theme region within which the block is set.'), ), 'custom' => array( @@ -71,14 +68,13 @@ function block_schema() { ), 'pages' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => t('Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.'), ), 'title' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)'), ), 'cache' => array( @@ -104,13 +100,13 @@ function block_schema() { 'module' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, + 'not null' => FALSE, 'description' => t("The block's origin module, from {block}.module."), ), 'delta' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, + 'not null' => FALSE, 'description' => t("The block's unique delta within module, from {block}.delta."), ), 'rid' => array( @@ -144,8 +140,7 @@ function block_schema() { 'info' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Block description.'), ), 'format' => array( @@ -167,3 +162,85 @@ function block_schema() { return $schema; } + +/** + * @defgroup updates-6.x-to-7.x Block updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function block_update_7001() { + $ret = array(); + + $schema['block'] = array( + 'fields' => array( + 'module' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'theme' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'region' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'pages' => array( + 'type' => 'text', + 'not null' => FALSE, + ), + 'title' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + ), + ); + + $schema['block_role'] = array( + 'fields' => array( + 'module' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'delta' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + ), + ); + + $schema['box'] = array( + 'fields' => array( + 'info' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + ), + ); + + $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache'); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */ Index: modules/dblog/dblog.install =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.install,v retrieving revision 1.9 diff -u -p -r1.9 dblog.install --- modules/dblog/dblog.install 22 Oct 2008 18:32:31 -0000 1.9 +++ modules/dblog/dblog.install 15 Nov 2008 10:02:59 -0000 @@ -38,19 +38,18 @@ function dblog_schema() { 'type' => array( 'type' => 'varchar', 'length' => 16, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Type of log message, for example "user" or "page not found."'), ), 'message' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => t('Text of log message to be passed into the t() function.'), ), 'variables' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => t('Serialized array of variables that match the message string and that is passed into the t() function.'), ), @@ -66,26 +65,23 @@ function dblog_schema() { 'type' => 'varchar', 'length' => 255, 'not null' => FALSE, - 'default' => '', 'description' => t('Link to view the result of the event.'), ), 'location' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => t('URL of the origin of the event.'), ), 'referer' => array( 'type' => 'varchar', 'length' => 128, 'not null' => FALSE, - 'default' => '', 'description' => t('URL of referring page.'), ), 'hostname' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Hostname of the user who triggered the event.'), ), 'timestamp' => array( @@ -106,6 +102,11 @@ function dblog_schema() { } /** + * @defgroup updates-6.x-to-7.x Database logging updates from 6.x to 7.x + * @{ + */ + +/** * Allow NULL values for links. */ function dblog_update_7001() { @@ -123,3 +124,63 @@ function dblog_update_7002() { db_add_index($ret, 'watchdog', 'uid', array('uid')); return $ret; } + +/** + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function dblog_update_7003() { + $ret = array(); + + $schema['watchdog'] = array( + 'fields' => array( + 'type' => array( + 'type' => 'varchar', + 'length' => 16, + 'not null' => FALSE, + ), + 'message' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'variables' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'link' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'referer' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'location' => array( + 'type' => 'text', + 'not null' => FALSE, + ), + 'hostname' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + ), + ); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */ Index: modules/filter/filter.install =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v retrieving revision 1.9 diff -u -p -r1.9 filter.install --- modules/filter/filter.install 14 Apr 2008 17:48:37 -0000 1.9 +++ modules/filter/filter.install 15 Nov 2008 10:02:59 -0000 @@ -22,8 +22,7 @@ function filter_schema() { 'module' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('The origin module of the filter.'), ), 'delta' => array( @@ -60,15 +59,13 @@ function filter_schema() { 'name' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Name of the input format (Filtered HTML).'), ), 'roles' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('A comma-separated string of roles; references {role}.rid.'), // This is bad since you can't use joins, nor index. ), 'cache' => array( @@ -99,6 +96,11 @@ function filter_schema() { } /** + * @defgroup updates-6.x-to-7.x Filter updates from 6.x to 7.x + * @{ + */ + +/** * Add a weight column to the filter formats table. */ function filter_update_7000() { @@ -122,3 +124,51 @@ function filter_update_7001() { } return $ret; } + +/** + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function filter_update_7002() { + $ret = array(); + + $schema['filters'] = array( + 'fields' => array( + 'module' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + ), + ); + + $schema['filter_formats'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'roles' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['cache_filter'] = drupal_get_schema_unprocessed('system', 'cache'); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */ Index: modules/locale/locale.install =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.install,v retrieving revision 1.30 diff -u -p -r1.30 locale.install --- modules/locale/locale.install 14 Apr 2008 17:48:37 -0000 1.30 +++ modules/locale/locale.install 15 Nov 2008 10:03:00 -0000 @@ -12,7 +12,7 @@ function locale_install() { // Create tables. drupal_install_schema('locale'); - db_query("INSERT INTO {languages} (language, name, native, direction, enabled, weight, javascript) VALUES ('en', 'English', 'English', '0', '1', '0', '')"); + db_query("INSERT INTO {languages} (language, name, native, direction, enabled, weight, javascript) VALUES ('en', 'English', 'English', '0', '1', '0', NULL)"); } /** @@ -206,6 +206,102 @@ function locale_update_6005() { */ /** + * @defgroup updates-6.x-to-7.x Locale updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function locale_update_7000() { + $ret = array(); + + $schema['languages'] = array( + 'fields' => array( + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => FALSE, + ), + 'name' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'native' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'formula' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'domain' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'prefix' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'javascript' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + ), + ); + + $schema['locales_source'] = array( + 'fields' => array( + 'location' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'source' => array( + 'type' => 'text', + 'mysql_type' => 'blob', + 'not null' => FALSE, + ), + ), + ); + + $schema['locales_target'] = array( + 'fields' => array( + 'translation' => array( + 'type' => 'text', + 'mysql_type' => 'blob', + 'not null' => FALSE, + ), + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => FALSE, + ), + ), + ); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */ + +/** * Implementation of hook_uninstall(). */ function locale_uninstall() { @@ -231,22 +327,19 @@ function locale_schema() { 'language' => array( 'type' => 'varchar', 'length' => 12, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t("Language code, e.g. 'de' or 'en-US'."), ), 'name' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Language name in English.'), ), 'native' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Native language name.'), ), 'direction' => array( @@ -270,22 +363,19 @@ function locale_schema() { 'formula' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Plural formula in PHP code to evaluate to get plural indexes.'), ), 'domain' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Domain to use for this language.'), ), 'prefix' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Path prefix to use for this language.'), ), 'weight' => array( @@ -297,8 +387,7 @@ function locale_schema() { 'javascript' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Location of JavaScript translation file.'), ), ), @@ -319,8 +408,7 @@ function locale_schema() { 'location' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Drupal path in case of online discovered translations or file path in case of imported strings.'), ), 'textgroup' => array( @@ -333,7 +421,7 @@ function locale_schema() { 'source' => array( 'type' => 'text', 'mysql_type' => 'blob', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => t('The original string in English.'), ), 'version' => array( @@ -362,14 +450,13 @@ function locale_schema() { 'translation' => array( 'type' => 'text', 'mysql_type' => 'blob', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => t('Translation string value in this language.'), ), 'language' => array( 'type' => 'varchar', 'length' => 12, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Language code. References {languages}.language.'), ), 'plid' => array( Index: modules/node/node.install =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.install,v retrieving revision 1.7 diff -u -p -r1.7 node.install --- modules/node/node.install 8 Oct 2008 03:27:56 -0000 1.7 +++ modules/node/node.install 15 Nov 2008 10:03:00 -0000 @@ -25,22 +25,19 @@ function node_schema() { 'description' => t('The {node_type}.type of this node.'), 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'language' => array( 'description' => t('The {languages}.language of this node.'), 'type' => 'varchar', 'length' => 12, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'title' => array( 'description' => t('The title of this node, always treated as non-markup plain text.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'uid' => array( 'description' => t('The {users}.uid that owns this node; initially, this is the user that created it.'), @@ -143,8 +140,7 @@ function node_schema() { 'description' => t('The realm in which the user must possess the grant ID. Each node access node can define one or more realms.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'grant_view' => array( 'description' => t('Boolean indicating whether a user with the realm/grant pair can view this node.'), @@ -236,25 +232,24 @@ function node_schema() { 'description' => t('The title of this version.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'body' => array( 'description' => t('The body of this version.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), 'teaser' => array( 'description' => t('The teaser of this version.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), 'log' => array( 'description' => t('The log entry explaining the changes in this version.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), 'timestamp' => array( @@ -284,31 +279,30 @@ function node_schema() { 'description' => t('The machine-readable name of this type.'), 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, + 'not null' => FALSE, ), 'name' => array( 'description' => t('The human-readable name of this type.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'base' => array( 'description' => t('The base string used to construct callbacks corresponding to this node type.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, ), 'description' => array( 'description' => t('A brief description of this type.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'medium', ), 'help' => array( 'description' => t('Help information shown to the user when creating a {node} of this type.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'medium', ), 'has_title' => array( @@ -322,8 +316,7 @@ function node_schema() { 'description' => t('The label displayed for the title field on the edit form.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'has_body' => array( 'description' => t('Boolean indicating whether this type uses the {node_revisions}.body field.'), @@ -336,8 +329,7 @@ function node_schema() { 'description' => t('The label displayed for the body field on the edit form.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'min_word_count' => array( 'description' => t('The minimum number of words the body must contain.'), @@ -371,8 +363,7 @@ function node_schema() { 'description' => t('The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), ), 'primary key' => array('type'), @@ -382,7 +373,8 @@ function node_schema() { } /** - * Drupal 6.x to 7.x updates + * @defgroup updates-6.x-to-7.x Node updates from 6.x to 7.x + * @{ */ /** @@ -398,5 +390,122 @@ function node_update_7000() { } /** - * End of 6.x to 7.x updates + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function node_update_7001() { + $ret = array(); + + $schema['node'] = array( + 'fields' => array( + 'type' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => FALSE, + ), + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['node_access'] = array( + 'fields' => array( + 'realm' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['node_revisions'] = array( + 'fields' => array( + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'body' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'teaser' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'log' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + ), + ); + + $schema['node_type'] = array( + 'fields' => array( + 'type' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'name' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'base' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'description' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'medium', + ), + 'help' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'medium', + ), + 'title_label' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'body_label' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'orig_type' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. */ Index: modules/php/php.install =================================================================== RCS file: /cvs/drupal/drupal/modules/php/php.install,v retrieving revision 1.2 diff -u -p -r1.2 php.install --- modules/php/php.install 14 Apr 2008 17:48:41 -0000 1.2 +++ modules/php/php.install 15 Nov 2008 10:03:00 -0000 @@ -11,7 +11,7 @@ function php_install() { // reliable method to identify the format in an uninstall hook or in // subsequent clean installs. if (!$format_exists) { - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code', '', 0)"); + db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code', NULL, 0)"); $format = db_result(db_query("SELECT MAX(format) FROM {filter_formats}")); // Enable the PHP evaluator filter. Index: modules/simpletest/simpletest.install =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.install,v retrieving revision 1.13 diff -u -p -r1.13 simpletest.install --- modules/simpletest/simpletest.install 9 Nov 2008 05:50:48 -0000 1.13 +++ modules/simpletest/simpletest.install 15 Nov 2008 10:03:00 -0000 @@ -148,34 +148,30 @@ function simpletest_schema() { 'test_class' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('The name of the class that created this message.'), ), 'status' => array( 'type' => 'varchar', 'length' => 9, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Message status. Core understands pass, fail, exception.'), ), 'message' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => t('The message itself.'), ), 'message_group' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('The message group this message belongs to. For example: warning, browser, user.'), ), 'function' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Name of the assertion function or method that created this message.'), ), 'line' => array( @@ -187,8 +183,7 @@ function simpletest_schema() { 'file' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Name of the file where the function is called.'), ), ), @@ -211,3 +206,63 @@ function simpletest_schema() { ); return $schema; } + +/** + * @defgroup updates-6.x-to-7.x SimpleTest updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function simpletest_update_7000() { + $ret = array(); + + $schema['simpletest'] = array( + 'fields' => array( + 'test_class' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'status' => array( + 'type' => 'varchar', + 'length' => 9, + 'not null' => FALSE, + ), + 'message' => array( + 'type' => 'text', + 'not null' => FALSE, + ), + 'message_group' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'function' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'file' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */ Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.104 diff -u -p -r1.104 system.admin.inc --- modules/system/system.admin.inc 11 Nov 2008 22:39:59 -0000 1.104 +++ modules/system/system.admin.inc 15 Nov 2008 10:03:00 -0000 @@ -1772,7 +1772,7 @@ function system_status($check = FALSE) { } // MySQL import might have set the uid of the anonymous user to autoincrement // value. Let's try fixing it. See http://drupal.org/node/204411 - db_query("UPDATE {users} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0"); + db_query("UPDATE {users} SET uid = uid - uid WHERE name = NULL AND pass = NULL AND status = 0"); return theme('status_report', $requirements); } Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.279 diff -u -p -r1.279 system.install --- modules/system/system.install 15 Nov 2008 08:23:07 -0000 1.279 +++ modules/system/system.install 15 Nov 2008 10:03:00 -0000 @@ -351,7 +351,7 @@ function system_install() { // uid 2 which is not what we want. So we insert the first user here, the // anonymous user. uid is 1 here for now, but very soon it will be changed // to 0. - db_query("INSERT INTO {users} (name, mail) VALUES('%s', '%s')", '', ''); + db_query("INSERT INTO {users} (name, mail) VALUES(NULL, NULL)"); // We need some placeholders here as name and mail are uniques and data is // presumed to be a serialized array. Install will change uid 1 immediately // anyways. So we insert the superuser here, the uid is 2 here for now, but @@ -359,7 +359,7 @@ function system_install() { db_query("INSERT INTO {users} (name, mail, created, status, data) VALUES('%s', '%s', %d, %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, 1, serialize(array())); // This sets the above two users uid 0 (anonymous). We avoid an explicit 0 // otherwise MySQL might insert the next auto_increment value. - db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", ''); + db_query("UPDATE {users} SET uid = uid - uid WHERE name IS NULL"); // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem. db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1'); @@ -378,15 +378,15 @@ function system_install() { db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'theme_default', 's:7:"garland";'); db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'theme', 'garland'); - db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'navigation', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', '', -1); + db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', NULL, %d)", 'user', 'login', 'garland', 1, 0, 'left', -1); + db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', NULL, %d)", 'user', 'navigation', 'garland', 1, 0, 'left', -1); + db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', NULL, %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', -1); db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", 0, 0, 'all', 1, 0, 0); // Add input formats. db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Filtered HTML', ',1,2,', 1); - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Full HTML', '', 1); + db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Full HTML', NULL, 1); // Enable filters for each input format. @@ -431,13 +431,12 @@ function system_schema() { 'description' => t('The name of the variable.'), 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'value' => array( 'description' => t('The value of the variable.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), ), @@ -458,20 +457,18 @@ function system_schema() { 'description' => t('The object that that action acts on (node, user, comment, system or custom types.)'), 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'callback' => array( 'description' => t('The callback function that executes when the action runs.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'parameters' => array( 'description' => t('Parameters to be passed to the callback function.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), 'description' => array( @@ -511,7 +508,7 @@ function system_schema() { 'description' => t("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."), 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, + 'not null' => FALSE, ), 'timestamp' => array( 'description' => t('A Unix timestamp indicating when this batch was submitted for processing. Stale batches are purged at cron time.'), @@ -544,8 +541,7 @@ function system_schema() { 'description' => t('IP address'), 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), ), 'indexes' => array( @@ -561,8 +557,7 @@ function system_schema() { 'description' => t('Primary Key: Unique cache ID.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'data' => array( 'description' => t('A collection of data to cache.'), @@ -630,22 +625,19 @@ function system_schema() { 'description' => t('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.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filepath' => array( 'description' => t('Path of the file relative to Drupal root.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filemime' => array( 'description' => t("The file's MIME type."), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filesize' => array( 'description' => t('The size of the file in bytes.'), @@ -688,15 +680,13 @@ function system_schema() { 'description' => t('Name of event (e.g. contact).'), 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'hostname' => array( 'description' => t('Hostname of the visitor.'), 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'timestamp' => array( 'description' => t('Timestamp of the event.'), @@ -745,25 +735,23 @@ function system_schema() { 'description' => t('Primary Key: the Drupal path this entry describes'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'load_functions' => array( 'description' => t('A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, ), 'to_arg_functions' => array( 'description' => t('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.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, ), 'access_callback' => array( 'description' => t('The callback which determines the access to this router path. Defaults to user_access.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'access_arguments' => array( 'description' => t('A serialized array of arguments for the access callback.'), @@ -774,8 +762,7 @@ function system_schema() { 'description' => t('The name of the function that renders the page.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'page_arguments' => array( 'description' => t('A serialized array of arguments for the page callback.'), @@ -799,36 +786,31 @@ function system_schema() { 'description' => t('Only for local tasks (tabs) - the router path of the parent page (which may also be a local task).'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'tab_root' => array( 'description' => t('Router path of the closest non-tab parent page. For pages that are not local tasks, this will be the same as the path.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'title' => array( 'description' => t('The title for the current page, or the title for the tab if this is a local task.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'title_callback' => array( 'description' => t('A function which will alter the title. Defaults to t()'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'title_arguments' => array( 'description' => t('A serialized array of arguments for the title callback. If empty, the title will be used as the sole argument for the title callback.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'type' => array( 'description' => t('Numeric representation of the type of the menu item, like MENU_LOCAL_TASK.'), @@ -840,20 +822,18 @@ function system_schema() { 'description' => t('Name of a function used to render the block on the system administration page for this item.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'description' => array( 'description' => t('A description of this item.'), 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, ), 'position' => array( 'description' => t('The position of the block (left or right) on the system administration page for this item.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'weight' => array( 'description' => t('Weight of the element. Lighter weights are higher up, heavier weights go down.'), @@ -876,8 +856,7 @@ function system_schema() { 'description' => t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."), 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'mlid' => array( 'description' => t('The menu link ID (mlid) is the integer primary key.'), @@ -896,22 +875,19 @@ function system_schema() { 'description' => t('The Drupal path or external path this link points to.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'router_path' => array( 'description' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'link_title' => array( 'description' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'options' => array( 'description' => t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.'), @@ -1060,35 +1036,31 @@ function system_schema() { 'description' => t('The name of the function, class, or interface.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'type' => array( 'description' => t('Either function or class or interface.'), 'type' => 'varchar', 'length' => 9, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filename' => array( 'description' => t('Name of the file.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, ), 'module' => array( 'description' => t('Name of the module the file belongs to.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '' + 'not null' => FALSE, ), 'suffix' => array( 'description' => t("The part of the function name after the module, which is the hook this function implements, if any."), 'type' => 'varchar', 'length' => 68, - 'not null' => TRUE, - 'default' => '' + 'not null' => FALSE, ), 'weight' => array( 'description' => t("The order in which this module's hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name."), @@ -1110,13 +1082,13 @@ function system_schema() { 'description' => t('Path to the file.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, ), 'md5' => array( 'description' => t("Md5 hash of the file's contents when last parsed."), 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, + 'not null' => FALSE, ), ), 'primary key' => array('filename'), @@ -1135,15 +1107,13 @@ function system_schema() { 'description' => t("Primary key: A session ID. The value is generated by PHP's Session API."), 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'hostname' => array( 'description' => t('The IP address that last used this session ID (sid).'), 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'timestamp' => array( 'description' => t('The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.'), @@ -1178,29 +1148,25 @@ function system_schema() { 'description' => t('The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'name' => array( 'description' => t('The name of the item; e.g. node.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'type' => array( 'description' => t('The type of the item, either module, theme, or theme_engine.'), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'owner' => array( 'description' => t("A theme's 'parent' . Can be either a theme or an engine."), 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'status' => array( 'description' => t('Boolean indicating whether or not this item is enabled.'), @@ -1260,22 +1226,19 @@ function system_schema() { 'description' => t('The Drupal path this alias is for; e.g. node/12.'), 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'dst' => array( 'description' => t('The alias for this path; e.g. title-of-the-story.'), 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'language' => array( 'description' => t('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.'), 'type' => 'varchar', 'length' => 12, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), ), 'unique keys' => array( @@ -3097,6 +3060,324 @@ function system_update_7012() { } /** + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function system_update_7013() { + $ret = array(); + + $schema['variable'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'value' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + ), + ); + + $schema['actions'] = array( + 'fields' => array( + 'type' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'callback' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'parameters' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + ), + ); + + $schema['batch'] = array( + 'fields' => array( + 'token' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + ), + ); + + $schema['blocked_ips'] = array( + 'fields' => array( + 'ip' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + ), + ); + + $schema['cache'] = array( + 'fields' => array( + 'cid' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['cache_form'] = $schema['cache']; + $schema['cache_page'] = $schema['cache']; + $schema['cache_menu'] = $schema['cache']; + $schema['cache_registry'] = $schema['cache']; + + $schema['files'] = array( + 'fields' => array( + 'filename' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'filepath' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'filemime' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['flood'] = array( + 'fields' => array( + 'event' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'hostname' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + ), + ); + + $schema['menu_router'] = array( + 'fields' => array( + 'path' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'load_functions' => array( + 'type' => 'text', + 'not null' => FALSE, + ), + 'to_arg_functions' => array( + 'type' => 'text', + 'not null' => FALSE, + ), + 'access_callback' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'page_callback' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'tab_parent' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'tab_root' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'title_callback' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'title_arguments' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'block_callback' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'position' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'description' => array( + 'type' => 'text', + 'not null' => FALSE, + ), + ), + ); + + $schema['menu_links'] = array( + 'fields' => array( + 'menu_name' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'link_path' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'router_path' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'link_title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['registry'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'type' => array( + 'type' => 'varchar', + 'length' => 9, + 'not null' => FALSE, + ), + 'filename' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'module' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'suffix' => array( + 'type' => 'varchar', + 'length' => 68, + 'not null' => FALSE, + ), + ), + ); + + $schema['registry_file'] = array( + 'fields' => array( + 'filename' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'md5' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + ), + ); + + $schema['sessions'] = array( + 'fields' => array( + 'sid' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'hostname' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + ), + ); + + $schema['system'] = array( + 'fields' => array( + 'filename' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'name' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'type' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'owner' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['url_alias'] = array( + 'fields' => array( + 'src' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'dst' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => FALSE, + ), + ), + ); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.638 diff -u -p -r1.638 system.module --- modules/system/system.module 15 Nov 2008 08:23:07 -0000 1.638 +++ modules/system/system.module 15 Nov 2008 10:03:00 -0000 @@ -1526,7 +1526,7 @@ function system_actions_manage() { } $row = array(); - $instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters <> ''")); + $instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters IS NOT NULL")); $header = array( array('data' => t('Action type'), 'field' => 'type'), array('data' => t('Description'), 'field' => 'description'), Index: modules/update/update.install =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.install,v retrieving revision 1.5 diff -u -p -r1.5 update.install --- modules/update/update.install 6 Feb 2008 19:38:28 -0000 1.5 +++ modules/update/update.install 15 Nov 2008 10:03:00 -0000 @@ -62,3 +62,31 @@ function update_update_6000() { _update_remove_update_status_variables(); return array(); } + +/** + * @defgroup updates-6.x-to-7.x Update updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. + */ +function update_update_7000() { + $ret = array(); + + $schema['cache_update'] = drupal_get_schema_unprocessed('system', 'cache'); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */ Index: modules/user/user.install =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.install,v retrieving revision 1.13 diff -u -p -r1.13 user.install --- modules/user/user.install 20 Sep 2008 20:22:25 -0000 1.13 +++ modules/user/user.install 15 Nov 2008 10:03:00 -0000 @@ -23,15 +23,13 @@ function user_schema() { 'authname' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Unique authentication name.'), ), 'module' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Module which is controlling the authentication.'), ), ), @@ -53,8 +51,7 @@ function user_schema() { 'permission' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('A single permission granted to the role identified by rid.'), ), ), @@ -76,8 +73,7 @@ function user_schema() { 'name' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Unique role name.'), ), ), @@ -99,36 +95,31 @@ function user_schema() { 'name' => array( 'type' => 'varchar', 'length' => 60, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t('Unique user name.'), ), 'pass' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t("User's password (hashed)."), ), 'mail' => array( 'type' => 'varchar', 'length' => 64, 'not null' => FALSE, - 'default' => '', 'description' => t("User's email address."), ), 'theme' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t("User's default theme."), ), 'signature' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t("User's signature."), ), 'created' => array( @@ -165,22 +156,19 @@ function user_schema() { 'language' => array( 'type' => 'varchar', 'length' => 12, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t("User's default language."), ), 'picture' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => t("Path to the user's uploaded picture."), ), 'init' => array( 'type' => 'varchar', 'length' => 64, 'not null' => FALSE, - 'default' => '', 'description' => t('Email address used for initial account creation.'), ), 'data' => array( @@ -230,7 +218,7 @@ function user_schema() { } /** - * @defgroup user-updates-6.x-to-7.x User updates from 6.x to 7.x + * @defgroup updates-6.x-to-7.x User updates from 6.x to 7.x * @{ */ @@ -292,7 +280,102 @@ function user_update_7001() { } /** - * @} End of "defgroup user-updates-6.x-to-7.x" - * The next series of updates should start at 8000. + * Replace not null CHAR, VARCHAR or TEXT fields with default '' as nullable. */ +function user_update_7002() { + $ret = array(); + + $schema['authmap'] = array( + 'fields' => array( + 'authname' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'module' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + ), + ); + + $schema['role_permission'] = array( + 'fields' => array( + 'permission' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + ), + ); + + $schema['role'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + ), + ); + $schema['users'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 60, + 'not null' => FALSE, + ), + 'pass' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'mail' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'theme' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'signature' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => FALSE, + ), + 'picture' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'init' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + ), + ); + + foreach ($schema as $table => $fields) { + foreach ($fields['fields'] as $field => $def) { + db_change_field($ret, $table, $field, $field, $def); + $ret[] = update_sql("UPDATE {" . $table . "} SET " . $field . " = NULL WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */