Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.330 diff -u -p -r1.330 bootstrap.inc --- includes/bootstrap.inc 22 Nov 2009 08:20:51 -0000 1.330 +++ includes/bootstrap.inc 2 Dec 2009 16:36:25 -0000 @@ -179,6 +179,13 @@ define('DRUPAL_AUTHENTICATED_RID', 2); define('DRUPAL_KILOBYTE', 1024); /** + * The language code used when no language is explicitly assigned. + * + * Defined by ISO639-2 for "No linguistic content / Not applicable". + */ +define('FIELD_LANGUAGE_NONE', 'zxx'); + +/** * The type of language used to define the content language. */ define('LANGUAGE_TYPE_CONTENT', 'language'); Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.50 diff -u -p -r1.50 path.inc --- includes/path.inc 2 Dec 2009 07:28:22 -0000 1.50 +++ includes/path.inc 2 Dec 2009 16:36:25 -0000 @@ -43,7 +43,7 @@ function drupal_path_initialize() { * 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 = NULL) { global $language; // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static = array(); @@ -90,9 +90,10 @@ function drupal_lookup_path($action, $pa // Now fetch the aliases corresponding to these system paths. // We order by ASC and overwrite array keys to ensure the correct // alias is used when there are multiple aliases per path. - $cache['map'][$path_language] = db_query("SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, '') ORDER BY language ASC, pid ASC", array( + $cache['map'][$path_language] = db_query("SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language ASC, pid ASC", array( ':system' => $cache['system_paths'], - ':language' => $path_language + ':language' => $path_language, + ':language_none' => FIELD_LANGUAGE_NONE, ))->fetchAllKeyed(); // Keep a record of paths with no alias to avoid querying twice. $cache['no_aliases'][$path_language] = array_flip(array_diff_key($cache['system_paths'], array_keys($cache['map'][$path_language]))); @@ -111,9 +112,10 @@ function drupal_lookup_path($action, $pa // For system paths which were not cached, query aliases individually. else if (!isset($cache['no_aliases'][$path_language][$path])) { // Get the most fitting result falling back with alias without language - $alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, '') ORDER BY language DESC, pid DESC", array( + $alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", array( ':source' => $path, - ':language' => $path_language + ':language' => $path_language, + ':language_none' => FIELD_LANGUAGE_NONE, ))->fetchField(); $cache['map'][$path_language][$path] = $alias; return $alias; @@ -126,9 +128,10 @@ function drupal_lookup_path($action, $pa $source = ''; if (!isset($cache['map'][$path_language]) || !($source = array_search($path, $cache['map'][$path_language]))) { // Get the most fitting result falling back with alias without language - if ($source = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, '') ORDER BY language DESC, pid DESC", array( + if ($source = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", array( ':alias' => $path, - ':language' => $path_language)) + ':language' => $path_language, + ':language_none' => FIELD_LANGUAGE_NONE)) ->fetchField()) { $cache['map'][$path_language][$source] = $path; } @@ -186,7 +189,7 @@ function drupal_cache_system_paths() { * An aliased path if one was found, or the original path if no alias was * found. */ -function drupal_get_path_alias($path = NULL, $path_language = '') { +function drupal_get_path_alias($path = NULL, $path_language = NULL) { // If no path is specified, use the current page's path. if ($path == NULL) { $path = $_GET['q']; @@ -210,7 +213,7 @@ function drupal_get_path_alias($path = N * 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 = NULL) { $original_path = $path; // Lookup the path alias first. @@ -445,7 +448,7 @@ function path_load($conditions) { * - language: (optional) The language of the alias. */ function path_save(&$path) { - $path += array('pid' => NULL, 'language' => ''); + $path += array('pid' => NULL, 'language' => FIELD_LANGUAGE_NONE); // Insert or update the alias. $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : NULL)); Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.812 diff -u -p -r1.812 comment.module --- modules/comment/comment.module 1 Dec 2009 16:03:35 -0000 1.812 +++ modules/comment/comment.module 2 Dec 2009 16:36:25 -0000 @@ -1672,7 +1672,7 @@ function comment_form($form, &$form_stat 'comment' => '', 'cid' => NULL, 'pid' => NULL, - 'language' => '', + 'language' => FIELD_LANGUAGE_NONE, 'uid' => 0, ); $comment = (object) $comment; Index: modules/field/field.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.module,v retrieving revision 1.49 diff -u -p -r1.49 field.module --- modules/field/field.module 2 Dec 2009 08:08:11 -0000 1.49 +++ modules/field/field.module 2 Dec 2009 16:36:25 -0000 @@ -70,13 +70,6 @@ module_load_include('inc', 'field', 'fie define('FIELD_CARDINALITY_UNLIMITED', -1); /** - * The language code assigned to untranslatable fields. - * - * Defined by ISO639-2 for "No linguistic content / Not applicable". - */ -define('FIELD_LANGUAGE_NONE', 'zxx'); - -/** * TODO */ define('FIELD_BEHAVIOR_NONE', 0x0001); Index: modules/field/field.multilingual.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.multilingual.inc,v retrieving revision 1.4 diff -u -p -r1.4 field.multilingual.inc --- modules/field/field.multilingual.inc 31 Oct 2009 16:06:35 -0000 1.4 +++ modules/field/field.multilingual.inc 2 Dec 2009 16:36:25 -0000 @@ -71,7 +71,7 @@ function field_multilingual_available_la /** * Return available content languages. * - * The languages that may be associated to fields include FIELD_LANGAUGE_NONE. + * The languages that may be associated to fields include FIELD_LANGUAGE_NONE. * * @return * An array of language codes. @@ -132,12 +132,6 @@ function field_multilingual_valid_langua if (in_array($langcode, $enabled_languages)) { return $langcode; } - // @todo Currently, node language neutral code is an empty string. Node passes - // $node->language as language parameter to field_attach_form(). We might - // want to unify the two "language neutral" language codes. - if ($langcode === '') { - return FIELD_LANGUAGE_NONE; - } global $language; $langcode = $default ? language_default('language') : $language->language; if (in_array($langcode, $enabled_languages)) { Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.272 diff -u -p -r1.272 locale.module --- modules/locale/locale.module 2 Dec 2009 00:28:43 -0000 1.272 +++ modules/locale/locale.module 2 Dec 2009 16:36:25 -0000 @@ -412,7 +412,7 @@ function locale_form_alter(&$form, &$for '#type' => 'select', '#title' => t('Language'), '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''), - '#options' => array('' => t('Language neutral')) + locale_language_list('name'), + '#options' => array(FIELD_LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'), ); } // Node type without language selector: assign the default for new nodes Index: modules/node/node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.79 diff -u -p -r1.79 node.admin.inc --- modules/node/node.admin.inc 2 Dec 2009 14:56:32 -0000 1.79 +++ modules/node/node.admin.inc 2 Dec 2009 16:36:25 -0000 @@ -108,7 +108,7 @@ function node_filters() { } // Language filter if there is a list of languages if ($languages = module_invoke('locale', 'language_list')) { - $languages = array('' => t('Language neutral')) + $languages; + $languages = array(FIELD_LANGUAGE_NONE => t('Language neutral')) + $languages; $filters['language'] = array( 'title' => t('language'), 'options' => array( @@ -169,7 +169,7 @@ function node_filter_form() { $value = $value->name; } elseif ($type == 'language') { - $value = empty($value) ? t('Language neutral') : module_invoke('locale', 'language_name', $value); + $value = $value == FIELD_LANGUAGE_NONE ? t('Language neutral') : module_invoke('locale', 'language_name', $value); } else { $value = $filters[$type]['options'][$value]; @@ -436,7 +436,7 @@ 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_query("SELECT COUNT(*) FROM {node} WHERE language <> ''")->fetchField()); + $multilanguage = (module_exists('translation') || db_query("SELECT COUNT(*) FROM {node} WHERE language <> :language", array(':language' => FIELD_LANGUAGE_NONE))->fetchField()); // Build the sortable table header. $header = array( @@ -482,7 +482,7 @@ function node_admin_nodes() { $destination = drupal_get_destination(); $options = array(); foreach ($nodes as $node) { - $l_options = !empty($node->language) ? array('language' => $languages[$node->language]) : array(); + $l_options = $node->language != FIELD_LANGUAGE_NONE ? array('language' => $languages[$node->language]) : array(); $options[$node->nid] = array( 'title' => array( 'data' => array( @@ -499,7 +499,7 @@ function node_admin_nodes() { 'changed' => format_date($node->changed, 'short'), ); if ($multilanguage) { - $options[$node->nid]['language'] = empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name); + $options[$node->nid]['language'] = $node->language == FIELD_LANGUAGE_NONE ? t('Language neutral') : t($languages[$node->language]->name); } // Build a list of all the accessible operations for the current node. $operations = array(); Index: modules/node/node.install =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.install,v retrieving revision 1.35 diff -u -p -r1.35 node.install --- modules/node/node.install 14 Nov 2009 07:58:49 -0000 1.35 +++ modules/node/node.install 2 Dec 2009 16:36:25 -0000 @@ -566,6 +566,16 @@ function node_update_7008() { } /** + * Convert node languages from the empty string to FIELD_LANGUAGE_NONE. + */ +function node_update_7009() { + db_update('node') + ->fields(array('language' => FIELD_LANGUAGE_NONE)) + ->condition('language', '') + ->execute(); +} + +/** * @} 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.102 diff -u -p -r1.102 node.pages.inc --- modules/node/node.pages.inc 1 Dec 2009 16:03:35 -0000 1.102 +++ modules/node/node.pages.inc 2 Dec 2009 16:36:25 -0000 @@ -62,7 +62,7 @@ function node_add($type) { // If a node type has been specified, validate its existence. if (isset($types[$type])) { // Initialize settings: - $node = (object)array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => ''); + $node = (object)array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => FIELD_LANGUAGE_NONE); drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH); $output = drupal_get_form($type . '_node_form', $node); Index: modules/path/path.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v retrieving revision 1.37 diff -u -p -r1.37 path.admin.inc --- modules/path/path.admin.inc 2 Dec 2009 14:56:32 -0000 1.37 +++ modules/path/path.admin.inc 2 Dec 2009 16:36:25 -0000 @@ -16,7 +16,7 @@ function path_admin_overview($keys = NUL // Add the filter form above the overview table. $build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys); // Enable language column if locale is enabled or if we have any alias with language - $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE language <> :language', 0, 1, array(':language' => ''))->fetchField(); + $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE language <> :language', 0, 1, array(':language' => FIELD_LANGUAGE_NONE))->fetchField(); $multilanguage = (module_exists('locale') || $alias_exists); $header = array( @@ -94,7 +94,7 @@ function path_admin_edit($path = array() * @see path_admin_form_validate() * @see path_admin_form_submit() */ -function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'language' => '', 'pid' => NULL)) { +function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'language' => FIELD_LANGUAGE_NONE, 'pid' => NULL)) { $form['source'] = array( '#type' => 'textfield', '#title' => t('Existing system path'), @@ -151,7 +151,7 @@ function path_admin_form_validate($form, $alias = $form_state['values']['alias']; $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 = isset($form_state['values']['language']) ? $form_state['values']['language'] : FIELD_LANGUAGE_NONE; $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND language = :language", array( ':pid' => $pid, Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.177 diff -u -p -r1.177 path.module --- modules/path/path.module 1 Dec 2009 13:14:42 -0000 1.177 +++ modules/path/path.module 2 Dec 2009 16:36:25 -0000 @@ -100,7 +100,7 @@ function path_form_alter(&$form, $form_s $path = array(); if (!empty($form['#node']->nid)) { $conditions = array('source' => 'node/' . $form['#node']->nid); - if (!empty($form['#node']->language)) { + if ($form['#node']->language != FIELD_LANGUAGE_NONE) { $conditions['language'] = $form['#node']->language; } $path = path_load($conditions); @@ -112,7 +112,7 @@ function path_form_alter(&$form, $form_s 'pid' => NULL, 'source' => isset($form['#node']->nid) ? 'node/' . $form['#node']->nid : NULL, 'alias' => '', - 'language' => isset($form['#node']->language) ? $form['#node']->language : '', + 'language' => isset($form['#node']->language) ? $form['#node']->language : FIELD_LANGUAGE_NONE, ); $form['path'] = array( @@ -190,7 +190,7 @@ function path_node_insert($node) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'node/' . $node->nid; - $path['language'] = isset($node->language) ? $node->language : ''; + $path['language'] = isset($node->language) ? $node->language : FIELD_LANGUAGE_NONE; path_save($path); } } @@ -211,7 +211,7 @@ function path_node_update($node) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'node/' . $node->nid; - $path['language'] = isset($node->language) ? $node->language : ''; + $path['language'] = isset($node->language) ? $node->language : FIELD_LANGUAGE_NONE; path_save($path); } } @@ -239,7 +239,7 @@ function path_form_taxonomy_form_term_al 'pid' => NULL, 'source' => isset($form['#term']['tid']) ? 'taxonomy/term/' . $form['#term']['tid'] : NULL, 'alias' => '', - 'language' => '', + 'language' => FIELD_LANGUAGE_NONE, ); $form['identification']['path'] = array( '#access' => user_access('create url aliases') || user_access('administer url aliases'), @@ -271,7 +271,7 @@ function path_taxonomy_term_insert($term if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; - $path['language'] = ''; + $path['language'] = FIELD_LANGUAGE_NONE; path_save($path); } } @@ -292,7 +292,7 @@ function path_taxonomy_term_update($term if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; - $path['language'] = ''; + $path['language'] = FIELD_LANGUAGE_NONE; path_save($path); } } Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.175 diff -u -p -r1.175 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 22 Nov 2009 08:09:21 -0000 1.175 +++ modules/simpletest/drupal_web_test_case.php 2 Dec 2009 16:36:25 -0000 @@ -709,6 +709,7 @@ class DrupalWebTestCase extends DrupalTe 'type' => 'page', 'revisions' => NULL, 'taxonomy' => NULL, + 'language' => FIELD_LANGUAGE_NONE, ); // Use the original node's created time for existing nodes. @@ -733,8 +734,7 @@ class DrupalWebTestCase extends DrupalTe 'value' => $this->randomName(32), 'format' => filter_default_format(), ); - $langcode = !empty($settings['language']) ? $settings['language'] : FIELD_LANGUAGE_NONE; - $settings['body'][$langcode][0] += $body; + $settings['body'][$settings['language']][0] += $body; $node = (object) $settings; node_save($node); Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.426 diff -u -p -r1.426 system.install --- modules/system/system.install 1 Dec 2009 19:19:49 -0000 1.426 +++ modules/system/system.install 2 Dec 2009 16:36:42 -0000 @@ -2813,6 +2813,16 @@ function system_update_7047() { } /** + * Convert path languages from the empty string to FIELD_LANGUAGE_NONE. + */ +function system_update_7048() { + db_update('url_alias') + ->fields(array('language' => FIELD_LANGUAGE_NONE)) + ->condition('language', '') + ->execute(); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/translation/translation.module =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v retrieving revision 1.65 diff -u -p -r1.65 translation.module --- modules/translation/translation.module 1 Dec 2009 13:14:43 -0000 1.65 +++ modules/translation/translation.module 2 Dec 2009 16:36:25 -0000 @@ -76,7 +76,7 @@ function translation_menu() { * all languages). */ function _translation_tab_access($node) { - if (!empty($node->language) && translation_supported_type($node->type)) { + if ($node->language != FIELD_LANGUAGE_NONE && translation_supported_type($node->type)) { return user_access('translate content'); } return FALSE; @@ -122,7 +122,7 @@ function translation_form_alter(&$form, // Disable languages for existing translations, so it is not possible to switch this // node to some language which is already in the translation set. Also remove the // language neutral option. - unset($form['language']['#options']['']); + unset($form['language']['#options'][FIELD_LANGUAGE_NONE]); foreach (translation_node_get_translations($node->tnid) as $translation) { if ($translation->nid != $node->nid) { unset($form['language']['#options'][$translation->language]);