? 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 19 Nov 2008 16:59:27 -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.304 diff -u -p -r1.304 form.inc --- includes/form.inc 15 Nov 2008 15:32:36 -0000 1.304 +++ includes/form.inc 19 Nov 2008 16:59:28 -0000 @@ -2614,7 +2614,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.195 diff -u -p -r1.195 locale.inc --- includes/locale.inc 16 Nov 2008 19:41:14 -0000 1.195 +++ includes/locale.inc 19 Nov 2008 16:59:28 -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 = 'default' 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); @@ -1215,7 +1215,7 @@ function _locale_import_message($message * @param $group * Text group to import PO file into (eg. 'default' for interface translations) */ -function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL, $file = NULL, $group = 'default') { +function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = 'default', $file = NULL, $group = 'default') { static $report = array(0, 0, 0); static $headerdone = FALSE; static $strings = array(); Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.28 diff -u -p -r1.28 path.inc --- includes/path.inc 14 Oct 2008 11:01:08 -0000 1.28 +++ includes/path.inc 19 Nov 2008 16:59:28 -0000 @@ -43,12 +43,12 @@ function drupal_init_path() { * Either a Drupal system path, an aliased path, or FALSE if no path was * found. */ -function drupal_lookup_path($action, $path = '', $path_language = '') { +function drupal_lookup_path($action, $path = '', $path_language = 'default') { global $language; // $map is an array with language keys, holding arrays of Drupal paths to alias relations static $map = array(), $no_src = array(), $count; - $path_language = $path_language ? $path_language : $language->language; + $path_language = ($path_language != 'default') ? $path_language : $language->language; // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases if (!isset($count)) { @@ -66,7 +66,7 @@ function drupal_lookup_path($action, $pa return $map[$path_language][$path]; } // Get the most fitting result falling back with alias without language - $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language)); + $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s' AND language IN('%s', 'default') ORDER BY language DESC", $path, $path_language)); $map[$path_language][$path] = $alias; return $alias; } @@ -77,7 +77,7 @@ function drupal_lookup_path($action, $pa $src = ''; if (!isset($map[$path_language]) || !($src = array_search($path, $map[$path_language]))) { // Get the most fitting result falling back with alias without language - if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language))) { + if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s' AND language IN('%s', 'default') ORDER BY language DESC", $path, $path_language))) { $map[$path_language][$src] = $path; } else { @@ -106,7 +106,7 @@ function drupal_lookup_path($action, $pa * An aliased path if one was found, or the original path if no alias was * found. */ -function drupal_get_path_alias($path, $path_language = '') { +function drupal_get_path_alias($path, $path_language = 'default') { $result = $path; if ($alias = drupal_lookup_path('alias', $path, $path_language)) { $result = $alias; @@ -126,7 +126,7 @@ function drupal_get_path_alias($path, $p * The internal path represented by the alias, or the original alias if no * internal path was found. */ -function drupal_get_normal_path($path, $path_language = '') { +function drupal_get_normal_path($path, $path_language = 'default') { $result = $path; if ($src = drupal_lookup_path('source', $path, $path_language)) { $result = $src; 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 19 Nov 2008 16:59:28 -0000 @@ -224,6 +224,8 @@ abstract class DatabaseConnection extend // Because the other methods don't seem to work right. $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; + // Empty string is converted to NULL. + $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 +456,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 +2251,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: includes/database/mysql/schema.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/mysql/schema.inc,v retrieving revision 1.6 diff -u -p -r1.6 schema.inc --- includes/database/mysql/schema.inc 13 Nov 2008 20:52:13 -0000 1.6 +++ includes/database/mysql/schema.inc 19 Nov 2008 16:59:28 -0000 @@ -73,6 +73,18 @@ class DatabaseSchema_mysql extends Datab protected function createFieldSql($name, $spec) { $sql = "`" . $name . "` " . $spec['mysql_type']; + if ($spec['type'] == 'char' || $spec['type'] == 'varchar' || $spec['type'] == 'text' || $spec['type'] == 'blob') { + // Not allow default with '', so switch field as nullable. + if (isset($spec['default']) && $spec['default'] == '') { + unset($spec['default']); + $spec['not null'] = FALSE; + } + // Set field as nullable if no valid default value. + if (!isset($spec['default']) && !empty($spec['not null'])) { + $spec['not null'] = FALSE; + } + } + if (isset($spec['length'])) { $sql .= '(' . $spec['length'] . ')'; } Index: includes/database/pgsql/schema.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/pgsql/schema.inc,v retrieving revision 1.2 diff -u -p -r1.2 schema.inc --- includes/database/pgsql/schema.inc 15 Sep 2008 20:48:07 -0000 1.2 +++ includes/database/pgsql/schema.inc 19 Nov 2008 16:59:28 -0000 @@ -80,6 +80,18 @@ class DatabaseSchema_pgsql extends Datab protected function createFieldSql($name, $spec) { $sql = $name . ' ' . $spec['pgsql_type']; + if ($spec['type'] == 'char' || $spec['type'] == 'varchar' || $spec['type'] == 'text' || $spec['type'] == 'blob') { + // Not allow default with '', so switch field as nullable. + if (isset($spec['default']) && $spec['default'] == '') { + unset($spec['default']); + $spec['not null'] = FALSE; + } + // Set field as nullable if no valid default value. + if (!isset($spec['default']) && !empty($spec['not null'])) { + $spec['not null'] = FALSE; + } + } + if ($spec['type'] == 'serial') { unset($spec['not null']); } Index: modules/aggregator/aggregator.install =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.install,v retrieving revision 1.19 diff -u -p -r1.19 aggregator.install --- modules/aggregator/aggregator.install 15 Nov 2008 13:01:04 -0000 1.19 +++ modules/aggregator/aggregator.install 19 Nov 2008 16:59:28 -0000 @@ -37,13 +37,12 @@ function aggregator_schema() { 'title' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Title of the category.', ), 'description' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'Description of the category', ), @@ -116,15 +115,13 @@ function aggregator_schema() { 'title' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Title of the feed.', ), 'url' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'URL to the feed.', ), 'refresh' => array( @@ -142,34 +139,31 @@ function aggregator_schema() { 'link' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The parent website of the feed; comes from the <link> element in the feed.', ), 'description' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => "The parent website's description; comes from the <description> element in the feed.", ), 'image' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'An image representing the feed.', ), 'hash' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Calculated md5 hash of the feed data, used for validating cache.', ), 'etag' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Entity tag HTTP response header, used for validating cache.', ), 'modified' => array( @@ -210,27 +204,24 @@ function aggregator_schema() { 'title' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Title of the feed item.', ), 'link' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Link to the feed item.', ), 'author' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Author of the feed item.', ), 'description' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'Body of the feed item.', ), @@ -256,6 +247,11 @@ function aggregator_schema() { } /** + * @defgroup updates-6.x-to-7.x Aggregator updates from 6.x to 7.x + * @{ + */ + +/** * Add hash column to aggregator_feed table. */ function aggregator_update_7000() { @@ -263,3 +259,104 @@ function aggregator_update_7000() { db_add_field($ret, 'aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '')); return $ret; } + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function aggregator_update_7001() { + $ret = array(); + + $schema['aggregator_category'] = array( + 'fields' => array( + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'description' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + ), + ); + + $schema['aggregator_feed'] = array( + 'fields' => array( + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'url' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'link' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'description' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'image' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'hash' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'etag' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['aggregator_item'] = array( + 'fields' => array( + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'link' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'author' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'description' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + ), + ); + + 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/block/block.install =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.install,v retrieving revision 1.14 diff -u -p -r1.14 block.install --- modules/block/block.install 15 Nov 2008 13:01:04 -0000 1.14 +++ modules/block/block.install 19 Nov 2008 16:59:28 -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, TEXT or BLOB 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/blogapi/blogapi.install =================================================================== RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.install,v retrieving revision 1.4 diff -u -p -r1.4 blogapi.install --- modules/blogapi/blogapi.install 15 Nov 2008 13:01:04 -0000 1.4 +++ modules/blogapi/blogapi.install 19 Nov 2008 16:59:28 -0000 @@ -40,8 +40,7 @@ function blogapi_schema() { 'description' => 'Path of the file relative to Drupal root.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filesize' => array( 'description' => 'The size of the file in bytes.', @@ -93,3 +92,39 @@ function blogapi_update_6001() { * @} End of "defgroup updates-5.x-to-6.x" * The next series of updates should start at 7000. */ + +/** + * @defgroup updates-6.x-to-7.x Blog API updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function blogapi_update_7000() { + $ret = array(); + + $schema['blogapi_files'] = array( + 'fields' => array( + 'filepath' => 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/comment/comment.install =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v retrieving revision 1.27 diff -u -p -r1.27 comment.install --- modules/comment/comment.install 15 Nov 2008 13:01:05 -0000 1.27 +++ modules/comment/comment.install 19 Nov 2008 16:59:28 -0000 @@ -109,6 +109,47 @@ function comment_update_7001() { } /** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function comment_update_7002() { + $ret = array(); + + $schema['comments'] = array( + 'fields' => array( + 'subject' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + ), + 'comment' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'hostname' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'thread' => 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. */ @@ -146,21 +187,19 @@ function comment_schema() { 'subject' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The comment title.', ), 'comment' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'The comment body.', ), 'hostname' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => "The author's host name.", ), 'timestamp' => array( @@ -187,7 +226,7 @@ function comment_schema() { 'thread' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, 'description' => "The vancode representation of the comment's place in a thread.", ), 'name' => array( Index: modules/contact/contact.install =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.install,v retrieving revision 1.11 diff -u -p -r1.11 contact.install --- modules/contact/contact.install 15 Nov 2008 13:01:05 -0000 1.11 +++ modules/contact/contact.install 19 Nov 2008 16:59:28 -0000 @@ -37,19 +37,18 @@ function contact_schema() { 'category' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Category name.', ), 'recipients' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'Comma-separated list of recipient e-mail addresses.', ), 'reply' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'Text of the auto-reply message.', ), @@ -79,3 +78,49 @@ function contact_schema() { return $schema; } + +/** + * @defgroup updates-6.x-to-7.x Contact updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function contact_update_7000() { + $ret = array(); + + $schema['contact'] = array( + 'fields' => array( + 'category' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'recipients' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'reply' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + ), + ); + + 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.10 diff -u -p -r1.10 dblog.install --- modules/dblog/dblog.install 15 Nov 2008 13:01:05 -0000 1.10 +++ modules/dblog/dblog.install 19 Nov 2008 16:59:28 -0000 @@ -38,19 +38,18 @@ function dblog_schema() { 'type' => array( 'type' => 'varchar', 'length' => 16, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Type of log message, for example "user" or "page not found."', ), 'message' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'Text of log message to be passed into the t() function.', ), 'variables' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => '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' => 'Link to view the result of the event.', ), 'location' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => 'URL of the origin of the event.', ), 'referer' => array( 'type' => 'varchar', 'length' => 128, 'not null' => FALSE, - 'default' => '', 'description' => 'URL of referring page.', ), 'hostname' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => '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, TEXT or BLOB 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.10 diff -u -p -r1.10 filter.install --- modules/filter/filter.install 15 Nov 2008 13:01:06 -0000 1.10 +++ modules/filter/filter.install 19 Nov 2008 16:59:28 -0000 @@ -22,8 +22,7 @@ function filter_schema() { 'module' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => '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' => 'Name of the input format (Filtered HTML).', ), 'roles' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => '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, TEXT or BLOB 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.31 diff -u -p -r1.31 locale.install --- modules/locale/locale.install 15 Nov 2008 13:01:07 -0000 1.31 +++ modules/locale/locale.install 19 Nov 2008 16:59:28 -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,130 @@ function locale_update_6005() { */ /** + * @defgroup updates-6.x-to-7.x Locale updates from 6.x to 7.x + * @{ + */ + +/** + * Replace default language from '' to 'default'. + */ +function locale_update_7000() { + $ret = array(); + + $schema['languages'] = array( + 'fields' => array( + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => 'default', + ), + ), + ); + + $schema['locales_target'] = array( + 'fields' => array( + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => 'default', + ), + ), + ); + + 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 . " = 'default' WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function locale_update_7001() { + $ret = array(); + + $schema['languages'] = array( + 'fields' => array( + '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, + ), + ), + ); + + 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() { @@ -232,21 +356,19 @@ function locale_schema() { 'type' => 'varchar', 'length' => 12, 'not null' => TRUE, - 'default' => '', + 'default' => 'default', 'description' => "Language code, e.g. 'de' or 'en-US'.", ), 'name' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Language name in English.', ), 'native' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Native language name.', ), 'direction' => array( @@ -270,22 +392,19 @@ function locale_schema() { 'formula' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => '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' => 'Domain to use for this language.', ), 'prefix' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Path prefix to use for this language.', ), 'weight' => array( @@ -297,8 +416,7 @@ function locale_schema() { 'javascript' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Location of JavaScript translation file.', ), ), @@ -319,8 +437,7 @@ function locale_schema() { 'location' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Drupal path in case of online discovered translations or file path in case of imported strings.', ), 'textgroup' => array( @@ -333,7 +450,7 @@ function locale_schema() { 'source' => array( 'type' => 'text', 'mysql_type' => 'blob', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => 'The original string in English.', ), 'version' => array( @@ -362,14 +479,14 @@ function locale_schema() { 'translation' => array( 'type' => 'text', 'mysql_type' => 'blob', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => 'Translation string value in this language.', ), 'language' => array( 'type' => 'varchar', 'length' => 12, 'not null' => TRUE, - 'default' => '', + 'default' => 'default', 'description' => 'Language code. References {languages}.language.', ), 'plid' => array( Index: modules/menu/menu.install =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.install,v retrieving revision 1.14 diff -u -p -r1.14 menu.install --- modules/menu/menu.install 15 Nov 2008 13:01:07 -0000 1.14 +++ modules/menu/menu.install 19 Nov 2008 16:59:28 -0000 @@ -33,15 +33,13 @@ function menu_schema() { 'menu_name' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Primary Key: Unique key for menu. This is used as a block delta so length is 32.', ), 'title' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Menu title; displayed at top of block.', ), 'description' => array( @@ -56,3 +54,43 @@ function menu_schema() { return $schema; } +/** + * @defgroup updates-6.x-to-7.x Menu updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function menu_update_7000() { + $ret = array(); + + $schema['menu_custom'] = array( + 'fields' => array( + 'menu_name' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'title' => 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/node/node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.29 diff -u -p -r1.29 node.admin.inc --- modules/node/node.admin.inc 10 Nov 2008 05:22:59 -0000 1.29 +++ modules/node/node.admin.inc 19 Nov 2008 16:59:28 -0000 @@ -452,7 +452,7 @@ function node_admin_content($form_state) function node_admin_nodes() { // Enable language column if translation module is enabled // or if we have any node with language. - $multilanguage = (module_exists('translation') || db_result(db_query("SELECT COUNT(*) FROM {node} WHERE language != ''"))); + $multilanguage = (module_exists('translation') || db_result(db_query("SELECT COUNT(*) FROM {node} WHERE language <> 'default'"))); // Build the sortable table header. $header = array(); Index: modules/node/node.install =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.install,v retrieving revision 1.8 diff -u -p -r1.8 node.install --- modules/node/node.install 15 Nov 2008 13:01:08 -0000 1.8 +++ modules/node/node.install 19 Nov 2008 16:59:28 -0000 @@ -25,22 +25,20 @@ function node_schema() { 'description' => 'The {node_type}.type of this node.', 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'language' => array( 'description' => 'The {languages}.language of this node.', 'type' => 'varchar', 'length' => 12, 'not null' => TRUE, - 'default' => '', + 'default' => 'default', ), 'title' => array( 'description' => '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' => 'The {users}.uid that owns this node; initially, this is the user that created it.', @@ -143,8 +141,7 @@ function node_schema() { 'description' => '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' => 'Boolean indicating whether a user with the realm/grant pair can view this node.', @@ -236,25 +233,24 @@ function node_schema() { 'description' => 'The title of this version.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'body' => array( 'description' => 'The body of this version.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), 'teaser' => array( 'description' => 'The teaser of this version.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), 'log' => array( 'description' => 'The log entry explaining the changes in this version.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), 'timestamp' => array( @@ -284,31 +280,30 @@ function node_schema() { 'description' => 'The machine-readable name of this type.', 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, + 'not null' => FALSE, ), 'name' => array( 'description' => 'The human-readable name of this type.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'base' => array( 'description' => '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' => 'A brief description of this type.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'medium', ), 'help' => array( 'description' => '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 +317,7 @@ function node_schema() { 'description' => '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' => 'Boolean indicating whether this type uses the {node_revisions}.body field.', @@ -336,8 +330,7 @@ function node_schema() { 'description' => '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' => 'The minimum number of words the body must contain.', @@ -371,8 +364,7 @@ function node_schema() { 'description' => '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 +374,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 +391,130 @@ function node_update_7000() { } /** - * End of 6.x to 7.x updates + * Replace default language from '' to 'default'. + */ +function node_update_7001() { + $ret = array(); + + $schema['node'] = array( + 'fields' => array( + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => 'default', + ), + ), + ); + + 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 . " = 'default' WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function node_update_7002() { + $ret = array(); + + $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, + ), + ), + 'primary key' => array('type'), + ); + + 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/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.45 diff -u -p -r1.45 node.pages.inc --- modules/node/node.pages.inc 13 Oct 2008 00:33:03 -0000 1.45 +++ modules/node/node.pages.inc 19 Nov 2008 16:59:28 -0000 @@ -57,7 +57,7 @@ function node_add($type) { // If a node type has been specified, validate its existence. if (isset($types[$type]) && node_access('create', $type)) { // Initialize settings: - $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => ''); + $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => 'default'); drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH); $output = drupal_get_form($type . '_node_form', $node); Index: modules/openid/openid.install =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.install,v retrieving revision 1.4 diff -u -p -r1.4 openid.install --- modules/openid/openid.install 15 Nov 2008 13:01:08 -0000 1.4 +++ modules/openid/openid.install 19 Nov 2008 16:59:28 -0000 @@ -32,7 +32,7 @@ function openid_schema() { 'assoc_handle' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, 'description' => 'Primary Key: Used to refer to this association in subsequent messages.', ), 'assoc_type' => array( @@ -68,3 +68,39 @@ function openid_schema() { return $schema; } + +/** + * @defgroup updates-6.x-to-7.x OpenID updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function openid_update_7000() { + $ret = array(); + + $schema['openid_association'] = array( + 'fields' => array( + 'assoc_handle' => 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/path/path.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v retrieving revision 1.14 diff -u -p -r1.14 path.admin.inc --- modules/path/path.admin.inc 13 Oct 2008 00:33:03 -0000 1.14 +++ modules/path/path.admin.inc 19 Nov 2008 16:59:28 -0000 @@ -15,7 +15,7 @@ function path_admin_overview($keys = NUL // Add the filter form above the overview table. $output = drupal_get_form('path_admin_filter_form', $keys); // Enable language column if locale is enabled or if we have any alias with language - $count = db_result(db_query("SELECT COUNT(*) FROM {url_alias} WHERE language != ''")); + $count = db_result(db_query("SELECT COUNT(*) FROM {url_alias} WHERE language <> 'default'")); $multilanguage = (module_exists('locale') || $count); if ($keys) { @@ -83,7 +83,7 @@ function path_admin_edit($pid = 0) { * @see path_admin_form_validate() * @see path_admin_form_submit() */ -function path_admin_form(&$form_state, $edit = array('src' => '', 'dst' => '', 'language' => '', 'pid' => NULL)) { +function path_admin_form(&$form_state, $edit = array('src' => '', 'dst' => '', 'language' => 'default', 'pid' => NULL)) { $form['#alias'] = $edit; @@ -132,7 +132,7 @@ function path_admin_form_validate($form, $dst = $form_state['values']['dst']; $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; // Language is only set if locale module is enabled, otherwise save for all languages. - $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : ''; + $language = $form_state['values']['language']; if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s' AND language = '%s'", $pid, $dst, $language))) { form_set_error('dst', t('The alias %alias is already in use in this language.', array('%alias' => $dst))); @@ -148,7 +148,7 @@ function path_admin_form_validate($form, */ function path_admin_form_submit($form, &$form_state) { // Language is only set if locale module is enabled - path_set_alias($form_state['values']['src'], $form_state['values']['dst'], isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0, isset($form_state['values']['language']) ? $form_state['values']['language'] : ''); + path_set_alias($form_state['values']['src'], $form_state['values']['dst'], isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0, $form_state['values']['language']); drupal_set_message(t('The alias has been saved.')); $form_state['redirect'] = 'admin/build/path'; Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.149 diff -u -p -r1.149 path.module --- modules/path/path.module 12 Oct 2008 04:30:06 -0000 1.149 +++ modules/path/path.module 19 Nov 2008 16:59:28 -0000 @@ -78,7 +78,7 @@ function path_admin_delete($pid = 0) { /** * Set an aliased path for a given Drupal path, preventing duplicates. */ -function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '') { +function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = 'default') { $path = urldecode($path); $alias = urldecode($alias); // First we check if we deal with an existing alias and delete or modify it based on pid. @@ -123,7 +123,7 @@ function path_set_alias($path = NULL, $a function path_nodeapi_validate(&$node, $arg) { if (user_access('create url aliases') || user_access('administer url aliases')) { if (isset($node->path)) { - $language = isset($node->language) ? $node->language : ''; + $language = ($node->language != 'default') ? $node->language : 'default'; $node->path = trim($node->path); if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s' AND language = '%s'", $node->path, "node/$node->nid", $language))) { form_set_error('path', t('The path is already in use.')); @@ -136,7 +136,7 @@ function path_nodeapi_validate(&$node, $ * Implementation of hook_nodeapi_load(). */ function path_nodeapi_load(&$node, $arg) { - $language = isset($node->language) ? $node->language : ''; + $language = ($node->language != 'default') ? $node->language : 'default'; $path = 'node/' . $node->nid; $alias = drupal_get_path_alias($path, $language); if ($path != $alias) { @@ -149,7 +149,7 @@ function path_nodeapi_load(&$node, $arg) */ function path_nodeapi_insert(&$node, $arg) { if (user_access('create url aliases') || user_access('administer url aliases')) { - $language = isset($node->language) ? $node->language : ''; + $language = ($node->language != 'default') ? $node->language : 'default'; // Don't try to insert if path is NULL. We may have already set // the alias ahead of time. if (isset($node->path)) { @@ -163,7 +163,7 @@ function path_nodeapi_insert(&$node, $ar */ function path_nodeapi_update(&$node, $arg) { if (user_access('create url aliases') || user_access('administer url aliases')) { - $language = isset($node->language) ? $node->language : ''; + $language = ($node->language != 'default') ? $node->language : 'default'; path_set_alias('node/' . $node->nid, isset($node->path) ? $node->path : NULL, isset($node->pid) ? $node->pid : NULL, $language); } } @@ -173,7 +173,6 @@ function path_nodeapi_update(&$node, $ar */ function path_nodeapi_delete(&$node, $arg) { if (user_access('create url aliases') || user_access('administer url aliases')) { - $language = isset($node->language) ? $node->language : ''; $path = 'node/' . $node->nid; if (drupal_get_path_alias($path) != $path) { path_set_alias($path); 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 19 Nov 2008 16:59:28 -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/poll/poll.install =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.install,v retrieving revision 1.16 diff -u -p -r1.16 poll.install --- modules/poll/poll.install 15 Nov 2008 13:01:08 -0000 1.16 +++ modules/poll/poll.install 19 Nov 2008 16:59:28 -0000 @@ -67,8 +67,7 @@ function poll_schema() { 'chtext' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The text for this choice.', ), 'chvotes' => array( @@ -116,8 +115,7 @@ function poll_schema() { 'hostname' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The IP address this vote is from unless the voter was logged in.', ), ), @@ -131,3 +129,49 @@ function poll_schema() { return $schema; } + +/** + * @defgroup updates-6.x-to-7.x Poll updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function poll_update_7000() { + $ret = array(); + + $schema['poll_choices'] = array( + 'fields' => array( + 'chtext' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + ), + ); + + $schema['poll_votes'] = array( + 'fields' => array( + '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/profile/profile.install =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.install,v retrieving revision 1.14 diff -u -p -r1.14 profile.install --- modules/profile/profile.install 15 Nov 2008 13:01:08 -0000 1.14 +++ modules/profile/profile.install 19 Nov 2008 16:59:28 -0000 @@ -40,8 +40,7 @@ function profile_schema() { 'name' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Internal name of the field used in the form HTML and URLs.', ), 'explanation' => array( @@ -148,3 +147,39 @@ function profile_schema() { return $schema; } + +/** + * @defgroup updates-6.x-to-7.x Profile updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function profile_update_7000() { + $ret = array(); + + $schema['profile_fields'] = array( + 'fields' => array( + 'name' => 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/search/search.install =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.install,v retrieving revision 1.19 diff -u -p -r1.19 search.install --- modules/search/search.install 15 Nov 2008 13:01:09 -0000 1.19 +++ modules/search/search.install 19 Nov 2008 16:59:28 -0000 @@ -43,7 +43,7 @@ function search_schema() { ), 'data' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', 'description' => 'List of space-separated words from the item.', ), @@ -64,8 +64,7 @@ function search_schema() { 'word' => array( 'type' => 'varchar', 'length' => 50, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The {search_total}.word that is associated with the search item.', ), 'sid' => array( @@ -100,8 +99,7 @@ function search_schema() { 'description' => 'Primary Key: Unique word in the search index.', 'type' => 'varchar', 'length' => 50, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'count' => array( 'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.", @@ -125,8 +123,7 @@ function search_schema() { 'type' => array( 'type' => 'varchar', 'length' => 16, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The {search_dataset}.type of the searchable item containing the link to the node.', ), 'nid' => array( @@ -153,6 +150,11 @@ function search_schema() { } /** + * @defgroup updates-6.x-to-7.x Search updates from 6.x to 7.x + * @{ + */ + +/** * Replace unique keys in 'search_dataset' and 'search_index' by primary keys. */ function search_update_7000() { @@ -166,3 +168,64 @@ function search_update_7000() { return $ret; } + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function search_update_7001() { + $ret = array(); + + $schema['search_dataset'] = array( + 'fields' => array( + 'data' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + ), + ); + + $schema['search_index'] = array( + 'fields' => array( + 'word' => array( + 'type' => 'varchar', + 'length' => 50, + 'not null' => FALSE, + ), + ), + ); + + $schema['search_total'] = array( + 'fields' => array( + 'word' => array( + 'type' => 'varchar', + 'length' => 50, + 'not null' => FALSE, + ), + ), + ); + + $schema['search_node_links'] = array( + 'fields' => array( + 'type' => array( + 'type' => 'varchar', + 'length' => 16, + '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/simpletest/simpletest.install =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.install,v retrieving revision 1.14 diff -u -p -r1.14 simpletest.install --- modules/simpletest/simpletest.install 15 Nov 2008 13:01:09 -0000 1.14 +++ modules/simpletest/simpletest.install 19 Nov 2008 16:59:28 -0000 @@ -148,34 +148,30 @@ function simpletest_schema() { 'test_class' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The name of the class that created this message.', ), 'status' => array( 'type' => 'varchar', 'length' => 9, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Message status. Core understands pass, fail, exception.', ), 'message' => array( 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'description' => 'The message itself.', ), 'message_group' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => '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' => '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' => '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, TEXT or BLOB 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/simpletest/tests/database_test.install =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/database_test.install,v retrieving revision 1.3 diff -u -p -r1.3 database_test.install --- modules/simpletest/tests/database_test.install 8 Oct 2008 18:34:30 -0000 1.3 +++ modules/simpletest/tests/database_test.install 19 Nov 2008 16:59:28 -0000 @@ -22,8 +22,7 @@ function database_test_schema() { 'description' => "A person's name", 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'age' => array( 'description' => "The person's age", @@ -57,8 +56,7 @@ function database_test_schema() { 'description' => "A person's name", 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'age' => array( 'description' => "The person's age", @@ -71,8 +69,7 @@ function database_test_schema() { 'description' => "The person's job", 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), ), 'primary key' => array('job'), @@ -136,8 +133,7 @@ function database_test_schema() { 'description' => 'The task to be completed.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'priority' => array( 'description' => 'The priority of the task.', Index: modules/simpletest/tests/taxonomy_test.install =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/taxonomy_test.install,v retrieving revision 1.2 diff -u -p -r1.2 taxonomy_test.install --- modules/simpletest/tests/taxonomy_test.install 15 Nov 2008 13:01:09 -0000 1.2 +++ modules/simpletest/tests/taxonomy_test.install 19 Nov 2008 16:59:28 -0000 @@ -23,8 +23,7 @@ function taxonomy_test_schema() { 'name' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The name of the antonym.', ), ), Index: modules/statistics/statistics.install =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.install,v retrieving revision 1.14 diff -u -p -r1.14 statistics.install --- modules/statistics/statistics.install 15 Nov 2008 13:01:09 -0000 1.14 +++ modules/statistics/statistics.install 19 Nov 2008 16:59:28 -0000 @@ -29,6 +29,42 @@ function statistics_update_1000() { } /** + * @defgroup updates-6.x-to-7.x Statistic updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function statistics_update_7000() { + $ret = array(); + + $schema['accesslog'] = array( + 'fields' => array( + 'sid' => 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. + */ + +/** * Implementation of hook_uninstall(). */ function statistics_uninstall() { @@ -59,8 +95,7 @@ function statistics_schema() { 'sid' => array( 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Browser session ID of user that visited page.', ), 'title' => array( 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 19 Nov 2008 16:59:28 -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 IS NULL AND pass IS 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.280 diff -u -p -r1.280 system.install --- modules/system/system.install 15 Nov 2008 13:01:10 -0000 1.280 +++ modules/system/system.install 19 Nov 2008 16:59:29 -0000 @@ -351,15 +351,15 @@ 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 // very soon it will be changed to 1. - 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())); + 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', NULL, %d)", 'Full HTML', 1); // Enable filters for each input format. @@ -431,13 +431,12 @@ function system_schema() { 'description' => 'The name of the variable.', 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'value' => array( 'description' => 'The value of the variable.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, 'size' => 'big', ), ), @@ -458,20 +457,18 @@ function system_schema() { 'description' => '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' => 'The callback function that executes when the action runs.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'parameters' => array( 'description' => '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' => "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' => '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' => 'IP address', 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), ), 'indexes' => array( @@ -561,8 +557,7 @@ function system_schema() { 'description' => 'Primary Key: Unique cache ID.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'data' => array( 'description' => 'A collection of data to cache.', @@ -630,22 +625,19 @@ function system_schema() { '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.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filepath' => array( 'description' => 'Path of the file relative to Drupal root.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filemime' => array( 'description' => "The file's MIME type.", 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filesize' => array( 'description' => 'The size of the file in bytes.', @@ -688,15 +680,13 @@ function system_schema() { 'description' => 'Name of event (e.g. contact).', 'type' => 'varchar', 'length' => 64, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'hostname' => array( 'description' => 'Hostname of the visitor.', 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'timestamp' => array( 'description' => 'Timestamp of the event.', @@ -745,25 +735,23 @@ function system_schema() { 'description' => 'Primary Key: the Drupal path this entry describes', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'load_functions' => array( '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.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, ), 'to_arg_functions' => array( '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.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, ), 'access_callback' => array( 'description' => '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' => 'A serialized array of arguments for the access callback.', @@ -774,8 +762,7 @@ function system_schema() { 'description' => 'The name of the function that renders the page.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'page_arguments' => array( 'description' => 'A serialized array of arguments for the page callback.', @@ -799,36 +786,31 @@ function system_schema() { 'description' => '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' => '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' => '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' => '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' => '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' => 'Numeric representation of the type of the menu item, like MENU_LOCAL_TASK.', @@ -840,20 +822,18 @@ function system_schema() { 'description' => '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' => 'A description of this item.', 'type' => 'text', - 'not null' => TRUE, + 'not null' => FALSE, ), 'position' => array( 'description' => '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' => 'Weight of the element. Lighter weights are higher up, heavier weights go down.', @@ -876,8 +856,7 @@ function system_schema() { 'description' => "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' => 'The menu link ID (mlid) is the integer primary key.', @@ -896,22 +875,19 @@ function system_schema() { 'description' => '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' => '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' => 'The text displayed for the link, which may be modified by a title callback stored in {menu_router}.', + 'description' => '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' => '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' => 'The name of the function, class, or interface.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'type' => array( 'description' => 'Either function or class or interface.', 'type' => 'varchar', 'length' => 9, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'filename' => array( 'description' => 'Name of the file.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, ), 'module' => array( 'description' => 'Name of the module the file belongs to.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '' + 'not null' => FALSE, ), 'suffix' => array( 'description' => "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' => "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' => 'Path to the file.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, + 'not null' => FALSE, ), 'md5' => array( 'description' => "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' => "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' => 'The IP address that last used this session ID (sid).', 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'timestamp' => array( 'description' => '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' => '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' => 'The name of the item; e.g. node.', 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, ), 'type' => array( 'description' => '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' => "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' => 'Boolean indicating whether or not this item is enabled.', @@ -1260,22 +1226,20 @@ function system_schema() { 'description' => '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' => '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' => '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.', + 'description' => 'The language this alias is for; if \'default\', 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' => '', + 'default' => 'default', ), ), 'unique keys' => array( @@ -3097,7 +3061,346 @@ function system_update_7012() { } /** + * Replace default language from '' to 'default'. + */ +function system_update_7013() { + $ret = array(); + + $schema['url_alias'] = array( + 'fields' => array( + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => 'default', + ), + ), + ); + + 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 . " = 'default' WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function system_update_7014() { + $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, + ), + ), + ); + + 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 19 Nov 2008 16:59:29 -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/taxonomy/taxonomy.install =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.install,v retrieving revision 1.8 diff -u -p -r1.8 taxonomy.install --- modules/taxonomy/taxonomy.install 15 Nov 2008 13:01:10 -0000 1.8 +++ modules/taxonomy/taxonomy.install 19 Nov 2008 16:59:29 -0000 @@ -24,8 +24,7 @@ function taxonomy_schema() { 'name' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The term name.', ), 'description' => array( @@ -155,8 +154,7 @@ function taxonomy_schema() { 'name' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The name of the synonym.', ), ), @@ -179,8 +177,7 @@ function taxonomy_schema() { 'name' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Name of the vocabulary.', ), 'description' => array( @@ -192,8 +189,7 @@ function taxonomy_schema() { 'help' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Help text to display for the vocabulary.', ), 'relations' => array( @@ -239,8 +235,7 @@ function taxonomy_schema() { 'module' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The module which created the vocabulary.', ), 'weight' => array( @@ -270,8 +265,7 @@ function taxonomy_schema() { 'type' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'The {node}.type of the node type for which the vocabulary may be used.', ), ), @@ -284,3 +278,78 @@ function taxonomy_schema() { return $schema; } +/** + * @defgroup updates-6.x-to-7.x Taxonomy updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function taxonomy_update_7000() { + $ret = array(); + + $schema['term_data'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['term_synonym'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['vocabulary'] = array( + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'help' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + 'module' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + ); + + $schema['vocabulary_node_types'] = array( + 'fields' => array( + 'type' => array( + 'type' => 'varchar', + 'length' => 32, + '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/trigger/trigger.install =================================================================== RCS file: /cvs/drupal/drupal/modules/trigger/trigger.install,v retrieving revision 1.6 diff -u -p -r1.6 trigger.install --- modules/trigger/trigger.install 15 Nov 2008 13:01:10 -0000 1.6 +++ modules/trigger/trigger.install 19 Nov 2008 16:59:29 -0000 @@ -30,22 +30,19 @@ function trigger_schema() { 'hook' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Primary Key: The name of the internal Drupal hook upon which an action is firing; for example, nodeapi.', ), 'op' => array( 'type' => 'varchar', 'length' => 32, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Primary Key: The specific operation of the hook upon which an action is firing: for example, presave.', ), 'aid' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => "Primary Key: Action's {actions}.aid.", ), 'weight' => array( @@ -57,7 +54,52 @@ function trigger_schema() { ), 'primary key' => array('hook', 'op', 'aid'), ); + return $schema; } +/** + * @defgroup updates-6.x-to-7.x Trigger updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function trigger_update_7000() { + $ret = array(); + + $schema['trigger_assignments'] = array( + 'fields' => array( + 'hook' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'op' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => FALSE, + ), + 'aid' => 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/update/update.install =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.install,v retrieving revision 1.6 diff -u -p -r1.6 update.install --- modules/update/update.install 15 Nov 2008 13:01:11 -0000 1.6 +++ modules/update/update.install 19 Nov 2008 16:59:29 -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, TEXT or BLOB 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/upload/upload.install =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.install,v retrieving revision 1.8 diff -u -p -r1.8 upload.install --- modules/upload/upload.install 15 Nov 2008 13:01:11 -0000 1.8 +++ modules/upload/upload.install 19 Nov 2008 16:59:29 -0000 @@ -52,8 +52,7 @@ function upload_schema() { 'description' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Description of the uploaded file.', ), 'list' => array( @@ -82,4 +81,38 @@ function upload_schema() { return $schema; } +/** + * @defgroup updates-6.x-to-7.x Upload updates from 6.x to 7.x + * @{ + */ + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function upload_update_7000() { + $ret = array(); + + $schema['upload'] = array( + 'fields' => array( + 'description' => 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/user/user.install =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.install,v retrieving revision 1.14 diff -u -p -r1.14 user.install --- modules/user/user.install 15 Nov 2008 13:01:11 -0000 1.14 +++ modules/user/user.install 19 Nov 2008 16:59:29 -0000 @@ -23,15 +23,13 @@ function user_schema() { 'authname' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Unique authentication name.', ), 'module' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => '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' => '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' => 'Unique role name.', ), ), @@ -99,36 +95,31 @@ function user_schema() { 'name' => array( 'type' => 'varchar', 'length' => 60, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => 'Unique user name.', ), 'pass' => array( 'type' => 'varchar', 'length' => 128, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => "User's password (hashed).", ), 'mail' => array( 'type' => 'varchar', 'length' => 64, 'not null' => FALSE, - 'default' => '', 'description' => "User's email address.", ), 'theme' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => "User's default theme.", ), 'signature' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => "User's signature.", ), 'created' => array( @@ -166,21 +157,19 @@ function user_schema() { 'type' => 'varchar', 'length' => 12, 'not null' => TRUE, - 'default' => '', + 'default' => 'default', 'description' => "User's default language.", ), 'picture' => array( 'type' => 'varchar', 'length' => 255, - 'not null' => TRUE, - 'default' => '', + 'not null' => FALSE, 'description' => "Path to the user's uploaded picture.", ), 'init' => array( 'type' => 'varchar', 'length' => 64, 'not null' => FALSE, - 'default' => '', 'description' => 'Email address used for initial account creation.', ), 'data' => array( @@ -230,7 +219,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 +281,124 @@ function user_update_7001() { } /** - * @} End of "defgroup user-updates-6.x-to-7.x" - * The next series of updates should start at 8000. + * Replace default language from '' to 'default'. */ +function user_update_7002() { + $ret = array(); + + $schema['users'] = array( + 'fields' => array( + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => 'default', + ), + ), + ); + + 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 . " = 'default' WHERE " . $field . " = ''"); + } + } + + return $ret; +} + +/** + * Replace not null CHAR, VARCHAR, TEXT or BLOB fields with default '' as nullable. + */ +function user_update_7003() { + $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, + ), + '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. + */ Index: modules/user/user.test =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.test,v retrieving revision 1.19 diff -u -p -r1.19 user.test --- modules/user/user.test 18 Nov 2008 15:06:47 -0000 1.19 +++ modules/user/user.test 19 Nov 2008 16:59:29 -0000 @@ -46,7 +46,7 @@ class UserRegistrationTestCase extends D $this->assertTrue(($user->created > REQUEST_TIME - 20 ), t('Correct creation time.')); $this->assertEqual($user->status, variable_get('user_register', 1) == 1 ? 1 : 0, t('Correct status field.')); $this->assertEqual($user->timezone, variable_get('date_default_timezone', NULL), t('Correct timezone field.')); - $this->assertEqual($user->language, '', t('Correct language field.')); + $this->assertEqual($user->language, 'default', t('Correct language field.')); $this->assertEqual($user->picture, '', t('Correct picture field.')); $this->assertEqual($user->init, $mail, t('Correct init field.'));