diff --git a/core/includes/gettext.inc b/core/includes/gettext.inc index 08fa38f..4d2ed9e 100644 --- a/core/includes/gettext.inc +++ b/core/includes/gettext.inc @@ -392,8 +392,8 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL case 'db-store': // We got header information. if ($value['msgid'] == '') { - $locale_plurals = variable_get('locale_translation_plurals', array()); - if (($mode != LOCALE_IMPORT_KEEP) || empty($locale_plurals[$lang]['plurals'])) { + $languages = language_list(); + if (($mode != LOCALE_IMPORT_KEEP) || empty($languages[$lang]->plurals)) { // Since we only need to parse the header if we ought to update the // plural formula, only run this if we don't need to keep existing // data untouched or if we don't have an existing plural formula. @@ -401,17 +401,24 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL // Get the plural formula and update in database. if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->uri)) { - list($nplurals, $formula) = $p; + list($nplurals, $plural) = $p; + db_update('languages') + ->fields(array( + 'plurals' => $nplurals, + 'formula' => $plural, + )) + ->condition('language', $lang) + ->execute(); } else { - $nplurals = 0; - $formula = ''; + db_update('languages') + ->fields(array( + 'plurals' => 0, + 'formula' => '', + )) + ->condition('language', $lang) + ->execute(); } - $locale_plurals[$lang] = array( - 'plurals' => $nplurals, - 'formula' => $formula, - ); - variable_set('locale_translation_plurals', $locale_plurals); } $header_done = TRUE; } @@ -917,8 +924,6 @@ function _locale_export_get_strings($language = NULL) { function _locale_export_po_generate($language = NULL, $strings = array(), $header = NULL) { global $user; - $locale_plurals = variable_get('locale_translation_plurals', array()); - if (!isset($header)) { if (isset($language)) { $header = '# ' . $language->name . ' translation of ' . variable_get('site_name', 'Drupal') . "\n"; @@ -934,8 +939,8 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade $header .= "\"MIME-Version: 1.0\\n\"\n"; $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n"; $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n"; - if (!empty($locale_plurals[$language->language]['formula'])) { - $header .= "\"Plural-Forms: nplurals=" . $locale_plurals[$language->language]['plurals'] . "; plural=" . strtr($locale_plurals[$language->language]['formula'], array('$' => '')) . ";\\n\"\n"; + if ($language->formula && $language->plurals) { + $header .= "\"Plural-Forms: nplurals=" . $language->plurals . "; plural=" . strtr($language->formula, array('$' => '')) . ";\\n\"\n"; } } else { @@ -973,7 +978,7 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade $output .= 'msgid_plural ' . _locale_export_string($strings[$plural]['source']); if (isset($language)) { $translation = $string['translation']; - for ($i = 0; $i < $locale_plurals[$language->language]['plurals']; $i++) { + for ($i = 0; $i < $language->plurals; $i++) { $output .= 'msgstr[' . $i . '] ' . _locale_export_string($translation); if ($plural) { $translation = _locale_export_remove_plural($strings[$plural]['translation']); diff --git a/core/includes/locale.inc b/core/includes/locale.inc index e9cd427..6222bda 100644 --- a/core/includes/locale.inc +++ b/core/includes/locale.inc @@ -751,9 +751,8 @@ function _locale_rebuild_js($langcode = NULL) { $data = "Drupal.locale = { "; - $locale_plurals = variable_get('locale_translation_plurals', array()); - if (!empty($locale_plurals[$language->language])) { - $data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->language]['formula']}); }, "; + if (!empty($language->formula)) { + $data .= "'pluralFormula': function (\$n) { return Number({$language->formula}); }, "; } $data .= "'strings': " . drupal_json_encode($translations) . " };"; @@ -765,11 +764,10 @@ function _locale_rebuild_js($langcode = NULL) { $dir = 'public://' . variable_get('locale_js_directory', 'languages'); // Delete old file, if we have no translations anymore, or a different file to be saved. - $locale_javascripts = variable_get('locale_translation_javascript', array()); - $changed_hash = !isset($locale_javascripts[$language->language]) || ($locale_javascripts[$language->language] != $data_hash); - if (!empty($locale_javascripts[$language->language]) && (!$data || $changed_hash)) { - file_unmanaged_delete($dir . '/' . $language->language . '_' . $locale_javascripts[$language->language] . '.js'); - $locale_javascripts[$language->language] = ''; + $changed_hash = $language->javascript != $data_hash; + if (!empty($language->javascript) && (!$data || $changed_hash)) { + file_unmanaged_delete($dir . '/' . $language->language . '_' . $language->javascript . '.js'); + $language->javascript = ''; $status = 'deleted'; } @@ -782,7 +780,7 @@ function _locale_rebuild_js($langcode = NULL) { // Save the file. if (file_unmanaged_save_data($data, $dest)) { - $locale_javascripts[$language->language] = $data_hash; + $language->javascript = $data_hash; // If we deleted a previous version of the file and we replace it with a // new one we have an update. if ($status == 'deleted') { @@ -800,7 +798,7 @@ function _locale_rebuild_js($langcode = NULL) { } } else { - $locale_javascripts[$language->language] = ''; + $language->javascript = ''; $status = 'error'; } } @@ -809,7 +807,22 @@ function _locale_rebuild_js($langcode = NULL) { // deleted). Act only if some operation was executed that changed the hash // code. if ($status && $changed_hash) { - variable_set('locale_translation_javascript', $locale_javascripts); + db_update('languages') + ->fields(array( + 'javascript' => $language->javascript, + )) + ->condition('language', $language->language) + ->execute(); + + // Update the default language variable if the default language has been altered. + // This is necessary to keep the variable consistent with the database + // version of the language and to prevent checking against an outdated hash. + $default_langcode = language_default()->language; + drupal_static_reset('language_list'); + if ($default_langcode == $language->language) { + $default = language_load($default_langcode); + variable_set('language_default', $default); + } } // Log the operation and return success flag. @@ -818,7 +831,7 @@ function _locale_rebuild_js($langcode = NULL) { watchdog('locale', 'Updated JavaScript translation file for the language %language.', array('%language' => $language->name)); return TRUE; case 'rebuilt': - watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->language]), WATCHDOG_WARNING); + watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $language->javascript), WATCHDOG_WARNING); // Proceed to the 'created' case as the JavaScript translation file has // been created again. case 'created': diff --git a/core/misc/authorize.js b/core/misc/authorize.js index d522a5b..66b7897 100644 --- a/core/misc/authorize.js +++ b/core/misc/authorize.js @@ -16,6 +16,7 @@ Drupal.behaviors.authorizeFileTransferForm = { // Removes the float on the select box (used for non-JS interface). if ($('.connection-settings-update-filetransfer-default-wrapper').length > 0) { + console.log($('.connection-settings-update-filetransfer-default-wrapper')); $('.connection-settings-update-filetransfer-default-wrapper').css('float', 'none'); } // Hides the submit button for non-js users. diff --git a/core/modules/aggregator/aggregator.api.php b/core/modules/aggregator/aggregator.api.php index ea11927..f31413c 100644 --- a/core/modules/aggregator/aggregator.api.php +++ b/core/modules/aggregator/aggregator.api.php @@ -76,29 +76,33 @@ function hook_aggregator_fetch_info() { * finally, it is passed to all active processors which manipulate or store the * data. * - * Modules that define this hook can be set as the active parser on + * Modules that define this hook can be set as active parser on * admin/config/services/aggregator. Only one parser can be active at a time. * * @param $feed - * An object describing the resource to be parsed: $feed->source_string - * contains the raw feed data. The hook implementation should parse this data - * and add the following properties to the $feed object: - * - description: The human-readable description of the feed. - * - link: A full URL that directly relates to the feed. - * - image: An image URL used to display an image of the feed. - * - etag: An entity tag from the HTTP header used for cache validation to - * determine if the content has been changed. - * - modified: The UNIX timestamp when the feed was last modified. - * - items: An array of feed items. The common format for a single feed item - * is an associative array containing: - * - title: The human-readable title of the feed item. - * - description: The full body text of the item or a summary. - * - timestamp: The UNIX timestamp when the feed item was last published. - * - author: The author of the feed item. - * - guid: The global unique identifier (GUID) string that uniquely - * identifies the item. If not available, the link is used to identify - * the item. - * - link: A full URL to the individual feed item. + * The $feed object that describes the resource to be parsed. + * $feed->source_string contains the raw feed data as a string. Parse data + * from $feed->source_string and expose it to other modules as an array of + * data items on $feed->items. + * + * Feed format: + * - $feed->description (string) - description of the feed + * - $feed->image (string) - image for the feed + * - $feed->etag (string) - value of feed's entity tag header field + * - $feed->modified (UNIX timestamp) - value of feed's last modified header + * field + * - $feed->items (Array) - array of feed items. + * + * By convention, the common format for a single feed item is: + * $item[key-name] = value; + * + * Recognized keys: + * TITLE (string) - the title of a feed item + * DESCRIPTION (string) - the description (body text) of a feed item + * TIMESTAMP (UNIX timestamp) - the feed item's published time as UNIX timestamp + * AUTHOR (string) - the feed item's author + * GUID (string) - RSS/Atom global unique identifier + * LINK (string) - the feed item's URL * * @return * TRUE if parsing was successful, FALSE otherwise. diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index d30923f..228953b 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -89,61 +89,30 @@ function aggregator_page_category_form($form, $form_state, $category) { } /** - * Loads and optionally filters feed items. + * Load feed items * * @param $type - * The type of filter for the items. Possible values are: - * - sum: No filtering. - * - source: Filter the feed items, limiting the result to items from a - * single source. - * - category: Filter the feed items by category. + * The filter for the items. Possible values: 'sum', 'source', 'category' * @param $data - * Feed or category data used for filtering. The type and value of $data - * depends on $type: - * - source: $data is an object with $data->fid identifying the feed used to - * as filter. - * - category: $data is an array with $data['cid'] being the category id to - * filter on. - * The $data parameter is not used when $type is 'sum'. - * + * Feed or category data for filtering * @return * An array of the feed items. */ function aggregator_load_feed_items($type, $data = NULL) { $items = array(); + $range_limit = 20; switch ($type) { case 'sum': - $query = db_select('aggregator_item', 'i'); - $query->join('aggregator_feed', 'f', 'i.fid = f.fid'); - $query->fields('i'); - $query->addField('f', 'title', 'ftitle'); - $query->addField('f', 'link', 'flink'); + $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', 0, $range_limit); break; case 'source': - $query = db_select('aggregator_item', 'i'); - $query - ->fields('i') - ->condition('i.fid', $data->fid); + $result = db_query_range('SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC', 0, $range_limit, array(':fid' => $data->fid)); break; case 'category': - $query = db_select('aggregator_category_item', 'c'); - $query->leftJoin('aggregator_item', 'i', 'c.iid = i.iid'); - $query->leftJoin('aggregator_feed', 'f', 'i.fid = f.fid'); - $query - ->fields('i') - ->condition('cid', $data['cid']); - $query->addField('f', 'title', 'ftitle'); - $query->addField('f', 'link', 'flink'); + $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = :cid ORDER BY timestamp DESC, i.iid DESC', 0, $range_limit, array(':cid' => $data['cid'])); break; } - $result = $query - ->extend('PagerDefault') - ->limit(20) - ->orderBy('i.timestamp', 'DESC') - ->orderBy('i.iid', 'DESC') - ->execute(); - foreach ($result as $item) { $item->categories = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = :iid ORDER BY c.title', array(':iid' => $item->iid))->fetchAll(); $items[] = $item; diff --git a/core/modules/aggregator/aggregator.test b/core/modules/aggregator/aggregator.test index 522129f..381fb95 100644 --- a/core/modules/aggregator/aggregator.test +++ b/core/modules/aggregator/aggregator.test @@ -266,16 +266,10 @@ EOF; return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_atom.xml'; } - /** - * Creates sample article nodes. - * - * @param $count - * (optional) The number of nodes to generate. - */ - function createSampleNodes($count = 5) { + function createSampleNodes() { $langcode = LANGUAGE_NONE; - // Post $count article nodes. - for ($i = 0; $i < $count; $i++) { + // Post 5 articles. + for ($i = 0; $i < 5; $i++) { $edit = array(); $edit['title'] = $this->randomName(); $edit["body[$langcode][0][value]"] = $this->randomName(); @@ -844,28 +838,6 @@ class AggregatorRenderingTestCase extends AggregatorTestCase { $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->title)); $this->assertFalse(empty($correct_titles), t('Aggregator feed page is available and has the correct title.')); } - - /** - * Create a feed and check that feed's page. - */ - public function testFeedPage() { - // Increase the number of items published in the rss.xml feed so we have - // enough articles to test paging. - variable_set('feed_default_items', 30); - - // Create a feed with 30 items. - $this->createSampleNodes(30); - $feed = $this->createFeed(); - $this->updateFeedItems($feed, 30); - - // Check for the presence of a pager. - $this->drupalGet('aggregator/sources/' . $feed->fid); - $elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager')); - $this->assertTrue(!empty($elements), t('Individual source page contains a pager.')); - - // Reset the number of items in rss.xml to the default value. - variable_set('feed_default_items', 10); - } } /** @@ -915,3 +887,4 @@ class FeedParserTestCase extends AggregatorTestCase { $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', array(':link' => 'http://example.org/2003/12/13/atom03'))->fetchField(), 'Atom entry id element is parsed correctly.'); } } + diff --git a/core/modules/contextual/contextual.js b/core/modules/contextual/contextual.js index ee5b7a0..5085ea0 100644 --- a/core/modules/contextual/contextual.js +++ b/core/modules/contextual/contextual.js @@ -1,3 +1,8 @@ +/** + * @file + * Attaches behaviors for the Contextual module. + */ + (function ($) { Drupal.contextualLinks = Drupal.contextualLinks || {}; diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module index e3c0f8b..d29f68a 100644 --- a/core/modules/contextual/contextual.module +++ b/core/modules/contextual/contextual.module @@ -77,7 +77,7 @@ function contextual_element_info() { } /** - * Template variable preprocessor for contextual links. + * Implements hook_preprocess(). * * @see contextual_pre_render_links() */ @@ -114,7 +114,7 @@ function contextual_preprocess(&$variables, $hook) { } /** - * Build a renderable array for contextual links. + * Builds a renderable array for contextual links. * * @param $element * A renderable array containing a #contextual_links property, which is a diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index d0d5da9..74eae62 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -74,8 +74,8 @@ function hook_field_extra_fields() { function hook_field_extra_fields_alter(&$info) { // Force node title to always be at the top of the list by default. foreach (node_type_get_types() as $bundle) { - if (isset($info['node'][$bundle->type]['form']['title'])) { - $info['node'][$bundle->type]['form']['title']['weight'] = -20; + if (isset($info['node'][$bundle->type]['title'])) { + $info['node'][$bundle->type]['title']['weight'] = -20; } } } diff --git a/core/modules/locale/locale.admin.inc b/core/modules/locale/locale.admin.inc index 97d6b64..82397c8 100644 --- a/core/modules/locale/locale.admin.inc +++ b/core/modules/locale/locale.admin.inc @@ -278,7 +278,8 @@ function _locale_languages_common_controls(&$form, $language = NULL) { $form['langcode'] = array( '#type' => 'textfield', '#title' => t('Language code'), - '#maxlength' => 12, + '#size' => 12, + '#maxlength' => 60, '#required' => TRUE, '#default_value' => @$language->language, '#disabled' => (isset($language->language)), diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index 9ca0d6c..77da39c 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -22,10 +22,10 @@ function locale_uninstall() { $locale_js_directory = 'public://' . variable_get('locale_js_directory', 'languages'); if (is_dir($locale_js_directory)) { - $locale_javascripts = variable_get('locale_translation_javascript', array()); - foreach ($locale_javascripts as $langcode => $file_suffix) { - if (!empty($file_suffix)) { - file_unmanaged_delete($locale_js_directory . '/' . $langcode . '_' . $file_suffix . '.js'); + $files = db_query('SELECT language, javascript FROM {languages}'); + foreach ($files as $file) { + if (!empty($file->javascript)) { + file_unmanaged_delete($locale_js_directory . '/' . $file->language . '_' . $file->javascript . '.js'); } } // Delete the JavaScript translations directory if empty. @@ -47,8 +47,6 @@ function locale_uninstall() { variable_del('javascript_parsed'); variable_del('locale_field_language_fallback'); variable_del('locale_cache_length'); - variable_del('locale_translation_plurals'); - variable_del('locale_translation_javascript'); foreach (language_types() as $type) { variable_del("language_negotiation_$type"); @@ -99,6 +97,19 @@ function locale_schema() { 'default' => 0, 'description' => 'Enabled flag (1 = Enabled, 0 = Disabled).', ), + 'plurals' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Number of plural indexes in this language.', + ), + 'formula' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + 'description' => 'Plural formula in PHP code to evaluate to get plural indexes.', + ), 'domain' => array( 'type' => 'varchar', 'length' => 128, @@ -119,6 +130,13 @@ function locale_schema() { 'default' => 0, 'description' => 'Weight, used in lists of languages.', ), + 'javascript' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + 'description' => 'Location of JavaScript translation file.', + ), ), 'primary key' => array('language'), 'indexes' => array( @@ -232,32 +250,6 @@ function locale_update_8000() { } /** - * Decouple interface translation related data from language objects. - */ -function locale_update_8001() { - // Gather data from existing languages table and save in variables. - $languages = db_select('languages', 'l') - ->fields('l') - ->execute(); - $plurals = array(); - $javascript = array(); - foreach ($languages as $language) { - $plurals[$language->language] = array( - 'plurals' => $language->plurals, - 'formula' => $language->formula, - ); - $javascript[$language->language] = $language->javascript; - } - variable_set('locale_translation_plurals', $plurals); - variable_set('locale_translation_javascript', $javascript); - - // Drop now unneeded columns. - db_drop_field('languages', 'plurals'); - db_drop_field('languages', 'formula'); - db_drop_field('languages', 'javascript'); -} - -/** * @} End of "addtogroup updates-7.x-to-8.x" * The next series of updates should start at 9000. */ diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 103c284..18cf99d 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -725,18 +725,19 @@ function locale_reset() { */ function locale_get_plural($count, $langcode = NULL) { global $language; - $locale_plurals = &drupal_static(__FUNCTION__, array()); + $locale_formula = &drupal_static(__FUNCTION__, array()); $plurals = &drupal_static(__FUNCTION__ . ':plurals', array()); $langcode = $langcode ? $langcode : $language->language; if (!isset($plurals[$langcode][$count])) { - if (empty($locale_plural_formulas)) { - $locale_plurals = variable_get('locale_translation_plurals', array()); + if (empty($locale_formula)) { + $language_list = language_list(); + $locale_formula[$langcode] = $language_list[$langcode]->formula; } - if (!empty($locale_plurals[$langcode])) { + if ($locale_formula[$langcode]) { $n = $count; - $plurals[$langcode][$count] = @eval('return intval(' . $locale_plurals[$langcode]['formula'] . ');'); + $plurals[$langcode][$count] = @eval('return intval(' . $locale_formula[$langcode] . ');'); return $plurals[$langcode][$count]; } else { @@ -924,10 +925,9 @@ function locale_js_alter(&$javascript) { } // Add the translation JavaScript file to the page. - $locale_javascripts = variable_get('locale_translation_javascript', array()); - if ($files && !empty($locale_javascripts[$language->language])) { + if ($files && !empty($language->javascript)) { // Add the translation JavaScript file to the page. - $file = $dir . '/' . $language->language . '_' . $locale_javascripts[$language->language] . '.js'; + $file = $dir . '/' . $language->language . '_' . $language->javascript . '.js'; $javascript[$file] = drupal_js_defaults($file); } } diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test index 3474d78..7506242 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -483,8 +483,14 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { require_once DRUPAL_ROOT . '/core/includes/locale.inc'; _locale_rebuild_js($langcode); - $locale_javascripts = variable_get('locale_translation_javascript', array()); - $js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js'; + // Retrieve the JavaScript translation hash code for the custom language to + // check that the translation file has been properly built. + $file = db_select('languages', 'l') + ->fields('l', array('javascript')) + ->condition('language', $langcode) + ->execute() + ->fetchObject(); + $js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/' . $langcode . '_' . $file->javascript . '.js'; $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('not found')))); // Test JavaScript translation rebuilding. @@ -737,8 +743,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 9, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.')); // This import should have saved plural forms to have 2 variants. - $locale_plurals = variable_get('locale_translation_plurals', array()); - $this->assert($locale_plurals['fr']['plurals'] == 2, t('Plural number initialized.')); + $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, t('Plural number initialized.')); // Ensure we were redirected correctly. $this->assertEqual($this->getUrl(), url('admin/config/regional/translate', array('absolute' => TRUE)), t('Correct page redirection.')); @@ -784,8 +789,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { $this->assertText(t('No strings available.'), t('String not overwritten by imported string.')); // This import should not have changed number of plural forms. - $locale_plurals = variable_get('locale_translation_plurals', array()); - $this->assert($locale_plurals['fr']['plurals'] == 2, t('Plural numbers untouched.')); + $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, t('Plural numbers untouched.')); // Try importing a .po file with overriding strings, and ensure existing // strings are overwritten. @@ -805,8 +809,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { $this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter')); $this->assertNoText(t('No strings available.'), t('String overwritten by imported string.')); // This import should have changed number of plural forms. - $locale_plurals = variable_get('locale_translation_plurals', array()); - $this->assert($locale_plurals['fr']['plurals'] == 3, t('Plural numbers changed.')); + $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 3, t('Plural numbers changed.')); } /** @@ -1230,8 +1233,8 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { $edit = array('translations[fr]' => 'french translation'); $this->drupalPost('admin/config/regional/translate/edit/' . $string->lid, $edit, t('Save translations')); _locale_rebuild_js('fr'); - $locale_javascripts = variable_get('locale_translation_javascript', array()); - $js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/fr_' . $locale_javascripts['fr'] . '.js'; + $file = db_query('SELECT javascript FROM {languages} WHERE language = :language', array(':language' => 'fr'))->fetchObject(); + $js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/fr_' . $file->javascript . '.js'; $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('none')))); // Disable string caching. diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index ab0cb71..cab476e 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -230,6 +230,10 @@ function hook_node_grants($account, $op) { * of this gid within this realm can edit this node. * - 'grant_delete': If set to 1 a user that has been identified as a member * of this gid within this realm can delete this node. + * - 'priority': If multiple modules seek to set permissions on a node, the + * realms that have the highest priority will win out, and realms with a lower + * priority will not be written. If there is any doubt, it is best to + * leave this 0. * * * When an implementation is interested in a node but want to deny access to @@ -276,6 +280,7 @@ function hook_node_access_records($node) { 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0, + 'priority' => 0, ); } // For the example_author array, the GID is equivalent to a UID, which @@ -288,6 +293,7 @@ function hook_node_access_records($node) { 'grant_view' => 1, 'grant_update' => 1, 'grant_delete' => 1, + 'priority' => 0, ); return $grants; diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 81ee841..0c3cfb7 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -3333,6 +3333,16 @@ function node_access_acquire_grants($node, $delete = TRUE) { if (empty($grants) && !empty($node->status)) { $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0); } + else { + // Retain grants by highest priority. + $grant_by_priority = array(); + foreach ($grants as $g) { + $grant_by_priority[intval($g['priority'])][] = $g; + } + krsort($grant_by_priority); + $grants = array_shift($grant_by_priority); + } + _node_access_write_grants($node, $grants, NULL, $delete); } diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 4eea417..c53ba34 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -781,9 +781,6 @@ function rdf_field_attach_view_alter(&$output, $context) { * Implements MODULE_preprocess_HOOK(). */ function rdf_preprocess_image(&$variables) { - // Adds the RDF type for image. We cannot use the usual entity-based mapping - // to get 'foaf:Image' because image does not have its own entity type or - // bundle. $variables['attributes']['typeof'] = array('foaf:Image'); }