Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.326 diff -u -p -r1.326 bootstrap.inc --- includes/bootstrap.inc 15 Nov 2009 21:41:06 -0000 1.326 +++ includes/bootstrap.inc 17 Nov 2009 15:09:20 -0000 @@ -194,6 +194,13 @@ define('LANGUAGE_TYPE_INTERFACE', 'langu define('LANGUAGE_TYPE_URL', 'language_url'); /** + * The language code when no language is explicitly assigned. + * + * Defined by ISO639-2 for "No linguistic content / Not applicable". + */ +define('FIELD_LANGUAGE_NONE', 'zxx'); + +/** * Language written left to right. Possible value of $language->direction. */ define('LANGUAGE_LTR', 0); Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.47 diff -u -p -r1.47 path.inc --- includes/path.inc 24 Oct 2009 05:13:43 -0000 1.47 +++ includes/path.inc 17 Nov 2009 17:41:40 -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; $cache = &drupal_static(__FUNCTION__, array( 'map' => array(), @@ -104,9 +104,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_neutral) ORDER BY language DESC, pid DESC", array( ':source' => $path, - ':language' => $path_language + ':language' => $path_language, + ':language_neutral' => FIELD_LANGUAGE_NONE, ))->fetchField(); $cache['map'][$path_language][$path] = $alias; return $alias; @@ -119,9 +120,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_neutral) ORDER BY language DESC, pid DESC", array( ':alias' => $path, - ':language' => $path_language)) + ':language' => $path_language, + ':language_neutral' => FIELD_LANGUAGE_NONE)) ->fetchField()) { $cache['map'][$path_language][$source] = $path; } @@ -179,7 +181,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']; @@ -203,7 +205,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. @@ -428,7 +430,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/field/field.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.module,v retrieving revision 1.47 diff -u -p -r1.47 field.module --- modules/field/field.module 31 Oct 2009 18:00:48 -0000 1.47 +++ modules/field/field.module 17 Nov 2009 14:34:57 -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 17 Nov 2009 15:09:21 -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.268 diff -u -p -r1.268 locale.module --- modules/locale/locale.module 10 Nov 2009 17:27:53 -0000 1.268 +++ modules/locale/locale.module 17 Nov 2009 15:09:21 -0000 @@ -415,7 +415,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.78 diff -u -p -r1.78 node.admin.inc --- modules/node/node.admin.inc 17 Nov 2009 02:50:41 -0000 1.78 +++ modules/node/node.admin.inc 17 Nov 2009 16:42:45 -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 17 Nov 2009 17:52:21 -0000 @@ -566,6 +566,16 @@ function node_update_7008() { } /** + * Convert node languages from the empty string to 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.100 diff -u -p -r1.100 node.pages.inc --- modules/node/node.pages.inc 8 Nov 2009 10:02:41 -0000 1.100 +++ modules/node/node.pages.inc 17 Nov 2009 15:09:21 -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.36 diff -u -p -r1.36 path.admin.inc --- modules/path/path.admin.inc 24 Oct 2009 05:13:44 -0000 1.36 +++ modules/path/path.admin.inc 17 Nov 2009 16:53:11 -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( @@ -98,7 +98,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'), @@ -155,7 +155,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.175 diff -u -p -r1.175 path.module --- modules/path/path.module 8 Nov 2009 10:02:41 -0000 1.175 +++ modules/path/path.module 17 Nov 2009 17:03:41 -0000 @@ -98,7 +98,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); @@ -110,7 +110,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( @@ -188,7 +188,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); } } @@ -209,7 +209,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); } } @@ -237,7 +237,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'), @@ -269,7 +269,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); } } @@ -290,7 +290,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.170 diff -u -p -r1.170 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 14 Nov 2009 07:58:49 -0000 1.170 +++ modules/simpletest/drupal_web_test_case.php 17 Nov 2009 15:18:39 -0000 @@ -706,6 +706,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. @@ -730,8 +731,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.422 diff -u -p -r1.422 system.install --- modules/system/system.install 11 Nov 2009 17:06:30 -0000 1.422 +++ modules/system/system.install 17 Nov 2009 17:52:11 -0000 @@ -2767,6 +2767,16 @@ function system_update_7045() { } /** + * Convert path languages from the empty string to LANGUAGE_NONE. + */ +function system_update_7046() { + 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.64 diff -u -p -r1.64 translation.module --- modules/translation/translation.module 8 Nov 2009 10:02:41 -0000 1.64 +++ modules/translation/translation.module 17 Nov 2009 17:08:51 -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; @@ -123,7 +123,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]);