diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index e1c15fe..a45adaf 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -907,7 +907,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { } } try { - $file_list = state()->get('system.' . $type . '.files'); + $file_list = Drupal::state()->get('system.' . $type . '.files'); if ($file_list && isset($file_list[$name]) && file_exists(DRUPAL_ROOT . '/' . $file_list[$name])) { $files[$type][$name] = $file_list[$name]; } @@ -2538,21 +2538,6 @@ function module_hook($module, $hook) { } /** - * Returns the state storage service. - * - * Use this to store machine-generated data, local to a specific environment - * that does not need deploying and does not need human editing; for example, - * the last time cron was run. Data which needs to be edited by humans and - * needs to be the same across development, production, etc. environments - * (for example, the system maintenance message) should use config() instead. - * - * @return Drupal\Core\KeyValueStore\KeyValueStoreInterface - */ -function state() { - return drupal_container()->get('keyvalue')->get('state'); -} - -/** * Returns the typed data manager service. * * Use the typed data manager service for creating typed data objects. diff --git a/core/includes/common.inc b/core/includes/common.inc index 86fc44a..04b2d81 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3120,7 +3120,7 @@ function drupal_pre_render_styles($elements) { function drupal_build_css_cache($css) { $data = ''; $uri = ''; - $map = state()->get('drupal_css_cache_files') ?: array(); + $map = Drupal::state()->get('drupal_css_cache_files') ?: array(); // Create a new array so that only the file names are used to create the hash. // This prevents new aggregates from being created unnecessarily. $css_data = array(); @@ -3188,7 +3188,7 @@ function drupal_build_css_cache($css) { } // Save the updated map. $map[$key] = $uri; - state()->set('drupal_css_cache_files', $map); + Drupal::state()->set('drupal_css_cache_files', $map); } return $uri; } @@ -3353,7 +3353,7 @@ function _drupal_load_stylesheet($matches) { * Deletes old cached CSS files. */ function drupal_clear_css_cache() { - state()->delete('drupal_css_cache_files'); + Drupal::state()->delete('drupal_css_cache_files'); file_scan_directory('public://css', '/.*/', array('callback' => 'drupal_delete_file_if_stale')); } @@ -4714,7 +4714,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro function drupal_build_js_cache($files) { $contents = ''; $uri = ''; - $map = state()->get('system.js_cache_files') ?: array(); + $map = Drupal::state()->get('system.js_cache_files') ?: array(); // Create a new array so that only the file names are used to create the hash. // This prevents new aggregates from being created unnecessarily. $js_data = array(); @@ -4759,7 +4759,7 @@ function drupal_build_js_cache($files) { } } $map[$key] = $uri; - state()->set('system.js_cache_files', $map); + Drupal::state()->set('system.js_cache_files', $map); } return $uri; } @@ -4768,8 +4768,8 @@ function drupal_build_js_cache($files) { * Deletes old cached JavaScript files and variables. */ function drupal_clear_js_cache() { - state()->delete('system.javascript_parsed'); - state()->delete('system.js_cache_files'); + Drupal::state()->delete('system.javascript_parsed'); + Drupal::state()->delete('system.js_cache_files'); file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale')); } @@ -4816,9 +4816,9 @@ function drupal_get_hash_salt() { * The private key. */ function drupal_get_private_key() { - if (!($key = state()->get('system.private_key'))) { + if (!($key = Drupal::state()->get('system.private_key'))) { $key = drupal_hash_base64(drupal_random_bytes(55)); - state()->set('system.private_key', $key); + Drupal::state()->set('system.private_key', $key); } return $key; } @@ -5040,7 +5040,7 @@ function drupal_cron_run() { } // Record cron time. - state()->set('system.cron_last', REQUEST_TIME); + Drupal::state()->set('system.cron_last', REQUEST_TIME); watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE); // Release cron lock. diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index bb8f247..57d03eb 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -926,7 +926,7 @@ function install_base_system(&$install_state) { // after all the dependencies have been installed. $modules[] = drupal_get_profile(); - state()->set('install_profile_modules', array_diff($modules, array('system'))); + Drupal::state()->set('install_profile_modules', array_diff($modules, array('system'))); $install_state['database_tables_exist'] = TRUE; } @@ -1652,9 +1652,9 @@ function install_bootstrap_full() { * The batch definition. */ function install_profile_modules(&$install_state) { - $modules = state()->get('install_profile_modules') ?: array(); + $modules = Drupal::state()->get('install_profile_modules') ?: array(); $files = system_rebuild_module_data(); - state()->delete('install_profile_modules'); + Drupal::state()->delete('install_profile_modules'); // Always install required modules first. Respect the dependencies between // the modules. diff --git a/core/includes/menu.inc b/core/includes/menu.inc index e59615c..68d434c 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -327,7 +327,7 @@ function menu_get_ancestors($parts) { $ancestors = array(); $length = $number_parts - 1; $end = (1 << $number_parts) - 1; - $masks = state()->get('menu.masks'); + $masks = Drupal::state()->get('menu.masks'); // If the optimized menu.masks array is not available use brute force to get // the correct $ancestors and $placeholders returned. Do not use this as the // default value of the menu.masks variable to avoid building such a big @@ -461,7 +461,7 @@ function menu_get_item($path = NULL, $router_item = NULL) { if (!isset($router_items[$path])) { // Rebuild if we know it's needed, or if the menu masks are missing which // occurs rarely, likely due to a race condition of multiple rebuilds. - if (state()->get('menu_rebuild_needed') || !state()->get('menu.masks')) { + if (Drupal::state()->get('menu_rebuild_needed') || !Drupal::state()->get('menu.masks')) { menu_router_rebuild(); } $original_map = arg(NULL, $path); @@ -1270,7 +1270,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = } $parents = $active_trail; - $expanded = state()->get('menu_expanded'); + $expanded = Drupal::state()->get('menu_expanded'); // Check whether the current menu has any links set to be expanded. if (!$only_active_trail && $expanded && in_array($menu_name, $expanded)) { // Collect all the links set to be expanded, and then add all of @@ -2629,7 +2629,7 @@ function menu_router_rebuild() { menu_cache_clear_all(); _menu_clear_page_cache(); // Indicate that the menu has been successfully rebuilt. - state()->delete('menu_rebuild_needed'); + Drupal::state()->delete('menu_rebuild_needed'); } catch (Exception $e) { $transaction->rollback(); @@ -2909,7 +2909,7 @@ function _menu_clear_page_cache() { */ function _menu_set_expanded_menus() { $names = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name")->fetchCol(); - state()->set('menu_expanded', $names); + Drupal::state()->set('menu_expanded', $names); } /** @@ -3183,8 +3183,8 @@ function _menu_router_build($callbacks, $save = FALSE) { $path_roots = array_values($path_roots); // Update the path roots variable and reset the path alias whitelist cache // if the list has changed. - if ($path_roots != state()->get('menu_path_roots')) { - state()->set('menu_path_roots', array_values($path_roots)); + if ($path_roots != Drupal::state()->get('menu_path_roots')) { + Drupal::state()->set('menu_path_roots', array_values($path_roots)); drupal_container()->get('path.alias_manager')->cacheClear(); } _menu_router_save($menu, $masks); @@ -3270,7 +3270,7 @@ function _menu_router_save($menu, $masks) { // Insert any remaining records. $insert->execute(); // Store the masks. - state()->set('menu.masks', $masks); + Drupal::state()->set('menu.masks', $masks); return $menu; } diff --git a/core/includes/module.inc b/core/includes/module.inc index 99eac78..6b0f23c 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -47,7 +47,7 @@ function system_list($type) { // system.theme.data state will go away entirely as soon as themes have // a proper installation status. // @see http://drupal.org/node/1067408 - $theme_data = state()->get('system.theme.data'); + $theme_data = Drupal::state()->get('system.theme.data'); if (empty($theme_data)) { // @todo: system_list() may be called from _drupal_bootstrap_code(), in // which case system.module is not loaded yet. @@ -122,7 +122,7 @@ function system_list_reset() { // will cause system_list_reset() to be called, but theme data is not // necessarily rebuilt afterwards. // @todo Obsolete with proper installation status for themes. - state()->delete('system.theme.data'); + Drupal::state()->delete('system.theme.data'); } /** diff --git a/core/includes/update.inc b/core/includes/update.inc index 6aea70f..a73ec63 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -170,7 +170,7 @@ function update_prepare_d8_bootstrap() { if ($has_required_schema) { if (!db_table_exists('key_value')) { $specs = array( - 'description' => 'Generic key-value storage table. See state() for an example.', + 'description' => 'Generic key-value storage table. See the state system for an example.', 'fields' => array( 'collection' => array( 'description' => 'A named collection of key and value pairs.', @@ -468,8 +468,8 @@ function update_prepare_d8_language() { $prefixes[$language->language] = $language->prefix; $domains[$language->language] = $language->domain; } - state()->set('locale.translation.plurals', $plurals); - state()->set('locale.translation.javascript', $javascript); + Drupal::state()->set('locale.translation.plurals', $plurals); + Drupal::state()->set('locale.translation.javascript', $javascript); config('language.negotiation') ->set('url.prefixes', $prefixes) ->set('url.domains', $domains) @@ -1483,7 +1483,7 @@ function update_config_manifest_add($config_prefix, array $ids) { * Updates 7.x variables to state records. * * Provides a generalized method to migrate variables from 7.x to 8.x's - * state() system. + * Drupal::state() system. * * @param array $variable_map * An associative array that maps old variables names to new state record @@ -1498,7 +1498,7 @@ function update_config_manifest_add($config_prefix, array $ids) { function update_variables_to_state(array $variable_map) { foreach ($variable_map as $variable_name => $state_name) { if (NULL !== $value = update_variable_get($variable_name)) { - state()->set($state_name, $value); + Drupal::state()->set($state_name, $value); } } diff --git a/core/lib/Drupal/Core/Mail/VariableLog.php b/core/lib/Drupal/Core/Mail/VariableLog.php index 8302d96..c7b5201 100644 --- a/core/lib/Drupal/Core/Mail/VariableLog.php +++ b/core/lib/Drupal/Core/Mail/VariableLog.php @@ -21,9 +21,9 @@ class VariableLog extends PhpMail implements MailInterface { * Accepts an e-mail message and store it in a variable. */ public function mail(array $message) { - $captured_emails = state()->get('system.test_email_collector') ?: array(); + $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $captured_emails[] = $message; - state()->set('system.test_email_collector', $captured_emails); + \Drupal::state()->set('system.test_email_collector', $captured_emails); return TRUE; } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php index e9aac8c..36fcd05 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php @@ -25,7 +25,7 @@ public static function getInfo() { public function testCron() { // Create feed and test basic updating on cron. global $base_url; - $key = state()->get('system.cron_key'); + $key = \Drupal::state()->get('system.cron_key'); $this->createSampleNodes(); $feed = $this->createFeed(); $this->cronRun(); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php index 96f9343..a5738ac 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php @@ -61,7 +61,7 @@ function testCachePerRole() { // Enable our test block. Set some content for it to display. $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalLogin($this->normal_user); $this->drupalGet(''); $this->assertText($current_content, 'Block content displays.'); @@ -69,7 +69,7 @@ function testCachePerRole() { // Change the content, but the cached copy should still be served. $old_content = $current_content; $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet(''); $this->assertText($old_content, 'Block is served from the cache.'); @@ -82,7 +82,7 @@ function testCachePerRole() { // Test whether the cached data is served for the correct users. $old_content = $current_content; $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalLogout(); $this->drupalGet(''); $this->assertNoText($old_content, 'Anonymous user does not see content cached per-role for normal user.'); @@ -106,14 +106,14 @@ function testCachePerRole() { function testCacheGlobal() { $this->setCacheMode(DRUPAL_CACHE_GLOBAL); $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet(''); $this->assertText($current_content, 'Block content displays.'); $old_content = $current_content; $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalLogout(); $this->drupalGet('user'); @@ -126,7 +126,7 @@ function testCacheGlobal() { function testNoCache() { $this->setCacheMode(DRUPAL_NO_CACHE); $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); // If DRUPAL_NO_CACHE has no effect, the next request would be cached. $this->drupalGet(''); @@ -134,7 +134,7 @@ function testNoCache() { // A cached copy should not be served. $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet(''); $this->assertText($current_content, 'DRUPAL_NO_CACHE prevents blocks from being cached.'); } @@ -145,7 +145,7 @@ function testNoCache() { function testCachePerUser() { $this->setCacheMode(DRUPAL_CACHE_PER_USER); $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalLogin($this->normal_user); $this->drupalGet(''); @@ -153,7 +153,7 @@ function testCachePerUser() { $old_content = $current_content; $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet(''); $this->assertText($old_content, 'Block is served from per-user cache.'); @@ -173,14 +173,14 @@ function testCachePerUser() { function testCachePerPage() { $this->setCacheMode(DRUPAL_CACHE_PER_PAGE); $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet('node'); $this->assertText($current_content, 'Block content displays on the node page.'); $old_content = $current_content; $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet('user'); $this->assertNoText($old_content, 'Block content cached for the node page does not show up for the user page.'); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php index ed2f280..31bce89 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php @@ -36,7 +36,7 @@ function setUp() { // Make sure the block has some content so it will appear. $current_content = $this->randomName(); - state()->set('block_test.content', $current_content); + \Drupal::state()->set('block_test.content', $current_content); // Enable our test blocks. $this->drupalPlaceBlock('system_menu_block:menu-tools'); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php index b04f9fc..4f1bfd3 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php @@ -42,7 +42,7 @@ protected function setUp() { * Test XSS in title. */ function testXSSInTitle() { - state()->set('block_test.content', $this->randomName()); + \Drupal::state()->set('block_test.content', $this->randomName()); $this->drupalGet(''); $this->assertNoRaw('', 'The block title was properly sanitized when rendered.'); diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php index dd7a423..a1673d2 100644 --- a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php +++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php @@ -38,7 +38,7 @@ public function settings() { */ public function build() { return array( - '#children' => state()->get('block_test.content'), + '#children' => \Drupal::state()->get('block_test.content'), ); } diff --git a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php index 9ddd06a..7dcfb1b 100644 --- a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php +++ b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php @@ -110,7 +110,7 @@ function _testColor($theme, $test_values) { $config->set('css.preprocess', 1); $config->save(); $this->drupalGet(''); - $stylesheets = state()->get('drupal_css_cache_files') ?: array(); + $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array(); $stylesheet_content = ''; foreach ($stylesheets as $key => $uri) { $stylesheet_content .= join("\n", file(drupal_realpath($uri))); diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 48bb5a4..bc6673c 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -29,7 +29,7 @@ function comment_uninstall() { } // Remove states. - state()->delete('comment.node_comment_statistics_scale'); + Drupal::state()->delete('comment.node_comment_statistics_scale'); } /** diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index dd87b29..25635f0 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1279,7 +1279,7 @@ function comment_node_update_index(EntityInterface $node, $langcode) { */ function comment_update_index() { // Store the maximum possible comments per thread (used for ranking by reply count) - state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField())); + Drupal::state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField())); } /** @@ -2006,7 +2006,7 @@ function comment_ranking() { ), // Inverse law that maps the highest reply count on the site to 1 and 0 to 0. 'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))', - 'arguments' => array(':scale' => state()->get('comment.node_comment_statistics_scale') ?: 0), + 'arguments' => array(':scale' => Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0), ), ); } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php index 35a935e..3aecf3a 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php @@ -51,7 +51,7 @@ function setUp() { $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); // Enable content language negotiation UI. - state()->set('language_test.content_language_type', TRUE); + \Drupal::state()->set('language_test.content_language_type', TRUE); // Set interface language detection to user and content language detection // to URL. Disable inheritance from interface language to ensure content diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index f851cbc..7677fa7 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -146,7 +146,7 @@ function testListUI() { $this->drupalPost(NULL, $edit, t('Save')); // Ensure that the entity's sort method was called. - $this->assertTrue(state()->get('config_entity_sort'), 'ConfigTest::sort() was called.'); + $this->assertTrue(\Drupal::state()->get('config_entity_sort'), 'ConfigTest::sort() was called.'); // Confirm that the user is returned to the listing, and verify that the // text of the label and machine name appears in the list (versus elsewhere diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index 90ae934..5792200 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -189,7 +189,7 @@ function testCRUD() { } // Test config entity prepopulation. - state()->set('config_test.prepopulate', TRUE); + \Drupal::state()->set('config_test.prepopulate', TRUE); $config_test = entity_create('config_test', array('foo' => 'bar')); $this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated'); } diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 34c28ea..371bfb0 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -152,7 +152,7 @@ function config_test_cache_flush() { * Implements hook_ENTITY_TYPE_create(). */ function config_test_config_test_create(ConfigTest $config_test) { - if (state()->get('config_test.prepopulate')) { + if (Drupal::state()->get('config_test.prepopulate')) { $config_test->set('foo', 'baz'); } } diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php index 28b22cc..544c0e8 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php @@ -88,7 +88,7 @@ public function getExportProperties() { * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort(). */ public static function sort($a, $b) { - state()->set('config_entity_sort', TRUE); + \Drupal::state()->set('config_entity_sort', TRUE); return parent::sort($a, $b); } diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php index 567db78..daa6a8d 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php @@ -114,7 +114,7 @@ function testManager() { // Case 4: a text editor available associated, but now with its JS settings // being altered via hook_editor_js_settings_alter(). - state()->set('editor_test_js_settings_alter_enabled', TRUE); + \Drupal::state()->set('editor_test_js_settings_alter_enabled', TRUE); $expected['js'][0]['data']['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE; $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'hook_editor_js_settings_alter() works correctly.'); } diff --git a/core/modules/editor/tests/modules/editor_test.module b/core/modules/editor/tests/modules/editor_test.module index b638394..cdaf52e 100644 --- a/core/modules/editor/tests/modules/editor_test.module +++ b/core/modules/editor/tests/modules/editor_test.module @@ -31,7 +31,7 @@ function editor_test_editor_default_settings_alter(&$settings, $editor) { */ function editor_test_editor_js_settings_alter(&$settings) { // Allow tests to enable or disable this alter hook. - if (!state()->get('editor_test_js_settings_alter_enabled', FALSE)) { + if (!Drupal::state()->get('editor_test_js_settings_alter_enabled', FALSE)) { return; } diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 1cf252d..608a546 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -1173,7 +1173,7 @@ function hook_field_available_languages_alter(&$langcodes, $context) { function hook_field_attach_create_bundle($entity_type, $bundle) { // When a new bundle is created, the menu needs to be rebuilt to add the // Field UI menu item tabs. - state()->set('menu_rebuild_needed', TRUE); + \Drupal::state()->set('menu_rebuild_needed', TRUE); } /** diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 69102f4..580084f 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -797,7 +797,7 @@ function _field_invoke_widget_target() { * @endcode * * Additionally, some processing data is placed in $form_state, and can be - * accessed by field_form_get_state() and field_form_set_state(). + * accessed by field_form_get_Drupal::state() and field_form_set_Drupal::state(). * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity for which to load form elements, used to initialize @@ -817,8 +817,8 @@ function _field_invoke_widget_target() { * An associative array of additional options. See field_invoke_method() for * details. * - * @see field_form_get_state() - * @see field_form_set_state() + * @see field_form_get_Drupal::state() + * @see field_form_set_Drupal::state() */ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langcode = NULL, array $options = array()) { // Set #parents to 'top-level' by default. diff --git a/core/modules/field/field.form.inc b/core/modules/field/field.form.inc index 203a112..4bccf60 100644 --- a/core/modules/field/field.form.inc +++ b/core/modules/field/field.form.inc @@ -193,7 +193,7 @@ function field_add_more_js($form, $form_state) { * - errors: The array of field validation errors reported on the field. This * entry is populated at field_attach_form_validate() time. * - * @see field_form_set_state() + * @see field_form_set_Drupal::state() */ function field_form_get_state($parents, $field_name, $langcode, &$form_state) { $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode); @@ -212,10 +212,10 @@ function field_form_get_state($parents, $field_name, $langcode, &$form_state) { * @param $form_state * The form state. * @param $field_state - * The array of data to store. See field_form_get_state() for the structure + * The array of data to store. See field_form_get_Drupal::state() for the structure * and content of the array. * - * @see field_form_get_state() + * @see field_form_get_Drupal::state() */ function field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state) { $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index f9a1031..5ea2737 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -342,7 +342,7 @@ function testFieldInfoCache() { // field_test_entity_info(). Ensure the test field is still in the returned // array. field_info_cache_clear(); - state()->set('field_test.clear_info_cache_in_hook_entity_info', TRUE); + \Drupal::state()->set('field_test.clear_info_cache_in_hook_entity_info', TRUE); $fields = field_info_fields(); $this->assertTrue(isset($fields[$field_name]), 'The test field is found in the array returned by field_info_fields() even if its cache is cleared while being rebuilt.'); } diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 609d70f..111f6d8 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -82,7 +82,7 @@ function testFieldAvailableLanguages() { field_test_entity_info_translatable('test_entity', TRUE); // Test hook_field_languages() invocation on a translatable field. - state()->set('field_test.field_available_languages_alter', TRUE); + \Drupal::state()->set('field_test.field_available_languages_alter', TRUE); $langcodes = field_content_languages(); $available_langcodes = field_available_languages($this->entity_type, $this->field); foreach ($available_langcodes as $delta => $langcode) { @@ -380,7 +380,7 @@ function testFieldDisplayLanguage() { $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_langcode, format_string('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); // Test field_language() basic behavior without language fallback. - state()->set('field_test.language_fallback', FALSE); + \Drupal::state()->set('field_test.language_fallback', FALSE); $entity->{$this->field_name}[$requested_langcode] = mt_rand(1, 127); drupal_static_reset('field_language'); $display_langcode = field_language($entity, $this->field_name, $requested_langcode); diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index 5f08460..0c823a4 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -14,7 +14,7 @@ function field_test_entity_info() { // If requested, clear the field cache while this is being called. See // Drupal\field\Tests\FieldInfoTest::testFieldInfoCache(). - if (state()->get('field_test.clear_info_cache_in_hook_entity_info')) { + if (Drupal::state()->get('field_test.clear_info_cache_in_hook_entity_info')) { field_info_cache_clear(); } } @@ -56,7 +56,7 @@ function field_test_entity_bundle_info_alter(&$bundles) { $entity_info = entity_get_info(); foreach ($bundles as $entity_type => $info) { if ($entity_info[$entity_type]['module'] == 'field_test') { - $bundles[$entity_type] = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); + $bundles[$entity_type] = Drupal::state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); if ($entity_type == 'test_entity_bundle') { $bundles[$entity_type] += array('test_entity_2' => array('label' => 'Test entity 2')); } @@ -90,9 +90,9 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable * name will be used. */ function field_test_create_bundle($bundle, $text = NULL) { - $bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); + $bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); $bundles += array($bundle => array('label' => $text ? $text : $bundle)); - state()->set('field_test.bundles', $bundles); + Drupal::state()->set('field_test.bundles', $bundles); $info = entity_get_info(); foreach ($info as $type => $type_info) { @@ -111,10 +111,10 @@ function field_test_create_bundle($bundle, $text = NULL) { * The new machine-readable name of the bundle. */ function field_test_rename_bundle($bundle_old, $bundle_new) { - $bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); + $bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); $bundles[$bundle_new] = $bundles[$bundle_old]; unset($bundles[$bundle_old]); - state()->set('field_test.bundles', $bundles); + Drupal::state()->set('field_test.bundles', $bundles); $info = entity_get_info(); foreach ($info as $type => $type_info) { @@ -131,9 +131,9 @@ function field_test_rename_bundle($bundle_old, $bundle_new) { * The machine-readable name of the bundle to delete. */ function field_test_delete_bundle($bundle) { - $bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); + $bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); unset($bundles[$bundle]); - state()->set('field_test.bundles', $bundles); + Drupal::state()->set('field_test.bundles', $bundles); $info = entity_get_info(); foreach ($info as $type => $type_info) { diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 4ecd1a9..352a29d 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -106,7 +106,7 @@ function field_test_field_test_op_multiple($entity_type, $entities, $field, $ins * Implements hook_field_available_languages_alter(). */ function field_test_field_available_languages_alter(&$langcodes, $context) { - if (state()->get('field_test.field_available_languages_alter')) { + if (Drupal::state()->get('field_test.field_available_languages_alter')) { // Add an unavailable language code. $langcodes[] = 'xx'; // Remove an available language code. @@ -119,7 +119,7 @@ function field_test_field_available_languages_alter(&$langcodes, $context) { * Implements hook_field_language_alter(). */ function field_test_field_language_alter(&$display_langcode, $context) { - if (state()->get('field_test.language_fallback') ?: TRUE) { + if (Drupal::state()->get('field_test.language_fallback') ?: TRUE) { field_language_fallback($display_langcode, $context['entity'], $context['langcode']); } } diff --git a/core/modules/field/tests/modules/field_test/field_test.storage.inc b/core/modules/field/tests/modules/field_test/field_test.storage.inc index a53b941..31073ff 100644 --- a/core/modules/field/tests/modules/field_test/field_test.storage.inc +++ b/core/modules/field/tests/modules/field_test/field_test.storage.inc @@ -71,10 +71,10 @@ function field_test_field_storage_details_alter(&$details, $field) { */ function _field_test_storage_data($data = NULL) { if (!isset($data)) { - return state()->get('field_test.storage_data'); + return Drupal::state()->get('field_test.storage_data'); } else { - state()->set('field_test.storage_data', $data); + Drupal::state()->set('field_test.storage_data', $data); } } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 9f64f5f..2204846 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -327,7 +327,7 @@ function field_ui_element_info() { function field_ui_field_attach_create_bundle($entity_type, $bundle) { // When a new bundle is created, the menu needs to be rebuilt to add our // menu item tabs. - state()->set('menu_rebuild_needed', TRUE); + Drupal::state()->set('menu_rebuild_needed', TRUE); } /** diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php index 42c0b09..faa0525 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php @@ -30,7 +30,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); node_access_rebuild(); - state()->set('node_access_test.private', TRUE); + \Drupal::state()->set('node_access_test.private', TRUE); } /** diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index 1d924de..bb1b50c 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -158,14 +158,14 @@ function file_test_reset() { 'move' => array(), 'delete' => array(), ); - state()->set('file_test.results', $results); + Drupal::state()->set('file_test.results', $results); // These hooks will return these values, see file_test_set_return(). $return = array( 'validate' => array(), 'download' => NULL, ); - state()->set('file_test.return', $return); + Drupal::state()->set('file_test.return', $return); } /** @@ -183,7 +183,7 @@ function file_test_reset() { * @see file_test_reset() */ function file_test_get_calls($op) { - $results = state()->get('file_test.results') ?: array(); + $results = Drupal::state()->get('file_test.results') ?: array(); return $results[$op]; } @@ -196,7 +196,7 @@ function file_test_get_calls($op) { * passed to each call. */ function file_test_get_all_calls() { - return state()->get('file_test.results') ?: array(); + return Drupal::state()->get('file_test.results') ?: array(); } /** @@ -212,9 +212,9 @@ function file_test_get_all_calls() { * @see file_test_reset() */ function _file_test_log_call($op, $args) { - $results = state()->get('file_test.results') ?: array(); + $results = Drupal::state()->get('file_test.results') ?: array(); $results[$op][] = $args; - state()->set('file_test.results', $results); + Drupal::state()->set('file_test.results', $results); } /** @@ -230,7 +230,7 @@ function _file_test_log_call($op, $args) { * @see file_test_reset() */ function _file_test_get_return($op) { - $return = state()->get('file_test.return') ?: array($op => NULL); + $return = Drupal::state()->get('file_test.return') ?: array($op => NULL); return $return[$op]; } @@ -246,9 +246,9 @@ function _file_test_get_return($op) { * @see file_test_reset() */ function file_test_set_return($op, $value) { - $return = state()->get('file_test.return') ?: array(); + $return = Drupal::state()->get('file_test.return') ?: array(); $return[$op] = $value; - state()->set('file_test.return', $return); + Drupal::state()->set('file_test.return', $return); } /** @@ -320,7 +320,7 @@ function file_test_file_predelete(File $file) { function file_test_file_url_alter(&$uri) { // Only run this hook when this variable is set. Otherwise, we'd have to add // another hidden test module just for this hook. - $alter_mode = state()->get('file_test.hook_file_url_alter'); + $alter_mode = Drupal::state()->get('file_test.hook_file_url_alter'); if (!$alter_mode) { return; } diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php index bc145b0..b39b1ad 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php @@ -36,7 +36,7 @@ public static function getInfo() { function setUp() { parent::setUp(); node_access_rebuild(); - state()->set('node_access_test.private', TRUE); + \Drupal::state()->set('node_access_test.private', TRUE); } /** diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 7be1abd..80b77ed 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -276,7 +276,7 @@ function image_form_system_file_system_settings_alter(&$form, &$form_state) { */ function image_system_file_system_settings_submit($form, &$form_state) { if ($form['file_public_path']['#default_value'] !== $form_state['values']['file_public_path']) { - state()->set('menu_rebuild_needed', TRUE); + Drupal::state()->set('menu_rebuild_needed', TRUE); } } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php index 07ea3fb..53abe9e 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php @@ -113,7 +113,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA $original_uri = file_unmanaged_copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME); // Let the image_module_test module know about this file, so it can claim // ownership in hook_file_download(). - state()->set('image.test_file_download', $original_uri); + \Drupal::state()->set('image.test_file_download', $original_uri); $this->assertNotIdentical(FALSE, $original_uri, 'Created the generated image file.'); // Get the URL of a file that has not been generated and try to create it. @@ -160,7 +160,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA // Make sure that access is denied for existing style files if we do not // have access. - state()->delete('image.test_file_download'); + \Drupal::state()->delete('image.test_file_download'); $this->drupalGet($generate_url); $this->assertResponse(403, 'Confirmed that access is denied for the private image style.'); diff --git a/core/modules/image/tests/image_module_test.module b/core/modules/image/tests/image_module_test.module index 2cb078e..7cc6cdd 100644 --- a/core/modules/image/tests/image_module_test.module +++ b/core/modules/image/tests/image_module_test.module @@ -6,7 +6,7 @@ */ function image_module_test_file_download($uri) { - $default_uri = state()->get('image.test_file_download') ?: FALSE; + $default_uri = Drupal::state()->get('image.test_file_download') ?: FALSE; if ($default_uri == $uri) { return array('X-Image-Owned-By' => 'image_module_test'); } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index 8aea763..ab83207 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -42,8 +42,8 @@ function setUp() { */ function testInfoAlterations() { // Enable language type/negotiation info alterations. - state()->set('language_test.language_types', TRUE); - state()->set('language_test.language_negotiation_info', TRUE); + \Drupal::state()->set('language_test.language_types', TRUE); + \Drupal::state()->set('language_test.language_negotiation_info', TRUE); $this->languageNegotiationUpdate(); // Check that fixed language types are properly configured without the need @@ -52,7 +52,7 @@ function testInfoAlterations() { // Make the content language type configurable by updating the language // negotiation settings with the proper flag enabled. - state()->set('language_test.content_language_type', TRUE); + \Drupal::state()->set('language_test.content_language_type', TRUE); $this->languageNegotiationUpdate(); $type = LANGUAGE_TYPE_CONTENT; $language_types = variable_get('language_types', language_types_get_default()); @@ -73,7 +73,7 @@ function testInfoAlterations() { // Remove the interface language negotiation method by updating the language // negotiation settings with the proper flag enabled. - state()->set('language_test.language_negotiation_info_alter', TRUE); + \Drupal::state()->set('language_test.language_negotiation_info_alter', TRUE); $this->languageNegotiationUpdate(); $negotiation = variable_get("language_negotiation_$type", array()); $this->assertFalse(isset($negotiation[$interface_method_id]), 'Interface language negotiation method removed from the stored settings.'); @@ -93,7 +93,7 @@ function testInfoAlterations() { // Check language negotiation results. $this->drupalGet(''); - $last = state()->get('language_test.language_negotiation_last'); + $last = \Drupal::state()->get('language_test.language_negotiation_last'); foreach (language_types_get_all() as $type) { $langcode = $last[$type]; $value = $type == LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index e614da2..e8c6aaa 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -368,7 +368,7 @@ protected function runTest($test) { ->save(); } if (!empty($test['language_test_domain'])) { - state()->set('language_test.domain', $test['language_test_domain']); + \Drupal::state()->set('language_test.domain', $test['language_test_domain']); } $this->container->get('language_manager')->reset(); $this->drupalGet($test['path'], array(), $test['http_header']); diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index cb97937..e191c41 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -22,7 +22,7 @@ function language_test_init() { * Implements hook_language_types_info(). */ function language_test_language_types_info() { - if (state()->get('language_test.language_types')) { + if (Drupal::state()->get('language_test.language_types')) { return array( 'test_language_type' => array( 'name' => t('Test'), @@ -39,7 +39,7 @@ function language_test_language_types_info() { * Implements hook_language_types_info_alter(). */ function language_test_language_types_info_alter(array &$language_types) { - if (state()->get('language_test.content_language_type')) { + if (Drupal::state()->get('language_test.content_language_type')) { unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']); } } @@ -48,7 +48,7 @@ function language_test_language_types_info_alter(array &$language_types) { * Implements hook_language_negotiation_info(). */ function language_test_language_negotiation_info() { - if (state()->get('language_test.language_negotiation_info')) { + if (Drupal::state()->get('language_test.language_negotiation_info')) { $info = array( 'callbacks' => array( 'negotiation' => 'language_test_language_negotiation_method', @@ -75,7 +75,7 @@ function language_test_language_negotiation_info() { * Implements hook_language_negotiation_info_alter(). */ function language_test_language_negotiation_info_alter(array &$negotiation_info) { - if (state()->get('language_test.language_negotiation_info_alter')) { + if (Drupal::state()->get('language_test.language_negotiation_info_alter')) { unset($negotiation_info[LANGUAGE_NEGOTIATION_INTERFACE]); } } @@ -88,7 +88,7 @@ function language_test_store_language_negotiation() { foreach (language_types_get_all() as $type) { $last[$type] = language($type)->langcode; } - state()->set('language_test.language_negotiation_last', $last); + Drupal::state()->set('language_test.language_negotiation_last', $last); } /** diff --git a/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php b/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php index aa32076..991755e 100644 --- a/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php +++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php @@ -19,7 +19,7 @@ class LanguageTestManager extends LanguageManager { * Overrides \Drupal\Core\Language\LanguageManager::init(). */ public function init() { - if ($test_domain = state()->get('language_test.domain')) { + if ($test_domain = \Drupal::state()->get('language_test.domain')) { $_SERVER['HTTP_HOST'] = $test_domain; } return parent::init(); diff --git a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php index 618b419..4fd01b7 100644 --- a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php +++ b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php @@ -155,7 +155,7 @@ function getHeader() { function setHeader(PoHeader $header) { $this->_header = $header; $config = config('locale.settings'); - $locale_plurals = state()->get('locale.translation.plurals') ?: array(); + $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); // Check for options. $options = $this->getOptions(); @@ -179,7 +179,7 @@ function setHeader(PoHeader $header) { 'plurals' => $nplurals, 'formula' => $formula, ); - state()->set('locale.translation.plurals', $locale_plurals); + \Drupal::state()->set('locale.translation.plurals', $locale_plurals); } } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 06269ab..6353ef6 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -61,7 +61,7 @@ function testStandalonePoFile() { $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 8, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.')); // This import should have saved plural forms to have 2 variants. - $locale_plurals = state()->get('locale.translation.plurals') ?: array(); + $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); $this->assert($locale_plurals['fr']['plurals'] == 2, t('Plural number initialized.')); // Ensure we were redirected correctly. @@ -115,7 +115,7 @@ function testStandalonePoFile() { $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 = state()->get('locale.translation.plurals') ?: array(); + $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); $this->assert($locale_plurals['fr']['plurals'] == 2, t('Plural numbers untouched.')); // Try importing a .po file with overriding strings, and ensure existing @@ -136,7 +136,7 @@ function testStandalonePoFile() { $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 = state()->get('locale.translation.plurals') ?: array(); + $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); $this->assert($locale_plurals['fr']['plurals'] == 3, t('Plural numbers changed.')); // Importing a .po file and mark its strings as customized strings. diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php index f1c44dc..214fc08 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php @@ -259,7 +259,7 @@ function testJavaScriptTranslation() { // Trigger JavaScript translation parsing and building. _locale_rebuild_js($langcode); - $locale_javascripts = state()->get('locale.translation.javascript') ?: array(); + $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array(); $js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js'; $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('not found')))); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php index ee2b0c3..ec231c7 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php @@ -81,7 +81,7 @@ function testUninstallProcess() { $this->drupalPost('admin/config/regional/translate', $edit, t('Save translations')); _locale_rebuild_js('fr'); $config = config('locale.settings'); - $locale_javascripts = state()->get('locale.translation.javascript') ?: array(); + $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array(); $js_file = 'public://' . $config->get('javascript.directory') . '/fr_' . $locale_javascripts['fr'] . '.js'; $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('none')))); @@ -133,7 +133,7 @@ function testUninstallProcess() { $this->assertFalse(config('language.negotiation')->get('session.parameter'), t('Visit language negotiation method settings cleared.')); // Check JavaScript parsed. - $javascript_parsed_count = count(state()->get('system.javascript_parsed') ?: array()); + $javascript_parsed_count = count(\Drupal::state()->get('system.javascript_parsed') ?: array()); $this->assertEqual($javascript_parsed_count, 0, t('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count))); } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php index 836ee97..3c9d390 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php @@ -59,9 +59,9 @@ function testInterface() { // Drupal core is probably in 8.x, but tests may also be executed with // stable releases. As this is an uncontrolled factor in the test, we will // ignore Drupal core here and continue with the prepared modules. - $status = state()->get('locale.translation_status'); + $status = \Drupal::state()->get('locale.translation_status'); unset($status['drupal']); - state()->set('locale.translation_status', $status); + \Drupal::state()->set('locale.translation_status', $status); // One language added, all translations up to date. $this->drupalGet('admin/reports/status'); @@ -71,9 +71,9 @@ function testInterface() { $this->assertText(t('All translations up to date.'), 'Translations up to date'); // Set locale_test_translate module to have a local translation available. - $status = state()->get('locale.translation_status'); + $status = \Drupal::state()->get('locale.translation_status'); $status['locale_test_translate']['de']->type = 'local'; - state()->set('locale.translation_status', $status); + \Drupal::state()->set('locale.translation_status', $status); // Check if updates are available for German. $this->drupalGet('admin/reports/status'); @@ -84,10 +84,10 @@ function testInterface() { // Set locale_test_translate module to have a dev release and no // translation found. - $status = state()->get('locale.translation_status'); + $status = \Drupal::state()->get('locale.translation_status'); $status['locale_test_translate']['de']->version = '1.3-dev'; unset($status['locale_test_translate']['de']->type); - state()->set('locale.translation_status', $status); + \Drupal::state()->set('locale.translation_status', $status); // Check if no updates were found. $this->drupalGet('admin/reports/status'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php index e5dccbd..53a4c03 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php @@ -185,7 +185,7 @@ private function setTranslationFiles() { // A flag is set to let the locale_test module replace the project data with // a set of test projects which match the below project files. - state()->set('locale.test_projects_alter', TRUE); + \Drupal::state()->set('locale.test_projects_alter', TRUE); // Setup the environment. $public_path = variable_get('file_public_path', conf_path() . '/files'); @@ -314,7 +314,7 @@ function testUpdateProjects() { // Make the test modules look like a normal custom module. i.e. make the // modules not hidden. locale_test_system_info_alter() modifies the project // info of the locale_test and locale_test_translate modules. - state()->set('locale.test_system_info_alter', TRUE); + \Drupal::state()->set('locale.test_system_info_alter', TRUE); $this->resetAll(); // Check if interface translation data is collected from hook_info. @@ -332,7 +332,7 @@ function testUpdateProjectsHidden() { $config = config('locale.settings'); // Make the test modules look like a normal custom module. - state()->set('locale.test_system_info_alter', TRUE); + \Drupal::state()->set('locale.test_system_info_alter', TRUE); $this->resetAll(); // Set test condition: include disabled modules when building a project list. @@ -364,7 +364,7 @@ function testUpdateCheckStatus() { $config = config('locale.settings'); // Set a flag to let the locale_test module replace the project data with a // set of test projects. - state()->set('locale.test_projects_alter', TRUE); + \Drupal::state()->set('locale.test_projects_alter', TRUE); // Create local and remote translations files. $this->setTranslationFiles(); @@ -378,7 +378,7 @@ function testUpdateCheckStatus() { // Get status of translation sources at local file system. $this->drupalGet('admin/reports/translations/check'); - $result = state()->get('locale.translation_status'); + $result = \Drupal::state()->get('locale.translation_status'); $this->assertEqual($result['contrib_module_one']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_one found'); $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_old, 'Translation timestamp found'); $this->assertEqual($result['contrib_module_two']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_two found'); @@ -394,7 +394,7 @@ function testUpdateCheckStatus() { // Get status of translation sources at both local and remote locations. $this->drupalGet('admin/reports/translations/check'); - $result = state()->get('locale.translation_status'); + $result = \Drupal::state()->get('locale.translation_status'); $this->assertEqual($result['contrib_module_one']['de']->type, 'remote', 'Translation of contrib_module_one found'); $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found'); $this->assertEqual($result['contrib_module_two']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_two found'); @@ -442,7 +442,7 @@ function testUpdateImportSourceRemote() { $this->drupalPost('admin/reports/translations', array(), t('Update translations')); // Check if the translation has been updated, using the status cache. - $status = state()->get('locale.translation_status'); + $status = \Drupal::state()->get('locale.translation_status'); $this->assertEqual($status['contrib_module_one']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_one found'); $this->assertEqual($status['contrib_module_two']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_two found'); $this->assertEqual($status['contrib_module_three']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_three found'); @@ -497,7 +497,7 @@ function testUpdateImportSourceLocal() { $this->drupalPost('admin/reports/translations', array(), t('Update translations')); // Check if the translation has been updated, using the status cache. - $status = state()->get('locale.translation_status'); + $status = \Drupal::state()->get('locale.translation_status'); $this->assertEqual($status['contrib_module_one']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_one found'); $this->assertEqual($status['contrib_module_two']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_two found'); $this->assertEqual($status['contrib_module_three']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_three found'); @@ -553,7 +553,7 @@ function testUpdateImportWithoutDirectory() { $this->drupalPost('admin/reports/translations', array(), t('Update translations')); // Check if the translation has been updated, using the status cache. - $status = state()->get('locale.translation_status'); + $status = \Drupal::state()->get('locale.translation_status'); $this->assertEqual($status['contrib_module_one']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_one found'); $this->assertEqual($status['contrib_module_two']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_two found'); $this->assertEqual($status['contrib_module_three']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_three found'); @@ -660,7 +660,7 @@ function testUpdateImportModeNone() { */ function testEnableDisableModule() { // Make the hidden test modules look like a normal custom module. - state()->set('locale.test_system_info_alter', TRUE); + \Drupal::state()->set('locale.test_system_info_alter', TRUE); // Check if there is no translation yet. $this->assertTranslation('Tuesday', '', 'de'); @@ -703,7 +703,7 @@ function testEnableDisableModule() { */ function testEnableDisableLanguage() { // Make the hidden test modules look like a normal custom module. - state()->set('locale.test_system_info_alter', TRUE); + \Drupal::state()->set('locale.test_system_info_alter', TRUE); // Enable a module. $edit = array( @@ -747,7 +747,7 @@ function testEnableDisableLanguage() { */ function testEnableCustomLanguage() { // Make the hidden test modules look like a normal custom module. - state()->set('locale.test_system_info_alter', TRUE); + \Drupal::state()->set('locale.test_system_info_alter', TRUE); // Enable a module. $edit = array( diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index 9eba52e..4176c99 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -19,7 +19,7 @@ */ function locale_translation_flush_projects() { // Followup issue: http://drupal.org/node/1842362 - // Replace {locale_project} table by state() variable(s). + // Replace {locale_project} table by Drupal::state() variable(s). db_truncate('locale_project')->execute(); } diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index 0bcf093..d230570 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -26,7 +26,7 @@ function locale_uninstall() { $locale_js_directory = 'public://' . $config->get('javascript.directory'); if (is_dir($locale_js_directory)) { - $locale_javascripts = state()->get('locale.translation.javascript') ?: array(); + $locale_javascripts = Drupal::state()->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'); @@ -39,9 +39,9 @@ function locale_uninstall() { } // Clear variables. - state()->delete('system.javascript_parsed'); - state()->delete('locale.translation.plurals'); - state()->delete('locale.translation.javascript'); + Drupal::state()->delete('system.javascript_parsed'); + Drupal::state()->delete('locale.translation.plurals'); + Drupal::state()->delete('locale.translation.javascript'); // Remove all node type language variables. Node module might have been // enabled, but may be disabled, so use a wildcard delete. @@ -295,7 +295,7 @@ function locale_requirements($phase) { if ($languages) { // Determine the status of the translation updates per lanuage. - $status = state()->get('locale.translation_status'); + $status = Drupal::state()->get('locale.translation_status'); if ($status) { foreach ($status as $project_id => $project) { foreach ($project as $langcode => $project_info) { diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 880e335..acbac82 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -445,7 +445,7 @@ function locale_get_plural($count, $langcode = NULL) { if (!isset($plural_indexes[$langcode][$count])) { // Retrieve and statically cache the plural formulas for all languages. if (empty($plural_formulas)) { - $plural_formulas = state()->get('locale.translation.plurals') ?: array(); + $plural_formulas = Drupal::state()->get('locale.translation.plurals') ?: array(); } // If there is a plural formula for the language, evaluate it for the given // $count and statically cache the result for the combination of language @@ -583,7 +583,7 @@ function locale_js_alter(&$javascript) { $language_interface = language(LANGUAGE_TYPE_INTERFACE); $dir = 'public://' . config('local.settings')->get('javascript.directory'); - $parsed = state()->get('system.javascript_parsed') ?: array(); + $parsed = Drupal::state()->get('system.javascript_parsed') ?: array(); $files = $new_files = FALSE; foreach ($javascript as $item) { @@ -616,16 +616,16 @@ function locale_js_alter(&$javascript) { unset($parsed['refresh:' . $language_interface->langcode]); } // Store any changes after refresh was attempted. - state()->set('system.javascript_parsed', $parsed); + Drupal::state()->set('system.javascript_parsed', $parsed); } // If no refresh was attempted, but we have new source files, we need // to store them too. This occurs if current page is in English. elseif ($new_files) { - state()->set('system.javascript_parsed', $parsed); + Drupal::state()->set('system.javascript_parsed', $parsed); } // Add the translation JavaScript file to the page. - $locale_javascripts = state()->get('translation.javascript') ?: array(); + $locale_javascripts = Drupal::state()->get('translation.javascript') ?: array(); if ($files && !empty($locale_javascripts[$language_interface->langcode])) { // Add the translation JavaScript file to the page. $file = $dir . '/' . $language_interface->langcode . '_' . $locale_javascripts[$language_interface->langcode] . '.js'; @@ -938,7 +938,7 @@ function locale_translation_status_save($data) { // Followup issue: http://drupal.org/node/1842362 // Split status storage per module/language and expire individually. This will // improve performance for large sites. - $status = state()->get('locale.translation_status'); + $status = Drupal::state()->get('locale.translation_status'); $status = empty($status) ? array() : $status; // Merge the new data into the existing structured status array. @@ -948,8 +948,8 @@ function locale_translation_status_save($data) { } } - state()->set('locale.translation_status', $status); - state()->set('locale.translation_last_checked', REQUEST_TIME); + Drupal::state()->set('locale.translation_status', $status); + Drupal::state()->set('locale.translation_last_checked', REQUEST_TIME); } /** @@ -959,7 +959,7 @@ function locale_translation_status_save($data) { * Language code(s) to be deleted from the cache. */ function locale_translation_status_delete_languages($langcodes) { - if ($status = state()->get('locale.translation_status')) { + if ($status = Drupal::state()->get('locale.translation_status')) { foreach ($status as $project => $languages) { foreach ($languages as $langcode => $source) { if (in_array($langcode, $langcodes)) { @@ -967,7 +967,7 @@ function locale_translation_status_delete_languages($langcodes) { } } } - state()->set('locale.translation_status', $status); + Drupal::state()->set('locale.translation_status', $status); } } @@ -978,22 +978,22 @@ function locale_translation_status_delete_languages($langcodes) { * Project name(s) to be deleted from the cache. */ function locale_translation_status_delete_projects($projects) { - $status = state()->get('locale.translation_status'); + $status = Drupal::state()->get('locale.translation_status'); foreach ($status as $project => $languages) { if (in_array($project, $projects)) { unset($status[$project]); } } - state()->set('locale.translation_status', $status); + Drupal::state()->set('locale.translation_status', $status); } /** * Clear the translation status cache. */ function locale_translation_clear_status() { - state()->delete('locale.translation_status'); - state()->delete('locale.translation_last_checked'); + Drupal::state()->delete('locale.translation_status'); + Drupal::state()->delete('locale.translation_last_checked'); } /** @@ -1173,7 +1173,7 @@ function _locale_parse_js_file($filepath) { * New content of the 'system.javascript_parsed' variable. */ function _locale_invalidate_js($langcode = NULL) { - $parsed = state()->get('system.javascript_parsed') ?: array(); + $parsed = Drupal::state()->get('system.javascript_parsed') ?: array(); if (empty($langcode)) { // Invalidate all languages. @@ -1187,7 +1187,7 @@ function _locale_invalidate_js($langcode = NULL) { $parsed['refresh:' . $langcode] = 'waiting'; } - state()->set('system.javascript_parsed', $parsed); + Drupal::state()->set('system.javascript_parsed', $parsed); return $parsed; } @@ -1226,7 +1226,7 @@ function _locale_rebuild_js($langcode = NULL) { if (!empty($translations)) { $data = "Drupal.locale = { "; - $locale_plurals = state()->get('locale.translation.plurals') ?: array(); + $locale_plurals = Drupal::state()->get('locale.translation.plurals') ?: array(); if (!empty($locale_plurals[$language->langcode])) { $data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->langcode]['formula']}); }, "; } @@ -1240,7 +1240,7 @@ function _locale_rebuild_js($langcode = NULL) { $dir = 'public://' . $config->get('javascript.directory'); // Delete old file, if we have no translations anymore, or a different file to be saved. - $locale_javascripts = state()->get('locale.translation.javascript') ?: array(); + $locale_javascripts = Drupal::state()->get('locale.translation.javascript') ?: array(); $changed_hash = !isset($locale_javascripts[$language->langcode]) || ($locale_javascripts[$language->langcode] != $data_hash); if (!empty($locale_javascripts[$language->langcode]) && (!$data || $changed_hash)) { file_unmanaged_delete($dir . '/' . $language->langcode . '_' . $locale_javascripts[$language->langcode] . '.js'); @@ -1284,7 +1284,7 @@ function _locale_rebuild_js($langcode = NULL) { // deleted). Act only if some operation was executed that changed the hash // code. if ($status && $changed_hash) { - state()->set('locale.translation.javascript', $locale_javascripts); + Drupal::state()->set('locale.translation.javascript', $locale_javascripts); } // Log the operation and return success flag. diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index fc68a51..99af0a3 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -279,7 +279,7 @@ function locale_translate_edit_form($form, &$form_state) { if (isset($langcode)) { $strings = locale_translate_filter_load_strings(); - $plural_formulas = state()->get('locale.translation.plurals') ?: array(); + $plural_formulas = Drupal::state()->get('locale.translation.plurals') ?: array(); foreach ($strings as $string) { // Cast into source string, will do for our purposes. @@ -499,7 +499,7 @@ function locale_translation_status_form($form, &$form_state) { $project_data = locale_translation_build_projects(); $languages = locale_translatable_language_list(); $projects = locale_translation_get_projects(); - $status = state()->get('locale.translation_status'); + $status = Drupal::state()->get('locale.translation_status'); // Prepare information about projects which have available translation // updates. @@ -542,7 +542,7 @@ function locale_translation_status_form($form, &$form_state) { uasort($options, 'drupal_sort_title'); } - $last_checked = state()->get('locale.translation_last_checked'); + $last_checked = Drupal::state()->get('locale.translation_last_checked'); $form['last_checked'] = array( '#markup' => '

' . theme('locale_translation_last_check', array('last' => $last_checked)) . '

', ); @@ -619,7 +619,7 @@ function locale_translation_status_form_submit($form, &$form_state) { // If the status was updated recently we can immediately start fetching the // translation updates. If the status is expired we clear it an run a batch to // update the status and then fetch the translation updates. - $last_checked = state()->get('locale.translation_last_checked'); + $last_checked = Drupal::state()->get('locale.translation_last_checked'); if ($last_checked < REQUEST_TIME - LOCALE_TRANSLATION_STATUS_TTL) { locale_translation_clear_status(); $batch = locale_translation_batch_update_build(array(), $langcodes, $options); diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc index 7edf847..7d58315 100644 --- a/core/modules/locale/locale.translation.inc +++ b/core/modules/locale/locale.translation.inc @@ -104,7 +104,7 @@ function locale_translation_load_sources($projects = NULL, $langcodes = NULL) { $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list()); // Load source data from locale_translation_status cache. - $status = state()->get('locale.translation_status'); + $status = Drupal::state()->get('locale.translation_status'); // Use only the selected projects and languages for update. foreach($projects as $project) { diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.install b/core/modules/locale/tests/modules/locale_test/locale_test.install index 3d9dff3..e820b9f 100644 --- a/core/modules/locale/tests/modules/locale_test/locale_test.install +++ b/core/modules/locale/tests/modules/locale_test/locale_test.install @@ -10,6 +10,6 @@ */ function locale_test_uninstall() { // Clear variables. - state()->delete('locale.test_system_info_alter'); - state()->delete('locale.test_projects_alter'); + Drupal::state()->delete('locale.test_system_info_alter'); + Drupal::state()->delete('locale.test_projects_alter'); } diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.module b/core/modules/locale/tests/modules/locale_test/locale_test.module index 88e581c..ace4172 100644 --- a/core/modules/locale/tests/modules/locale_test/locale_test.module +++ b/core/modules/locale/tests/modules/locale_test/locale_test.module @@ -16,7 +16,7 @@ function locale_test_system_info_alter(&$info, $file, $type) { // By default the locale_test modules are hidden and have a project specified. // To test the module detection proces by locale_project_list() the // test modules should mimic a custom module. I.e. be non-hidden. - if (state()->get('locale.test_system_info_alter')) { + if (Drupal::state()->get('locale.test_system_info_alter')) { if ($file->name == 'locale_test' || $file->name == 'locale_test_translate') { // Don't hide the module. $info['hidden'] = FALSE; @@ -37,7 +37,7 @@ function locale_test_system_info_alter(&$info, $file, $type) { * test script in order for this hook to take effect. */ function locale_test_locale_translation_projects_alter(&$projects) { - if (state()->get('locale.test_projects_alter')) { + if (Drupal::state()->get('locale.test_projects_alter')) { // Instead of the default ftp.drupal.org we use the file system of the test // instance to simulate a remote file location. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php index 6b7d00d..5c0bc59 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php @@ -40,7 +40,7 @@ public function setUp() { parent::setUp(); node_access_rebuild(); - state()->set('node_access_test.private', TRUE); + \Drupal::state()->set('node_access_test.private', TRUE); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index fceb154..4e3f374 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -36,7 +36,7 @@ function setUp() { node_access_rebuild(); // Enable the private node feature of the node_access_test module. - state()->set('node_access_test.private', TRUE); + \Drupal::state()->set('node_access_test.private', TRUE); // Add Hungarian and Catalan. $language = new Language(array( @@ -153,7 +153,7 @@ function testNodeAccessPrivate() { // Reset the node access cache and turn on our test node_access() code. entity_access_controller('node')->resetCache(); - state()->set('node_access_test_secret_catalan', 1); + \Drupal::state()->set('node_access_test_secret_catalan', 1); // Tests that access is not granted if requested with no language. $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php index f072254..cd2366d 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php @@ -43,7 +43,7 @@ function testNodeViewModeChange() { $node = $this->drupalGetNodeByTitle($edit["title"]); // Set the flag to alter the view mode and view the node. - state()->set('node_test_change_view_mode', 'teaser'); + \Drupal::state()->set('node_test_change_view_mode', 'teaser'); $this->drupalGet('node/' . $node->nid); // Check that teaser mode is viewed. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php index cb2b329..f8ea00e 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php @@ -196,7 +196,7 @@ function testNodeQueryAlterOverride() { // $account instead of the global $user, we will log in as // noAccessUser2. $this->drupalLogin($this->noAccessUser2); - state()->set('node_access_test.no_access_uid', $this->noAccessUser->uid); + \Drupal::state()->set('node_access_test.no_access_uid', $this->noAccessUser->uid); drupal_static_reset('node_access_view_all_nodes'); try { $query = db_select('node', 'mytab') @@ -211,6 +211,6 @@ function testNodeQueryAlterOverride() { catch (Exception $e) { $this->fail(t('Altered query is malformed')); } - state()->delete('node_access_test.no_access_uid'); + \Drupal::state()->delete('node_access_test.no_access_uid'); } } diff --git a/core/modules/node/node.install b/core/modules/node/node.install index b0735d3..527ceb0 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -438,12 +438,12 @@ function node_uninstall() { variable_del('node_rank_recent'); // Delete remaining general module variables. - state()->delete('node.node_access_needs_rebuild'); + Drupal::state()->delete('node.node_access_needs_rebuild'); variable_del('node_admin_theme'); variable_del('node_recent_block_count'); // Delete any stored state. - state()->delete('node.cron_last'); + Drupal::state()->delete('node.cron_last'); } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 9d5fe32..82cbe84 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1450,7 +1450,7 @@ function node_ranking() { ); // Add relevance based on creation or changed date. - if ($node_cron_last = state()->get('node.cron_last')) { + if ($node_cron_last = Drupal::state()->get('node.cron_last')) { $ranking['recent'] = array( 'title' => t('Recently posted'), // Exponential decay with half-life of 6 months, starting at last indexed node @@ -2241,7 +2241,7 @@ function _node_index_node(EntityInterface $node) { // Save the changed time of the most recent indexed node, for the search // results half-life calculation. - state()->set('node.cron_last', $node->changed); + Drupal::state()->set('node.cron_last', $node->changed); $languages = $node->getTranslationLanguages(); @@ -2970,13 +2970,13 @@ function _node_access_write_grants(EntityInterface $node, $grants, $realm = NULL */ function node_access_needs_rebuild($rebuild = NULL) { if (!isset($rebuild)) { - return state()->get('node.node_access_needs_rebuild') ?: FALSE; + return Drupal::state()->get('node.node_access_needs_rebuild') ?: FALSE; } elseif ($rebuild) { - state()->set('node.node_access_needs_rebuild', TRUE); + Drupal::state()->set('node.node_access_needs_rebuild', TRUE); } else { - state()->delete('node.node_access_needs_rebuild'); + Drupal::state()->delete('node.node_access_needs_rebuild'); } } diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index 66c6b59..0971750 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -22,7 +22,7 @@ function node_access_test_node_grants($account, $op) { $grants['node_access_test'] = array(8888, 8889); } - $no_access_uid = state()->get('node_access_test.no_access_uid') ?: 0; + $no_access_uid = Drupal::state()->get('node_access_test.no_access_uid') ?: 0; if ($op == 'view' && $account->uid == $no_access_uid) { $grants['node_access_all'] = array(0); } @@ -35,7 +35,7 @@ function node_access_test_node_grants($account, $op) { function node_access_test_node_access_records(EntityInterface $node) { $grants = array(); // For NodeAccessBaseTableTestCase, only set records for private nodes. - if (!state()->get('node_access_test.private') || $node->private) { + if (!Drupal::state()->get('node_access_test.private') || $node->private) { $grants[] = array( 'realm' => 'node_access_test', 'gid' => 8888, @@ -182,7 +182,7 @@ function node_access_entity_test_page() { */ function node_access_test_form_node_form_alter(&$form, $form_state) { // Only show this checkbox for NodeAccessBaseTableTestCase. - if (state()->get('node_access_test.private')) { + if (Drupal::state()->get('node_access_test.private')) { $node = $form_state['controller']->getEntity($form_state); $form['private'] = array( '#type' => 'checkbox', @@ -241,7 +241,7 @@ function _node_access_test_node_write(EntityInterface $node) { * Implements hook_node_access(). */ function node_access_test_node_access($node, $op, $account, $langcode) { - $secret_catalan = state()->get('node_access_test_secret_catalan') ?: 0; + $secret_catalan = Drupal::state()->get('node_access_test_secret_catalan') ?: 0; if ($secret_catalan && $langcode == 'ca') { // Make all Catalan content secret. return NODE_ACCESS_DENY; diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module index f3fd04b..3cb030a 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -160,7 +160,7 @@ function node_test_node_update(EntityInterface $node) { */ function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) { // Only alter the view mode if we are on the test callback. - $change_view_mode = state()->get( 'node_test_change_view_mode') ?: ''; + $change_view_mode = Drupal::state()->get( 'node_test_change_view_mode') ?: ''; if ($change_view_mode) { $view_mode = $change_view_mode; } diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php index 1715255..7586e98 100644 --- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php +++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php @@ -75,9 +75,9 @@ function testDiscovery() { $identity = url('openid-test/yadis/xrds/dummy-user', array('absolute' => TRUE, 'fragment' => $this->randomName())); // Tell openid_test.module to respond with this identifier. If the fragment // part is present in the identifier, it should be retained. - state()->set('openid_test.response', array('openid.claimed_id' => $identity)); + \Drupal::state()->set('openid_test.response', array('openid.claimed_id' => $identity)); $this->addIdentity(url('openid-test/yadis/xrds/server', array('absolute' => TRUE)), 2, 'http://specs.openid.net/auth/2.0/identifier_select', $identity); - state()->set('openid_test.response', array()); + \Drupal::state()->set('openid_test.response', array()); // Identifier is the URL of an HTML page that is sent with an HTTP header // that contains the URL of an XRDS document. @@ -94,7 +94,7 @@ function testDiscovery() { $this->addIdentity('@example*résumé;%25', 2, 'http://example.com/xrds', 'http://example.com/user'); // Make sure that unverified CanonicalID are not trusted. - state()->set('openid_test.canonical_id_status', 'bad value'); + \Drupal::state()->set('openid_test.canonical_id_status', 'bad value'); $this->addIdentity('@example*résumé;%25', 2, FALSE, FALSE); // HTML-based discovery: @@ -140,20 +140,20 @@ function testLogin() { // Use a User-supplied Identity that is the URL of an XRDS document. $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); $this->addIdentity($identity); - $response = state()->get('openid_test.hook_openid_response_response'); - $account = state()->get('openid_test.hook_openid_response_account'); + $response = \Drupal::state()->get('openid_test.hook_openid_response_response'); + $account = \Drupal::state()->get('openid_test.hook_openid_response_account'); $this->assertEqual($response['openid.claimed_id'], $identity, 'hook_openid_response() was invoked.'); $this->assertEqual($account->uid, $this->web_user->uid, 'Proper user object passed to hook_openid_response().'); $this->drupalLogout(); // Test logging in via the login block on the front page. - state()->delete('openid_test.hook_openid_response_response'); - state()->delete('openid_test.hook_openid_response_account'); + \Drupal::state()->delete('openid_test.hook_openid_response_response'); + \Drupal::state()->delete('openid_test.hook_openid_response_account'); $this->submitLoginForm($identity); $this->assertLink(t('Log out'), 0, 'User was logged in.'); - $response = state()->get('openid_test.hook_openid_response_response'); - $account = state()->get('openid_test.hook_openid_response_account'); + $response = \Drupal::state()->get('openid_test.hook_openid_response_response'); + $account = \Drupal::state()->get('openid_test.hook_openid_response_account'); $this->assertEqual($response['openid.claimed_id'], $identity, 'hook_openid_response() was invoked.'); $this->assertEqual($account->uid, $this->web_user->uid, 'Proper user object passed to hook_openid_response().'); @@ -179,11 +179,11 @@ function testLogin() { // Tell openid_test.module to alter the checkid_setup request. $new_identity = 'http://example.com/' . $this->randomName(); - state()->set('openid_test.identity', $new_identity); - state()->set('openid_test.request_alter', array('checkid_setup' => array('openid.identity' => $new_identity))); + \Drupal::state()->set('openid_test.identity', $new_identity); + \Drupal::state()->set('openid_test.request_alter', array('checkid_setup' => array('openid.identity' => $new_identity))); $this->submitLoginForm($identity); $this->assertLink(t('Log out'), 0, 'User was logged in.'); - $response = state()->get('openid_test.hook_openid_response_response'); + $response = \Drupal::state()->get('openid_test.hook_openid_response_response'); $this->assertEqual($response['openid.identity'], $new_identity, 'hook_openid_request_alter() were invoked.'); $this->drupalLogout(); @@ -292,7 +292,7 @@ function testBlockedUserLogin() { */ function addIdentity($identity, $version = 2, $local_id = 'http://example.com/xrds', $claimed_id = NULL) { // Tell openid_test.module to only accept this OP-Local Identifier. - state()->set('openid_test.identity', $local_id); + \Drupal::state()->set('openid_test.identity', $local_id); $edit = array('openid_identifier' => $identity); $this->drupalPost('user/' . $this->web_user->uid . '/openid', $edit, t('Add an OpenID')); @@ -342,14 +342,14 @@ function addRedirectedIdentity($identity, $version = 2, $local_id = 'http://exam // Identifier, we insert the same identifier also to the provider response, // but provider could further change the Claimed ID actually (e.g. it could // add unique fragment). - state()->set('openid_test.redirect_url', $identity); - state()->set('openid_test.response', array('openid.claimed_id' => $identity)); + \Drupal::state()->set('openid_test.redirect_url', $identity); + \Drupal::state()->set('openid_test.response', array('openid.claimed_id' => $identity)); $this->addIdentity(url('openid-test/redirect/' . $redirects, array('absolute' => TRUE)), $version, $local_id, $claimed_id); // Clean up. - state()->delete('openid_test.redirect_url'); - state()->delete('openid_test.response'); + \Drupal::state()->delete('openid_test.redirect_url'); + \Drupal::state()->delete('openid_test.response'); } /** @@ -361,12 +361,12 @@ function testSignatureValidation() { $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); // Respond with an invalid signature. - state()->set('openid_test.response', array('openid.sig' => 'this-is-an-invalid-signature')); + \Drupal::state()->set('openid_test.response', array('openid.sig' => 'this-is-an-invalid-signature')); $this->submitLoginForm($identity); $this->assertRaw('OpenID login failed.'); // Do not sign the mandatory field openid.assoc_handle. - state()->set('openid_test.response', array('openid.signed' => 'op_endpoint,claimed_id,identity,return_to,response_nonce')); + \Drupal::state()->set('openid_test.response', array('openid.signed' => 'op_endpoint,claimed_id,identity,return_to,response_nonce')); $this->submitLoginForm($identity); $this->assertRaw('OpenID login failed.'); @@ -385,7 +385,7 @@ function testSignatureValidation() { 'openid.signed' => implode(',', $keys_to_sign), ); $response['openid.sig'] = _openid_signature($association, $response, $keys_to_sign); - state()->set('openid_test.response', $response); + \Drupal::state()->set('openid_test.response', $response); $this->submitLoginForm($identity); $this->assertNoRaw('OpenID login failed.'); $this->assertFieldByName('name', '', 'No username was supplied by provider.'); @@ -397,7 +397,7 @@ function testSignatureValidation() { 'openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com', ); - state()->set('openid_test.response', $response); + \Drupal::state()->set('openid_test.response', $response); $this->submitLoginForm($identity); $this->assertNoRaw('OpenID login failed.'); $this->assertFieldByName('name', 'john', 'Username was supplied by provider.'); diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php index 7389580..2fd8370 100644 --- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php +++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php @@ -43,7 +43,7 @@ function testRegisterUserWithEmailVerification() { ->save(); // Tell openid_test.module to respond with these SREG fields. - state()->set('openid_test.response', array( + \Drupal::state()->set('openid_test.response', array( 'openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com', 'openid.sreg.language' => 'pt-BR', @@ -102,7 +102,7 @@ function testRegisterUserWithoutEmailVerification() { ->save(); // Tell openid_test.module to respond with these SREG fields. - state()->set('openid_test.response', array( + \Drupal::state()->set('openid_test.response', array( 'openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com', 'openid.sreg.language' => 'pt-BR', @@ -145,7 +145,7 @@ function testRegisterUserWithInvalidSreg() { // Tell openid_test.module to respond with these SREG fields. $web_user = $this->drupalCreateUser(array()); - state()->set('openid_test.response', array( + \Drupal::state()->set('openid_test.response', array( 'openid.sreg.nickname' => $web_user->name, 'openid.sreg.email' => 'mail@invalid#', 'openid.sreg.timezone' => 'Foo/Bar', @@ -159,11 +159,11 @@ function testRegisterUserWithInvalidSreg() { $this->assertRaw(t('Account registration using the information provided by your OpenID provider failed due to the reasons listed below. Complete the registration by filling out the form below. If you already have an account, you can log in now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'User was asked to complete the registration process manually.'); $this->assertRaw(t('The name %name is already taken.', array('%name' => $web_user->name)), 'Form validation error for username was displayed.'); $this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => 'mail@invalid#')), 'Form validation error for e-mail address was displayed.'); - $this->assertTrue(state()->get('openid_test.hook_openid_response_response'), 'hook_openid_response() was invoked.'); - $this->assertFalse(state()->get('openid_test.hook_openid_response_account'), 'No user object passed to hook_openid_response().'); + $this->assertTrue(\Drupal::state()->get('openid_test.hook_openid_response_response'), 'hook_openid_response() was invoked.'); + $this->assertFalse(\Drupal::state()->get('openid_test.hook_openid_response_account'), 'No user object passed to hook_openid_response().'); // Enter username and e-mail address manually. - state()->delete('openid_test.hook_openid_response_response'); + \Drupal::state()->delete('openid_test.hook_openid_response_response'); $edit = array('name' => 'john', 'mail' => 'john@example.com'); $this->drupalPost(NULL, $edit, t('Create new account')); $this->assertRaw(t('Once you have verified your e-mail address, you may log in via OpenID.'), 'User was asked to verify e-mail address.'); @@ -176,7 +176,7 @@ function testRegisterUserWithInvalidSreg() { // Follow the one-time login that was sent in the welcome e-mail. $this->drupalGet($reset_url); $this->drupalPost(NULL, array(), t('Log in')); - $this->assertFalse(state()->get('openid_test.hook_openid_response_response'), 'hook_openid_response() was not invoked.'); + $this->assertFalse(\Drupal::state()->get('openid_test.hook_openid_response_response'), 'hook_openid_response() was not invoked.'); // The user is taken to user/%uid/edit. $this->assertFieldByName('mail', 'john@example.com', 'User was registered with right e-mail address.'); @@ -233,7 +233,7 @@ function testRegisterUserWithAXButNoSREG() { ->save(); // Tell openid_test.module to respond with these AX fields. - state()->set('openid_test.response', array( + \Drupal::state()->set('openid_test.response', array( 'openid.ns.ext123' => 'http://openid.net/srv/ax/1.0', 'openid.ext123.type.mail456' => 'http://axschema.org/contact/email', 'openid.ext123.value.mail456' => 'john@example.com', diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module index 9aa5023..8ff285b 100644 --- a/core/modules/openid/tests/openid_test.module +++ b/core/modules/openid/tests/openid_test.module @@ -108,7 +108,7 @@ function openid_test_yadis_xrds() { $output .= ' - + xri://@ http://example.com/user @@ -226,12 +226,12 @@ function openid_test_endpoint() { */ function openid_test_redirect($count = 0) { if ($count == 0) { - $url = state()->get('openid_test.redirect_url'); + $url = Drupal::state()->get('openid_test.redirect_url'); } else { $url = url('openid-test/redirect/' . --$count, array('absolute' => TRUE)); } - $http_response_code = state()->get('openid_test.redirect_http_response_code') ?: 301; + $http_response_code = Drupal::state()->get('openid_test.redirect_http_response_code') ?: 301; return new RedirectResponse($url, $http_response_code); } @@ -303,9 +303,9 @@ function _openid_test_endpoint_associate() { function _openid_test_endpoint_authenticate() { module_load_include('inc', 'openid'); - $expected_identity = state()->get('openid_test.identity'); + $expected_identity = Drupal::state()->get('openid_test.identity'); if ($expected_identity && $_REQUEST['openid_identity'] != $expected_identity) { - $response = state()->get('openid_test.response') ?: array(); + $response = Drupal::state()->get('openid_test.response') ?: array(); $response += array( 'openid.ns' => OPENID_NS_2_0, 'openid.mode' => 'error', @@ -318,7 +318,7 @@ function _openid_test_endpoint_authenticate() { $nonce = _openid_nonce(); // Generate response containing the user's identity. - $response = state()->get('openid_test.response') ?: array(); + $response = Drupal::state()->get('openid_test.response') ?: array(); $response += array( 'openid.ns' => OPENID_NS_2_0, 'openid.mode' => 'id_res', @@ -359,7 +359,7 @@ function _openid_test_endpoint_authenticate() { * Implements hook_openid_request_alter(). */ function openid_test_openid_request_alter(&$request, $service) { - $parameters = state()->get('openid_test.request_alter'); + $parameters = Drupal::state()->get('openid_test.request_alter'); if (isset($parameters[$request['openid.mode']])) { $request = $parameters[$request['openid.mode']] + $request; } @@ -369,6 +369,6 @@ function openid_test_openid_request_alter(&$request, $service) { * Implements hook_openid_response(). */ function openid_test_openid_response($response, $account) { - state()->set('openid_test.hook_openid_response_response', $response); - state()->set('openid_test.hook_openid_response_account', $account ? $account : FALSE); + Drupal::state()->set('openid_test.hook_openid_response_response', $response); + Drupal::state()->set('openid_test.hook_openid_response_account', $account ? $account : FALSE); } diff --git a/core/modules/search/search.admin.inc b/core/modules/search/search.admin.inc index a63cf47..06fd68d 100644 --- a/core/modules/search/search.admin.inc +++ b/core/modules/search/search.admin.inc @@ -180,7 +180,7 @@ function search_admin_settings_submit($form, &$form_state) { if ($config->get('active_modules') != $new_modules) { $config->set('active_modules', $new_modules); drupal_set_message(t('The active search modules have been changed.')); - state()->set('menu_rebuild_needed', TRUE); + Drupal::state()->set('menu_rebuild_needed', TRUE); } $config->save(); } diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index ce581b0..05b26e4 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -367,7 +367,7 @@ function hook_update_index() { // Save the changed time of the most recent indexed node, for the search // results half-life calculation. - state()->set('node.cron_last', $node->changed); + \Drupal::state()->set('node.cron_last', $node->changed); // Render the node. $build = node_view($node, 'search_index'); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index e5f33d4..362398d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -79,9 +79,9 @@ function __construct($test_id = NULL) { protected function setUp() { // Copy/prime extension file lists once to avoid filesystem scans. if (!isset($this->moduleFiles)) { - $this->moduleFiles = state()->get('system.module.files') ?: array(); - $this->themeFiles = state()->get('system.theme.files') ?: array(); - $this->themeData = state()->get('system.theme.data') ?: array(); + $this->moduleFiles = \Drupal::state()->get('system.module.files') ?: array(); + $this->themeFiles = \Drupal::state()->get('system.theme.files') ?: array(); + $this->themeData = \Drupal::state()->get('system.theme.data') ?: array(); } $this->keyValueFactory = new KeyValueMemoryFactory(); @@ -92,9 +92,9 @@ protected function setUp() { // Make sure it survives kernel rebuilds. $GLOBALS['conf']['container_bundles'][] = 'Drupal\simpletest\TestBundle'; - state()->set('system.module.files', $this->moduleFiles); - state()->set('system.theme.files', $this->themeFiles); - state()->set('system.theme.data', $this->themeData); + \Drupal::state()->set('system.module.files', $this->moduleFiles); + \Drupal::state()->set('system.theme.files', $this->themeFiles); + \Drupal::state()->set('system.theme.data', $this->themeData); // Bootstrap the kernel. // No need to dump it; this test runs in-memory. @@ -163,7 +163,7 @@ public function containerBuild(ContainerBuilder $container) { // a kernel is overridden then there's no need to re-register the keyvalue // service but when a test is happy with the superminimal container put // together here, it still might a keyvalue storage for anything (for - // eg. module_enable) using state() -- that's why a memory service was + // eg. module_enable) using \Drupal::state() -- that's why a memory service was // added in the first place. $container ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory') diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 35af531..ba366a2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -1011,7 +1011,7 @@ protected function tearDown() { // log to pick up any fatal errors. simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE); if (($container = drupal_container()) && $container->has('keyvalue')) { - $captured_emails = state()->get('system.test_email_collector') ?: array(); + $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $emailCount = count($captured_emails); if ($emailCount) { $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.'); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 5cca38a..316a78d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -1533,7 +1533,7 @@ protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path * Runs cron in the Drupal installed by Simpletest. */ protected function cronRun() { - $this->drupalGet('cron/' . state()->get('system.cron_key')); + $this->drupalGet('cron/' . \Drupal::state()->get('system.cron_key')); } /** @@ -2106,7 +2106,7 @@ protected function drupalGetSettings() { * An array containing e-mail messages captured during the current test. */ protected function drupalGetMails($filter = array()) { - $captured_emails = state()->get('system.test_email_collector') ?: array(); + $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $filtered_emails = array(); foreach ($captured_emails as $message) { @@ -3075,7 +3075,7 @@ protected function assertNoResponse($code, $message = '', $group = 'Browser') { * TRUE on pass, FALSE on fail. */ protected function assertMail($name, $value = '', $message = '', $group = 'E-mail') { - $captured_emails = state()->get('system.test_email_collector') ?: array(); + $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $email = end($captured_emails); return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, $group); } diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php index dfae39f..bcc13c7 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php @@ -130,7 +130,7 @@ function testExpiredLogs() { config('statistics.settings') ->set('count_content_views', 1) ->save(); - state()->set('statistics.day_timestamp', 8640000); + \Drupal::state()->set('statistics.day_timestamp', 8640000); $this->drupalGet('node/' . $this->test_node->nid); // Manually calling statistics.php, simulating ajax behavior. diff --git a/core/modules/statistics/statistics.install b/core/modules/statistics/statistics.install index 6732eb0..5706db3 100644 --- a/core/modules/statistics/statistics.install +++ b/core/modules/statistics/statistics.install @@ -10,8 +10,8 @@ */ function statistics_uninstall() { // Remove states. - state()->delete('statistics.node_counter_scale'); - state()->delete('statistics.day_timestamp'); + Drupal::state()->delete('statistics.node_counter_scale'); + Drupal::state()->delete('statistics.day_timestamp'); } /** diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 66842a5..318729c 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -90,14 +90,14 @@ function statistics_menu() { * Implements hook_cron(). */ function statistics_cron() { - $statistics_timestamp = state()->get('statistics.day_timestamp') ?: 0; + $statistics_timestamp = Drupal::state()->get('statistics.day_timestamp') ?: 0; if ((REQUEST_TIME - $statistics_timestamp) >= 86400) { // Reset day counts. db_update('node_counter') ->fields(array('daycount' => 0)) ->execute(); - state()->set('statistics.day_timestamp', REQUEST_TIME); + Drupal::state()->set('statistics.day_timestamp', REQUEST_TIME); } } @@ -220,7 +220,7 @@ function statistics_ranking() { ), // Inverse law that maps the highest view count on the site to 1 and 0 to 0. 'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * CAST(:scale AS DECIMAL))', - 'arguments' => array(':scale' => state()->get('statistics.node_counter_scale') ?: 0), + 'arguments' => array(':scale' => Drupal::state()->get('statistics.node_counter_scale') ?: 0), ), ); } @@ -230,7 +230,7 @@ function statistics_ranking() { * Implements hook_update_index(). */ function statistics_update_index() { - state()->set('statistics.node_counter_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField())); + Drupal::state()->set('statistics.node_counter_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField())); } /** diff --git a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php index 117dc1a..f90d2d3 100644 --- a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php +++ b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php @@ -28,7 +28,7 @@ public function applies(Route $route) { */ public function access(Route $route, Request $request) { $key = $request->attributes->get('key'); - if ($key != state()->get('system.cron_key')) { + if ($key != \Drupal::state()->get('system.cron_key')) { watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE); return FALSE; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php index 3c54ad4..fd4d1af 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php @@ -371,11 +371,11 @@ function testAggregationOrder() { )); // Store the expected key for the first item in the cache. - $cache = array_keys(state()->get('system.js_cache_files') ?: array()); + $cache = array_keys(\Drupal::state()->get('system.js_cache_files') ?: array()); $expected_key = $cache[0]; // Reset variables and add a file in a different scope first. - state()->delete('system.js_cache_files'); + \Drupal::state()->delete('system.js_cache_files'); drupal_static_reset('drupal_add_js'); drupal_add_library('system', 'drupal'); drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer')); @@ -390,7 +390,7 @@ function testAggregationOrder() { )); // Compare the expected key for the first file to the current one. - $cache = array_keys(state()->get('system.js_cache_files') ?: array()); + $cache = array_keys(\Drupal::state()->get('system.js_cache_files') ?: array()); $key = $cache[0]; $this->assertEqual($key, $expected_key, 'JavaScript aggregation is not affected by ordering in different scopes.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php index b31ca74..9bfde63 100644 --- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php @@ -32,13 +32,13 @@ public function testDestructionUsed() { $this->enableModules(array('bundle_test')); // The service has not been destructed yet. - $this->assertNull(state()->get('bundle_test.destructed')); + $this->assertNull(\Drupal::state()->get('bundle_test.destructed')); // Call the class and then terminate the kernel $this->container->get('bundle_test_class'); $response = new Response(); $this->container->get('kernel')->terminate($this->container->get('request'), $response); - $this->assertTrue(state()->get('bundle_test.destructed')); + $this->assertTrue(\Drupal::state()->get('bundle_test.destructed')); } /** @@ -49,12 +49,12 @@ public function testDestructionUnused() { $this->enableModules(array('bundle_test')); // The service has not been destructed yet. - $this->assertNull(state()->get('bundle_test.destructed')); + $this->assertNull(\Drupal::state()->get('bundle_test.destructed')); // Terminate the kernel. The test class has not been called, so it should not // be destructed. $response = new Response(); $this->container->get('kernel')->terminate($this->container->get('request'), $response); - $this->assertNull(state()->get('bundle_test.destructed')); + $this->assertNull(\Drupal::state()->get('bundle_test.destructed')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php index 6135bf0..d26db5b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php @@ -32,7 +32,7 @@ function testEntityInfoChanges() { // Change the label of the test entity type and make sure changes appear // after flushing caches. - state()->set('entity_cache_test.label', 'New label.'); + \Drupal::state()->set('entity_cache_test.label', 'New label.'); $info = entity_get_info('entity_cache_test'); $this->assertEqual($info['label'], 'Entity Cache Test', 'Original label appears in cached entity info.'); $this->resetAll(); @@ -52,7 +52,7 @@ function testEntityInfoChanges() { */ function testEntityInfoCacheWatchdog() { module_enable(array('entity_cache_test')); - $info = state()->get('entity_cache_test'); + $info = \Drupal::state()->get('entity_cache_test'); $this->assertEqual($info['label'], 'Entity Cache Test', 'Entity info label is correct.'); $this->assertEqual($info['controller_class'], 'Drupal\Core\Entity\DatabaseStorageController', 'Entity controller class info is correct.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 7672fbe..3e991cc 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -37,7 +37,7 @@ public static function getInfo() { function setUp() { parent::setUp(); // Enable translations for the test entity type. - state()->set('entity_test.translation', TRUE); + \Drupal::state()->set('entity_test.translation', TRUE); // Create test languages. $this->langcodes = array(); @@ -67,7 +67,7 @@ function testEntityFormLanguage() { $edit["body[$langcode][0][value]"] = $this->randomName(16); $this->drupalGet('node/add/page'); - $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE; + $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; $this->drupalPost(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit["title"]); @@ -75,14 +75,14 @@ function testEntityFormLanguage() { // Edit the node and test the form language. $this->drupalGet($this->langcodes[0] . '/node/' . $node->nid . '/edit'); - $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE; + $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; $this->assertTrue($node->langcode == $form_langcode, 'Form language is the same as the entity language.'); // Explicitly set form langcode. $langcode = $this->langcodes[0]; $form_state['langcode'] = $langcode; entity_get_form($node, 'default', $form_state); - $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE; + $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; $this->assertTrue($langcode == $form_langcode, 'Form language is the same as the language parameter.'); // Enable language selector. @@ -117,7 +117,7 @@ function testEntityFormLanguage() { $node->body[$langcode2][0]['value'] = $this->randomName(16); $node->save(); $this->drupalGet($langcode2 . '/node/' . $node->nid . '/edit'); - $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE; + $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; $this->assertTrue($langcode2 == $form_langcode, "Node edit form language is $langcode2."); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index cccdc5f..5d58b0a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -46,7 +46,7 @@ function setUp() { entity_test_install(); // Enable translations for the test entity type. - state()->set('entity_test.translation', TRUE); + \Drupal::state()->set('entity_test.translation', TRUE); // Create a translatable test field. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php index ba837d4..7631d4d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php @@ -35,7 +35,7 @@ function testShippedFileURL() { // Drupal core, a module or a theme, for example a JavaScript file). // Test alteration of file URLs to use a CDN. - state()->set('file_test.hook_file_url_alter', 'cdn'); + \Drupal::state()->set('file_test.hook_file_url_alter', 'cdn'); $filepath = 'core/misc/jquery.js'; $url = file_create_url($filepath); $this->assertEqual(FILE_URL_TEST_CDN_1 . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.'); @@ -44,7 +44,7 @@ function testShippedFileURL() { $this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.'); // Test alteration of file URLs to use root-relative URLs. - state()->set('file_test.hook_file_url_alter', 'root-relative'); + \Drupal::state()->set('file_test.hook_file_url_alter', 'root-relative'); $filepath = 'core/misc/jquery.js'; $url = file_create_url($filepath); $this->assertEqual(base_path() . '/' . $filepath, $url, 'Correctly generated a root-relative URL for a shipped file.'); @@ -53,7 +53,7 @@ function testShippedFileURL() { $this->assertEqual(base_path() . '/' . $filepath, $url, 'Correctly generated a root-relative URL for a shipped file.'); // Test alteration of file URLs to use protocol-relative URLs. - state()->set('file_test.hook_file_url_alter', 'protocol-relative'); + \Drupal::state()->set('file_test.hook_file_url_alter', 'protocol-relative'); $filepath = 'core/misc/jquery.js'; $url = file_create_url($filepath); $this->assertEqual('/' . base_path() . '/' . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.'); @@ -69,20 +69,20 @@ function testPublicCreatedFileURL() { // Test generating an URL to a created file. // Test alteration of file URLs to use a CDN. - state()->set('file_test.hook_file_url_alter', 'cdn'); + \Drupal::state()->set('file_test.hook_file_url_alter', 'cdn'); $uri = $this->createUri(); $url = file_create_url($uri); $public_directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); $this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a CDN URL for a created file.'); // Test alteration of file URLs to use root-relative URLs. - state()->set('file_test.hook_file_url_alter', 'root-relative'); + \Drupal::state()->set('file_test.hook_file_url_alter', 'root-relative'); $uri = $this->createUri(); $url = file_create_url($uri); $this->assertEqual(base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a root-relative URL for a created file.'); // Test alteration of file URLs to use a protocol-relative URLs. - state()->set('file_test.hook_file_url_alter', 'protocol-relative'); + \Drupal::state()->set('file_test.hook_file_url_alter', 'protocol-relative'); $uri = $this->createUri(); $url = file_create_url($uri); $this->assertEqual('/' . base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a protocol-relative URL for a created file.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php index 1a851c9..aa94a68 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php @@ -57,7 +57,7 @@ function testCacheToken() { // Test that the form cache isn't loaded when the session/token has changed. // Change the private key. (We cannot change the session ID because this // will break the parent site test runner batch.) - state()->set('system.private_key', 'invalid'); + \Drupal::state()->set('system.private_key', 'invalid'); $cached_form_state = form_state_defaults(); $cached_form = form_get_cache($this->form_build_id, $cached_form_state); $this->assertFalse($cached_form, 'No form returned from cache'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php index d365f97..2a5043c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php @@ -94,7 +94,7 @@ function imageTestReset() { 'crop' => array(), 'desaturate' => array(), ); - state()->set('image_test.results', $results); + \Drupal::state()->set('image_test.results', $results); } /** @@ -106,6 +106,6 @@ function imageTestReset() { * passed to each call. */ function imageTestGetAllCalls() { - return state()->get('image_test.results') ?: array(); + return \Drupal::state()->get('image_test.results') ?: array(); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php index d4d7451..72f7ff1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php @@ -252,7 +252,7 @@ function testThemeCallbackNoThemeRequested() { function testHookCustomTheme() { // Trigger hook_custom_theme() to dynamically request the Stark theme for // the requested page. - state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme); + \Drupal::state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme); theme_enable(array($this->alternate_theme, $this->admin_theme)); // Visit a page that does not implement a theme callback. The above request @@ -268,7 +268,7 @@ function testHookCustomTheme() { function testThemeCallbackHookCustomTheme() { // Trigger hook_custom_theme() to dynamically request the Stark theme for // the requested page. - state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme); + \Drupal::state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme); theme_enable(array($this->alternate_theme, $this->admin_theme)); // The menu "theme callback" should take precedence over a value set in @@ -461,7 +461,7 @@ function testMenuHidden() { * Test menu_get_item() with empty ancestors. */ function testMenuGetItemNoAncestors() { - state()->set('menu.masks', array()); + \Drupal::state()->set('menu.masks', array()); $this->drupalGet(''); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php index 4677bb5..492c86f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php @@ -38,7 +38,7 @@ function testMenuRebuildByVariable() { // Now we enable the rebuild variable and send a request to rebuild the menu // item. Now 'admin' should exist. - state()->set('menu_rebuild_needed', TRUE); + \Drupal::state()->set('menu_rebuild_needed', TRUE); // The request should trigger the rebuild. $this->drupalGet(''); $admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php index 3dfd5c7..eb59f94 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php @@ -67,12 +67,12 @@ function testMenuTreeSetPath() { ); // Test the tree generation for the Tools menu. - state()->delete('menu_test.menu_tree_set_path'); + \Drupal::state()->delete('menu_test.menu_tree_set_path'); $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree); // Override the active trail for the Administration tree; it should not // affect the Tools tree. - state()->set('menu_test.menu_tree_set_path', $test_menu_path); + \Drupal::state()->set('menu_test.menu_tree_set_path', $test_menu_path); $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree); $breadcrumb = $config + array( @@ -93,12 +93,12 @@ function testMenuTreeSetPath() { ); // Test the tree generation for the Administration menu. - state()->delete('menu_test.menu_tree_set_path'); + \Drupal::state()->delete('menu_test.menu_tree_set_path'); $this->assertBreadcrumb('admin/config/development/menu-trail', $breadcrumb, t('Menu trail - Case 2'), $tree); // Override the active trail for the Administration tree; it should affect // the breadcrumbs and Administration tree. - state()->set('menu_test.menu_tree_set_path', $test_menu_path); + \Drupal::state()->set('menu_test.menu_tree_set_path', $test_menu_path); $this->assertBreadcrumb('admin/config/development/menu-trail', $override_breadcrumb, t('Menu trail - Case 2'), $override_tree); } @@ -150,13 +150,13 @@ function testCustom403And404Pages() { foreach (array(403, 404) as $status_code) { // Before visiting the page, trigger the code in the menu_test module // that will record the active trail (so we can check it in this test). - state()->set('menu_test.record_active_trail', TRUE); + \Drupal::state()->set('menu_test.record_active_trail', TRUE); $this->drupalGet($paths[$status_code]); $this->assertResponse($status_code); // Check that the initial trail (during the Drupal bootstrap) matches // what we expect. - $initial_trail = state()->get('menu_test.active_trail_initial') ?: array(); + $initial_trail = \Drupal::state()->get('menu_test.active_trail_initial') ?: array(); $this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), format_string('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array( '@status_code' => $status_code, '@expected' => count($expected_trail[$status_code]['initial']), @@ -173,7 +173,7 @@ function testCustom403And404Pages() { // Check that the final trail (after the user has been redirected to the // custom 403/404 page) matches what we expect. - $final_trail = state()->get('menu_test.active_trail_final') ?: array(); + $final_trail = \Drupal::state()->get('menu_test.active_trail_final') ?: array(); $this->assertEqual(count($final_trail), count($expected_trail[$status_code]['final']), format_string('The final active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array( '@status_code' => $status_code, '@expected' => count($expected_trail[$status_code]['final']), diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php index e561ab7..023f485 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php @@ -132,7 +132,7 @@ function testModuleEnableOrder() { module_enable(array('module_test'), FALSE); $this->resetAll(); $this->assertModules(array('module_test'), TRUE); - state()->set('module_test.dependency', 'dependency'); + \Drupal::state()->set('module_test.dependency', 'dependency'); // module_test creates a dependency chain: // - forum depends on taxonomy, comment, history, and ban (via module_test) // - taxonomy depends on options @@ -159,7 +159,7 @@ function testModuleEnableOrder() { $this->assertModules(array('forum', 'ban', 'php', 'comment', 'history', 'taxonomy', 'options', 'number'), TRUE); // Check the actual order which is saved by module_test_modules_enabled(). - $module_order = state()->get('system_test.module_enable_order') ?: array(); + $module_order = \Drupal::state()->get('system_test.module_enable_order') ?: array(); $this->assertIdentical($module_order, $expected_order); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php index f8aa2b3..8458bc7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php @@ -64,7 +64,7 @@ function testEnableDisable() { // Set a variable so that the hook implementations in system_test.module // will display messages via drupal_set_message(). - state()->set('system_test.verbose_module_hooks', TRUE); + \Drupal::state()->set('system_test.verbose_module_hooks', TRUE); // Go through each module in the list and try to enable it (unless it was // already enabled automatically due to a dependency). diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php index 3de02ce..19b51e4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -164,7 +164,7 @@ function testDependencyResolution() { // First, create a fake missing dependency. Forum depends on ban, which // depends on a made-up module, foo. Nothing should be installed. - state()->set('module_test.dependency', 'missing dependency'); + \Drupal::state()->set('module_test.dependency', 'missing dependency'); drupal_static_reset('system_rebuild_module_data'); $result = module_enable(array('forum')); $this->assertFalse($result, 'module_enable() returns FALSE if dependencies are missing.'); @@ -172,7 +172,7 @@ function testDependencyResolution() { // Now, fix the missing dependency. Forum module depends on ban, but ban // depends on the PHP module. module_enable() should work. - state()->set('module_test.dependency', 'dependency'); + \Drupal::state()->set('module_test.dependency', 'dependency'); drupal_static_reset('system_rebuild_module_data'); $result = module_enable(array('forum')); $this->assertTrue($result, 'module_enable() returns the correct value.'); @@ -181,7 +181,7 @@ function testDependencyResolution() { // Verify that the original module was installed. $this->assertTrue(module_exists('forum'), 'Module installation with unlisted dependencies succeeded.'); // Finally, verify that the modules were enabled in the correct order. - $module_order = state()->get('system_test.module_enable_order') ?: array(); + $module_order = \Drupal::state()->get('system_test.module_enable_order') ?: array(); $this->assertEqual($module_order, array('php', 'ban', 'forum'), 'Modules were enabled in the correct order by module_enable().'); // Now, disable the PHP module. Both forum and ban should be disabled as @@ -189,7 +189,7 @@ function testDependencyResolution() { module_disable(array('php')); $this->assertTrue(!module_exists('forum') && !module_exists('ban'), 'Depedency chain was disabled by module_disable().'); $this->assertFalse(module_exists('php'), 'Disabling a module with unlisted dependents succeeded.'); - $disabled_modules = state()->get('module_test.disable_order') ?: array(); + $disabled_modules = \Drupal::state()->get('module_test.disable_order') ?: array(); $this->assertEqual($disabled_modules, array('forum', 'ban', 'php'), 'Modules were disabled in the correct order by module_disable().'); // Disable a module that is listed as a dependency by the installation @@ -201,7 +201,7 @@ function testDependencyResolution() { $this->assertTrue(module_exists('comment'), 'Comment module is enabled.'); module_disable(array('comment')); $this->assertFalse(module_exists('comment'), 'Comment module was disabled.'); - $disabled_modules = state()->get('module_test.disable_order') ?: array(); + $disabled_modules = \Drupal::state()->get('module_test.disable_order') ?: array(); $this->assertTrue(in_array('comment', $disabled_modules), 'Comment module is in the list of disabled modules.'); $this->assertFalse(in_array($profile, $disabled_modules), 'The installation profile is not in the list of disabled modules.'); @@ -222,7 +222,7 @@ function testDependencyResolution() { foreach (array('forum', 'ban', 'php') as $module) { $this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, format_string('The @module module was uninstalled.', array('@module' => $module))); } - $uninstalled_modules = state()->get('module_test.uninstall_order') ?: array(); + $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array(); $this->assertEqual($uninstalled_modules, array('forum', 'ban', 'php'), 'Modules were uninstalled in the correct order by module_uninstall().'); // Uninstall the profile module from above, and make sure that the profile @@ -230,7 +230,7 @@ function testDependencyResolution() { $result = module_uninstall(array('comment')); $this->assertTrue($result, 'module_uninstall() returns the correct value.'); $this->assertEqual(drupal_get_installed_schema_version('comment'), SCHEMA_UNINSTALLED, 'Comment module was uninstalled.'); - $uninstalled_modules = state()->get('module_test.uninstall_order') ?: array(); + $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array(); $this->assertTrue(in_array('comment', $uninstalled_modules), 'Comment module is in the list of uninstalled modules.'); $this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.'); @@ -238,7 +238,7 @@ function testDependencyResolution() { // php module. But, this time do it with ban module declaring a dependency // on a specific version of php module in its info file. Make sure that // module_enable() still works. - state()->set('module_test.dependency', 'version dependency'); + \Drupal::state()->set('module_test.dependency', 'version dependency'); drupal_static_reset('system_rebuild_module_data'); $result = module_enable(array('forum')); $this->assertTrue($result, 'module_enable() returns the correct value.'); @@ -247,7 +247,7 @@ function testDependencyResolution() { // Verify that the original module was installed. $this->assertTrue(module_exists('forum'), 'Module installation with version dependencies succeeded.'); // Finally, verify that the modules were enabled in the correct order. - $enable_order = state()->get('system_test.module_enable_order') ?: array(); + $enable_order = \Drupal::state()->get('system_test.module_enable_order') ?: array(); $php_position = array_search('php', $enable_order); $ban_position = array_search('ban', $enable_order); $forum_position = array_search('forum', $enable_order); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php index 467a395..7998af1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php @@ -62,7 +62,7 @@ function testModuleVersions() { // Testing extra version. Incompatible. 'common_test (>2.4-rc0)', ); - state()->set('system_test.dependencies', $dependencies); + \Drupal::state()->set('system_test.dependencies', $dependencies); $n = count($dependencies); for ($i = 0; $i < $n; $i++) { $this->drupalGet('admin/modules'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php index ca7ef51..faaa158 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php @@ -20,7 +20,7 @@ public function setUp() { $this->fixtures = new UrlAliasFixtures(); // The alias whitelist expects that the menu path roots are set by a // menu router rebuild. - state()->set('menu_path_roots', array('user', 'admin')); + \Drupal::state()->set('menu_path_roots', array('user', 'admin')); } public function tearDown() { diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php index 5def452..67a5993 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php @@ -42,7 +42,7 @@ function testCronRun() { $this->assertResponse(403); // Run cron anonymously with the valid cron key. - $key = state()->get('system.cron_key'); + $key = \Drupal::state()->get('system.cron_key'); $this->drupalGet('cron/' . $key); $this->assertResponse(204); } @@ -58,19 +58,19 @@ function testAutomaticCron() { // not passed. $cron_last = time(); $cron_safe_threshold = 100; - state()->set('system.cron_last', $cron_last); + \Drupal::state()->set('system.cron_last', $cron_last); config('system.cron') ->set('threshold.autorun', $cron_safe_threshold) ->save(); $this->drupalGet(''); - $this->assertTrue($cron_last == state()->get('system.cron_last'), 'Cron does not run when the cron threshold is not passed.'); + $this->assertTrue($cron_last == \Drupal::state()->get('system.cron_last'), 'Cron does not run when the cron threshold is not passed.'); // Test if cron runs when the cron threshold was passed. $cron_last = time() - 200; - state()->set('system.cron_last', $cron_last); + \Drupal::state()->set('system.cron_last', $cron_last); $this->drupalGet(''); sleep(1); - $this->assertTrue($cron_last < state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.'); + $this->assertTrue($cron_last < \Drupal::state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.'); // Disable the cron threshold through the interface. $admin_user = $this->drupalCreateUser(array('administer site configuration')); @@ -81,21 +81,21 @@ function testAutomaticCron() { // Test if cron does not run when the cron threshold is disabled. $cron_last = time() - 200; - state()->set('system.cron_last', $cron_last); + \Drupal::state()->set('system.cron_last', $cron_last); $this->drupalGet(''); - $this->assertTrue($cron_last == state()->get('system.cron_last'), 'Cron does not run when the cron threshold is disabled.'); + $this->assertTrue($cron_last == \Drupal::state()->get('system.cron_last'), 'Cron does not run when the cron threshold is disabled.'); } /** * Make sure exceptions thrown on hook_cron() don't affect other modules. */ function testCronExceptions() { - state()->delete('common_test.cron'); + \Drupal::state()->delete('common_test.cron'); // The common_test module throws an exception. If it isn't caught, the tests // won't finish successfully. // The common_test_cron_helper module sets the 'common_test_cron' variable. $this->cronRun(); - $result = state()->get('common_test.cron'); + $result = \Drupal::state()->get('common_test.cron'); $this->assertEqual($result, 'success', 'Cron correctly handles exceptions thrown during hook_cron() invocations.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php index 8b98ecf..bbc3fb1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php @@ -40,7 +40,7 @@ function setUp() { // Configure 'node' as front page. config('system.site')->set('page.front', 'node')->save(); // Enable front page logging in system_test.module. - state()->set('system_test.front_page_output', 1); + \Drupal::state()->set('system_test.front_page_output', 1); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php index b02d5ff..3be42d0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php @@ -53,6 +53,6 @@ public function testDisabledUpgrade() { require_once DRUPAL_ROOT . '/core/includes/install.inc'; $updates = update_get_update_list(); $this->assertEqual($updates, array(), 'No pending updates after enabling all modules.'); - $this->assertTrue(state()->get('update_test_1_update_dependencies_run'), 'Module update dependencies resolved for disabled modules'); + $this->assertTrue(\Drupal::state()->get('update_test_1_update_dependencies_run'), 'Module update dependencies resolved for disabled modules'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php index ffa786f..b9a97a5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php @@ -81,7 +81,7 @@ public function testSystemVariableUpgrade() { ); foreach ($expected_state as $name => $data) { - $this->assertIdentical(state()->get($name), $data['value']); + $this->assertIdentical(\Drupal::state()->get($name), $data['value']); $deleted = !db_query('SELECT value FROM {variable} WHERE name = :name', array(':name' => $data['variable_name']))->fetchField(); $this->assertTrue($deleted, format_string('Variable !name has been deleted.', array('!name' => $data['variable_name']))); } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index dbdf6a5..7ef1b53 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1540,13 +1540,13 @@ function system_cron_settings($form, &$form_state) { '#submit' => array('system_run_cron_submit'), ); - $status = '

' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - state()->get('system.cron_last')))) . '

'; + $status = '

' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - Drupal::state()->get('system.cron_last')))) . '

'; $form['status'] = array( '#markup' => $status, ); $form['cron_url'] = array( - '#markup' => '

' . t('To run cron from outside the site, go to !cron', array('!cron' => url('cron/' . state()->get('system.cron_key'), array('absolute' => TRUE)))) . '

', + '#markup' => '

' . t('To run cron from outside the site, go to !cron', array('!cron' => url('cron/' . Drupal::state()->get('system.cron_key'), array('absolute' => TRUE)))) . '

', ); $form['cron'] = array( diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 8ddbf09..43e8bbf 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -113,11 +113,11 @@ function hook_admin_paths_alter(&$paths) { function hook_cron() { // Short-running operation example, not using a queue: // Delete all expired records since the last cron run. - $expires = state()->get('mymodule.cron_last_run') ?: REQUEST_TIME; + $expires = \Drupal::state()->get('mymodule.cron_last_run') ?: REQUEST_TIME; db_delete('mymodule_table') ->condition('expires', $expires, '>=') ->execute(); - state()->set('mymodule.cron_last_run', REQUEST_TIME); + \Drupal::state()->set('mymodule.cron_last_run', REQUEST_TIME); // Long-running operation example, leveraging a queue: // Fetch feeds from other sites. @@ -2353,7 +2353,7 @@ function hook_requirements($phase) { // Report cron status if ($phase == 'runtime') { - $cron_last = state()->get('system.cron_last'); + $cron_last = \Drupal::state()->get('system.cron_last'); if (is_numeric($cron_last)) { $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last))); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index a93a124..4545359 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1,4 +1,4 @@ -configuring cron jobs.', array('@cron-handbook' => 'http://drupal.org/cron')); // Determine when cron last ran. - $cron_last = state()->get('system.cron_last'); + $cron_last = Drupal::state()->get('system.cron_last'); if (!is_numeric($cron_last)) { $cron_last = variable_get('install_time', 0); } @@ -294,7 +294,7 @@ function system_requirements($phase) { } $description .= ' ' . $t('You can run cron manually.', array('@cron' => url('admin/reports/status/run-cron'))); - $description .= '
' . $t('To run cron from outside the site, go to !cron', array('!cron' => url('cron/' . state()->get('system.cron_key'), array('absolute' => TRUE)))); + $description .= '
' . $t('To run cron from outside the site, go to !cron', array('!cron' => url('cron/' . Drupal::state()->get('system.cron_key'), array('absolute' => TRUE)))); $requirements['cron'] = array( 'title' => $t('Cron maintenance tasks'), @@ -530,7 +530,7 @@ function system_install() { // Populate the cron key state variable. $cron_key = drupal_hash_base64(drupal_random_bytes(55)); - state()->set('system.cron_key', $cron_key); + Drupal::state()->set('system.cron_key', $cron_key); } /** @@ -734,7 +734,7 @@ function system_schema() { ); $schema['key_value'] = array( - 'description' => 'Generic key-value storage table. See state() for an example.', + 'description' => 'Generic key-value storage table. See the state system for an example.', 'fields' => array( 'collection' => array( 'description' => 'A named collection of key and value pairs.', @@ -1784,7 +1784,7 @@ function system_update_8028() { */ function system_update_8029() { if ($value = update_variable_get('path_alias_whitelist', FALSE)) { - state()->set('system.path_alias_whitelist', $value); + Drupal::state()->set('system.path_alias_whitelist', $value); } update_variable_del('path_alias_whitelist'); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index c4304f4..74839a8 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2965,7 +2965,7 @@ function system_rebuild_module_data() { // Store filenames to allow system_list() and drupal_get_filename() to // retrieve them without having to rebuild or scan the filesystem. - state()->set('system.module.files', $files); + Drupal::state()->set('system.module.files', $files); } return $modules_cache; } @@ -2984,7 +2984,7 @@ function _system_update_bootstrap_status() { $bootstrap_modules[$module] = drupal_get_filename('module', $module); } } - state()->set('system.module.bootstrap', $bootstrap_modules); + Drupal::state()->set('system.module.bootstrap', $bootstrap_modules); } /** @@ -3131,11 +3131,11 @@ function system_rebuild_theme_data() { } // Replace last known theme data state. // @todo Obsolete with proper installation status for themes. - state()->set('system.theme.data', $themes); + Drupal::state()->set('system.theme.data', $themes); // Store filenames to allow system_list() and drupal_get_filename() to // retrieve them without having to rebuild or scan the filesystem. - state()->set('system.theme.files', $files); + Drupal::state()->set('system.theme.files', $files); return $themes; } @@ -3744,7 +3744,7 @@ function system_run_automated_cron() { // Otherwise it could be triggered prematurely by Ajax requests during // installation. if (($threshold = config('system.cron')->get('threshold.autorun')) > 0 && variable_get('install_task') == 'done') { - $cron_last = state()->get('system.cron_last') ?: NULL; + $cron_last = Drupal::state()->get('system.cron_last') ?: NULL; if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) { drupal_cron_run(); } diff --git a/core/modules/system/tests/modules/batch_test/batch_test.module b/core/modules/system/tests/modules/batch_test/batch_test.module index a5f2995..85ee47c 100644 --- a/core/modules/system/tests/modules/batch_test/batch_test.module +++ b/core/modules/system/tests/modules/batch_test/batch_test.module @@ -527,12 +527,12 @@ function _batch_test_theme_callback() { */ function batch_test_stack($data = NULL, $reset = FALSE) { if ($reset) { - state()->delete('batch_test.stack'); + Drupal::state()->delete('batch_test.stack'); } if (!isset($data)) { - return state()->get('batch_test.stack'); + return Drupal::state()->get('batch_test.stack'); } - $stack = state()->get('batch_test.stack'); + $stack = Drupal::state()->get('batch_test.stack'); $stack[] = $data; - state()->set('batch_test.stack', $stack); + Drupal::state()->set('batch_test.stack', $stack); } diff --git a/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module b/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module index e2154ed..ef3ac88 100644 --- a/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module +++ b/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module @@ -14,5 +14,5 @@ * @see common_test_cron() */ function common_test_cron_helper_cron() { - state()->set('common_test.cron', 'success'); + Drupal::state()->set('common_test.cron', 'success'); } diff --git a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module index 6f23ebb..962114c 100644 --- a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module +++ b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module @@ -21,6 +21,6 @@ function entity_cache_test_watchdog($log_entry) { $info = entity_get_info('entity_cache_test'); // Store the information in a system variable to analyze it later in the // test case. - state()->set('entity_cache_test', $info); + Drupal::state()->set('entity_cache_test', $info); } } diff --git a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module index 392a03b..f2e9873 100644 --- a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module +++ b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module @@ -9,5 +9,5 @@ * Implements hook_entity_info_alter(). */ function entity_cache_test_dependency_entity_info_alter(&$info) { - $info['entity_cache_test']['label'] = state()->get('entity_cache_test.label') ?: 'Entity Cache Test'; + $info['entity_cache_test']['label'] = Drupal::state()->get('entity_cache_test.label') ?: 'Entity Cache Test'; } diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 80f1b39..f5959a3 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -56,7 +56,7 @@ function entity_test_entity_types($filter = NULL) { */ function entity_test_entity_info_alter(&$info) { // Optionally specify a translation handler for testing translations. - if (state()->get('entity_test.translation')) { + if (Drupal::state()->get('entity_test.translation')) { foreach(entity_test_entity_types() as $entity_type) { $info[$entity_type]['translation'][$entity_type] = TRUE; } @@ -147,7 +147,7 @@ function entity_test_menu() { */ function entity_test_form_node_form_alter(&$form, &$form_state, $form_id) { $langcode = $form_state['controller']->getFormLangcode($form_state); - state()->set('entity_test.form_langcode', $langcode); + Drupal::state()->set('entity_test.form_langcode', $langcode); } /** diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/system/imagetoolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/system/imagetoolkit/TestToolkit.php index b2634ac..0ca00e1 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/system/imagetoolkit/TestToolkit.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/system/imagetoolkit/TestToolkit.php @@ -106,9 +106,9 @@ public function desaturate($image) { * @see \Drupal\system\Tests\Image\ToolkitTestBase::imageTestGetAllCalls() */ protected function logCall($op, $args) { - $results = state()->get('image_test.results') ?: array(); + $results = \Drupal::state()->get('image_test.results') ?: array(); $results[$op][] = $args; - state()->set('image_test.results', $results); + \Drupal::state()->set('image_test.results', $results); } /** diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module index 8a1aac4..6405a03 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.module +++ b/core/modules/system/tests/modules/menu_test/menu_test.module @@ -492,7 +492,7 @@ function menu_test_callback() { * Callback that test menu_test_menu_tree_set_path(). */ function menu_test_menu_trail_callback() { - $menu_path = state()->get('menu_test.menu_tree_set_path') ?: array(); + $menu_path = Drupal::state()->get('menu_test.menu_tree_set_path') ?: array(); if (!empty($menu_path)) { menu_tree_set_path($menu_path['menu_name'], $menu_path['path']); } @@ -506,8 +506,8 @@ function menu_test_init() { // When requested by one of the MenuTrailTestCase tests, record the initial // active trail during Drupal's bootstrap (before the user is redirected to a // custom 403 or 404 page). See menu_test_custom_403_404_callback(). - if (state()->get('menu_test.record_active_trail') ?: FALSE) { - state()->set('menu_test.active_trail_initial', menu_get_active_trail()); + if (Drupal::state()->get('menu_test.record_active_trail') ?: FALSE) { + Drupal::state()->set('menu_test.active_trail_initial', menu_get_active_trail()); } } @@ -518,8 +518,8 @@ function menu_test_custom_403_404_callback() { // When requested by one of the MenuTrailTestCase tests, record the final // active trail now that the user has been redirected to the custom 403 or // 404 page. See menu_test_init(). - if (state()->get('menu_test.record_active_trail') ?: FALSE) { - state()->set('menu_test.active_trail_final', menu_get_active_trail()); + if (Drupal::state()->get('menu_test.record_active_trail') ?: FALSE) { + Drupal::state()->set('menu_test.active_trail_final', menu_get_active_trail()); } return 'This is menu_test_custom_403_404_callback().'; @@ -585,7 +585,7 @@ function menu_test_custom_theme() { // If an appropriate variable has been set in the database, request the theme // that is stored there. Otherwise, do not attempt to dynamically set the // theme. - if ($theme = state()->get('menu_test.hook_custom_theme_name') ?: FALSE) { + if ($theme = Drupal::state()->get('menu_test.hook_custom_theme_name') ?: FALSE) { return $theme; } } diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index 1d35ea9..39caf92 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -15,7 +15,7 @@ function module_test_permission() { * Manipulate module dependencies to test dependency chains. */ function module_test_system_info_alter(&$info, $file, $type) { - if (state()->get('module_test.dependency') == 'missing dependency') { + if (Drupal::state()->get('module_test.dependency') == 'missing dependency') { if ($file->name == 'forum') { // Make forum module depend on ban. $info['dependencies'][] = 'ban'; @@ -25,7 +25,7 @@ function module_test_system_info_alter(&$info, $file, $type) { $info['dependencies'][] = 'foo'; } } - elseif (state()->get('module_test.dependency') == 'dependency') { + elseif (Drupal::state()->get('module_test.dependency') == 'dependency') { if ($file->name == 'forum') { // Make the forum module depend on ban. $info['dependencies'][] = 'ban'; @@ -35,7 +35,7 @@ function module_test_system_info_alter(&$info, $file, $type) { $info['dependencies'][] = 'php'; } } - elseif (state()->get('module_test.dependency') == 'version dependency') { + elseif (Drupal::state()->get('module_test.dependency') == 'version dependency') { if ($file->name == 'forum') { // Make the forum module depend on ban. $info['dependencies'][] = 'ban'; @@ -155,7 +155,7 @@ function module_test_class_loading() { function module_test_modules_enabled($modules) { // Record the ordered list of modules that were passed in to this hook so we // can check that the modules were enabled in the correct sequence. - state()->set('system_test.module_enable_order', $modules); + Drupal::state()->set('system_test.module_enable_order', $modules); } /** @@ -164,7 +164,7 @@ function module_test_modules_enabled($modules) { function module_test_modules_disabled($modules) { // Record the ordered list of modules that were passed in to this hook so we // can check that the modules were disabled in the correct sequence. - state()->set('module_test.disable_order', $modules); + Drupal::state()->set('module_test.disable_order', $modules); } /** @@ -173,5 +173,5 @@ function module_test_modules_disabled($modules) { function module_test_modules_uninstalled($modules) { // Record the ordered list of modules that were passed in to this hook so we // can check that the modules were uninstalled in the correct sequence. - state()->set('module_test.uninstall_order', $modules); + Drupal::state()->set('module_test.uninstall_order', $modules); } diff --git a/core/modules/system/tests/modules/path_test/path_test.module b/core/modules/system/tests/modules/path_test/path_test.module index dd70498..6f4d580 100644 --- a/core/modules/system/tests/modules/path_test/path_test.module +++ b/core/modules/system/tests/modules/path_test/path_test.module @@ -9,14 +9,14 @@ * Resets the path test results. */ function path_test_reset() { - state()->set('path_test.results', array()); + Drupal::state()->set('path_test.results', array()); } /** * Implements hook_path_update(). */ function path_test_path_update($path) { - $results = state()->get('path_test.results') ?: array(); + $results = Drupal::state()->get('path_test.results') ?: array(); $results['hook_path_update'] = $path; - state()->set('path_test.results', $results); + Drupal::state()->set('path_test.results', $results); } diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module index 4494299..55c0b9e 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -177,7 +177,7 @@ function system_test_redirect_invalid_scheme() { * Implements hook_modules_installed(). */ function system_test_modules_installed($modules) { - if (state()->get('system_test.verbose_module_hooks')) { + if (Drupal::state()->get('system_test.verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_installed fired for @module', array('@module' => $module))); } @@ -188,7 +188,7 @@ function system_test_modules_installed($modules) { * Implements hook_modules_enabled(). */ function system_test_modules_enabled($modules) { - if (state()->get('system_test.verbose_module_hooks')) { + if (Drupal::state()->get('system_test.verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_enabled fired for @module', array('@module' => $module))); } @@ -199,7 +199,7 @@ function system_test_modules_enabled($modules) { * Implements hook_modules_disabled(). */ function system_test_modules_disabled($modules) { - if (state()->get('system_test.verbose_module_hooks')) { + if (Drupal::state()->get('system_test.verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_disabled fired for @module', array('@module' => $module))); } @@ -210,7 +210,7 @@ function system_test_modules_disabled($modules) { * Implements hook_modules_uninstalled(). */ function system_test_modules_uninstalled($modules) { - if (state()->get('system_test.verbose_module_hooks')) { + if (Drupal::state()->get('system_test.verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module))); } @@ -222,7 +222,7 @@ function system_test_modules_uninstalled($modules) { */ function system_test_init() { // Used by FrontPageTestCase to get the results of drupal_is_front_page(). - $frontpage = state()->get('system_test.front_page_output') ?: 0; + $frontpage = Drupal::state()->get('system_test.front_page_output') ?: 0; if ($frontpage && drupal_is_front_page()) { drupal_set_message(t('On front page.')); } @@ -241,11 +241,11 @@ function system_test_exit() { function system_test_system_info_alter(&$info, $file, $type) { // We need a static otherwise the last test will fail to alter common_test. static $test; - if (($dependencies = state()->get('system_test.dependencies')) || $test) { + if (($dependencies = Drupal::state()->get('system_test.dependencies')) || $test) { if ($file->name == 'module_test') { $info['hidden'] = FALSE; $info['dependencies'][] = array_shift($dependencies); - state()->set('system_test.dependencies', $dependencies); + Drupal::state()->set('system_test.dependencies', $dependencies); $test = TRUE; } if ($file->name == 'common_test') { diff --git a/core/modules/system/tests/modules/update_test_1/update_test_1.install b/core/modules/system/tests/modules/update_test_1/update_test_1.install index bf0beb3..3ac73db 100644 --- a/core/modules/system/tests/modules/update_test_1/update_test_1.install +++ b/core/modules/system/tests/modules/update_test_1/update_test_1.install @@ -11,7 +11,7 @@ * @see update_test_2_update_dependencies() */ function update_test_1_update_dependencies() { - state()->set('update_test_1_update_dependencies_run', TRUE); + Drupal::state()->set('update_test_1_update_dependencies_run', TRUE); // These dependencies are used in combination with those declared in // update_test_2_update_dependencies() for the sole purpose of testing that // the results of hook_update_dependencies() are collected correctly and have diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php index 1aa144e..68ed3ba 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php @@ -35,7 +35,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); node_access_rebuild(); - state()->set('node_access_test.private', TRUE); + \Drupal::state()->set('node_access_test.private', TRUE); } /** diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php index 0e7c429..7934c8c 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php @@ -221,7 +221,7 @@ function testTrackerCronIndexing() { $this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save')); // Start indexing backwards from node 3. - state()->set('tracker.index_nid', 3); + \Drupal::state()->set('tracker.index_nid', 3); // Clear the current tracker tables and rebuild them. db_delete('tracker_node') diff --git a/core/modules/tracker/tracker.install b/core/modules/tracker/tracker.install index 429b88e..841d74a 100644 --- a/core/modules/tracker/tracker.install +++ b/core/modules/tracker/tracker.install @@ -9,7 +9,7 @@ * Implements hook_uninstall(). */ function tracker_uninstall() { - state()->delete('tracker.index_nid'); + Drupal::state()->delete('tracker.index_nid'); } /** @@ -18,7 +18,7 @@ function tracker_uninstall() { function tracker_enable() { $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField(); if ($max_nid != 0) { - state()->set('tracker.index_nid', $max_nid); + Drupal::state()->set('tracker.index_nid', $max_nid); // To avoid timing out while attempting to do a complete indexing, we // simply call our cron job to remove stale records and begin the process. tracker_cron(); diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 125b5da..b0cb9f8 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -79,7 +79,7 @@ function tracker_menu() { * process, 'tracker.index_nid' will be 0. */ function tracker_cron() { - $state = state(); + $state = Drupal::state(); $max_nid = $state->get('tracker.index_nid') ?: 0; if ($max_nid > 0) { $batch_size = config('tracker.settings')->get('cron_index_limit'); diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index 63a94d0..65894f1 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -184,7 +184,7 @@ function _update_process_fetch_task($project) { Drupal::keyValueExpirable('update')->setWithExpire('fetch_failures', $fail, $request_time_difference + (60 * 5)); // Whether this worked or not, we did just (try to) check for updates. - state()->set('update.last_check', REQUEST_TIME + $request_time_difference); + Drupal::state()->set('update.last_check', REQUEST_TIME + $request_time_difference); // Now that we processed the fetch task for this project, clear out the // record for this task so we're willing to fetch again. @@ -359,7 +359,7 @@ function _update_cron_notify() { // Track when the last mail was successfully sent to avoid sending // too many e-mails. if ($message['result']) { - state()->set('update.last_email_notification', REQUEST_TIME); + Drupal::state()->set('update.last_email_notification', REQUEST_TIME); } } } diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index 0047a52..96590e0 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -278,7 +278,7 @@ function update_manager_update_form($form, $form_state = array(), $context) { */ function theme_update_manager_update_form($variables) { $form = $variables['form']; - $last = state()->get('update.last_check') ?: 0; + $last = Drupal::state()->get('update.last_check') ?: 0; $output = theme('update_last_check', array('last' => $last)); $output .= drupal_render_children($form); return $output; diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 7dee311..ec14858 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -283,7 +283,7 @@ function update_cron() { $update_config = config('update.settings'); $frequency = $update_config->get('check.interval_days'); $interval = 60 * 60 * 24 * $frequency; - $last_check = state()->get('update.last_check') ?: 0; + $last_check = Drupal::state()->get('update.last_check') ?: 0; if ((REQUEST_TIME - $last_check) > $interval) { // If the configured update interval has elapsed, we want to invalidate // the data for all projects, attempt to re-fetch, and trigger any @@ -296,7 +296,7 @@ function update_cron() { // missing data, and if so, try to fetch the data. update_get_available(TRUE); } - $last_email_notice = state()->get('update.last_email_notification') ?: 0; + $last_email_notice = Drupal::state()->get('update.last_email_notification') ?: 0; if ((REQUEST_TIME - $last_email_notice) > $interval) { // If configured time between notifications elapsed, send email about // updates possibly available. diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc index 607b523..7a79394 100644 --- a/core/modules/update/update.report.inc +++ b/core/modules/update/update.report.inc @@ -33,7 +33,7 @@ function update_status() { function theme_update_report($variables) { $data = $variables['data']; - $last = state()->get('update.last_check') ?: 0; + $last = Drupal::state()->get('update.last_check') ?: 0; $output = theme('update_last_check', array('last' => $last)); if (!is_array($data)) { diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php index b4c5118..1c37da9 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php @@ -101,8 +101,8 @@ function testDynamicAccessPlugin() { $view->setDisplay(); $argument1 = $this->randomName(); $argument2 = $this->randomName(); - state()->set('test_dynamic_access_argument1', $argument1); - state()->set('test_dynamic_access_argument2', $argument2); + \Drupal::state()->set('test_dynamic_access_argument1', $argument1); + \Drupal::state()->set('test_dynamic_access_argument2', $argument2); $access_plugin = $view->display_handler->getPlugin('access'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php index 3f21b88..eb1894e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php @@ -41,7 +41,7 @@ protected function setUp() { */ protected function testAttachment() { // @todo Remove that once http://drupal.org/node/1828444 got in. - state()->set('menu_rebuild_needed', TRUE); + \Drupal::state()->set('menu_rebuild_needed', TRUE); $this->drupalGet('test-display-attachment'); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php index d70468b..04ea163 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php @@ -37,13 +37,13 @@ protected function setUp() { * Tests render functionality. */ public function testRender() { - state()->set('views_render.test', 0); + \Drupal::state()->set('views_render.test', 0); // Make sure that the rendering just calls the preprocess function once. $view = views_get_view('test_view_render'); $view->preview(); - $this->assertEqual(state()->get('views_render.test'), 1); + $this->assertEqual(\Drupal::state()->get('views_render.test'), 1); } } diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php index 93685aa..23b1332 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php @@ -42,8 +42,8 @@ protected function setUp() { */ protected function enableViewsTestModule() { // Define the schema and views data variable before enabling the test module. - state()->set('views_test_data_schema', $this->schemaDefinition()); - state()->set('views_test_data_views_data', $this->viewsData()); + \Drupal::state()->set('views_test_data_schema', $this->schemaDefinition()); + \Drupal::state()->set('views_test_data_views_data', $this->viewsData()); module_enable(array('views_test_data')); $this->resetAll(); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php index 80b659c..6994b8b 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php @@ -45,8 +45,8 @@ protected function setUp() { */ protected function setUpFixtures() { // Define the schema and views data variable before enabling the test module. - state()->set('views_test_data_schema', $this->schemaDefinition()); - state()->set('views_test_data_views_data', $this->viewsData()); + \Drupal::state()->set('views_test_data_schema', $this->schemaDefinition()); + \Drupal::state()->set('views_test_data_views_data', $this->viewsData()); $this->installConfig(array('views', 'views_test_config', 'views_test_data')); foreach ($this->schemaDefinition() as $table => $schema) { diff --git a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php index b153c93..9fed163 100644 --- a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php +++ b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php @@ -30,7 +30,7 @@ protected function defineOptions() { } public function access($account) { - return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == state()->get('test_dynamic_access_argument1') && isset($this->view->args[1]) && $this->view->args[1] == state()->get('test_dynamic_access_argument2'); + return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == \Drupal::state()->get('test_dynamic_access_argument1') && isset($this->view->args[1]) && $this->view->args[1] == \Drupal::state()->get('test_dynamic_access_argument2'); } function get_access_callback() { diff --git a/core/modules/views/tests/views_test_data/views_test_data.install b/core/modules/views/tests/views_test_data/views_test_data.install index 520796d..6b1a868 100644 --- a/core/modules/views/tests/views_test_data/views_test_data.install +++ b/core/modules/views/tests/views_test_data/views_test_data.install @@ -9,7 +9,7 @@ * Implements hook_schema(). */ function views_test_data_schema() { - return state()->get('views_test_data_schema'); + return Drupal::state()->get('views_test_data_schema'); } /** diff --git a/core/modules/views/tests/views_test_data/views_test_data.module b/core/modules/views/tests/views_test_data/views_test_data.module index 40467c6..0412396 100644 --- a/core/modules/views/tests/views_test_data/views_test_data.module +++ b/core/modules/views/tests/views_test_data/views_test_data.module @@ -24,7 +24,7 @@ function views_test_data_test_static_access_callback($access) { } function views_test_data_test_dynamic_access_callback($access, $argument1, $argument2) { - return $access && $argument1 == state()->get('test_dynamic_access_argument1') && $argument2 == state()->get('test_dynamic_access_argument2'); + return $access && $argument1 == Drupal::state()->get('test_dynamic_access_argument1') && $argument2 == Drupal::state()->get('test_dynamic_access_argument2'); } /** @@ -85,9 +85,9 @@ function views_test_data_views_pre_render(ViewExecutable $view) { */ function views_test_data_preprocess_views_view_table(&$variables) { if ($variables['view']->storage->id() == 'test_view_render') { - $views_render_test = state()->get('views_render.test'); + $views_render_test = Drupal::state()->get('views_render.test'); $views_render_test++; - state()->set('views_render.test', $views_render_test); + Drupal::state()->set('views_render.test', $views_render_test); } } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index f1cb911..e765bbb 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -685,7 +685,7 @@ function views_invalidate_cache() { Cache::deleteTags(array('content' => TRUE)); // Set the menu as needed to be rebuilt. - state()->set('menu_rebuild_needed', TRUE); + Drupal::state()->set('menu_rebuild_needed', TRUE); // Invalidate the block cache to update views block derivatives. if (module_exists('block')) { diff --git a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php index d4ba19a..637d7a2 100644 --- a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php +++ b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php @@ -48,12 +48,12 @@ function testSizedMessages() { */ protected function testAlterListMethods() { // Ensure xmlrpc_test.alter() is disabled and retrieve regular list of methods. - state()->set('xmlrpc_test.alter', FALSE); + \Drupal::state()->set('xmlrpc_test.alter', FALSE); $url = url('xmlrpc.php', array('absolute' => TRUE)); $methods1 = xmlrpc($url, array('system.listMethods' => array())); // Enable the alter hook and retrieve the list of methods again. - state()->set('xmlrpc_test.alter', TRUE); + \Drupal::state()->set('xmlrpc_test.alter', TRUE); $methods2 = xmlrpc($url, array('system.listMethods' => array())); $diff = array_diff($methods1, $methods2); diff --git a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module index 11c86c3..4a772ab 100644 --- a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module +++ b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module @@ -68,7 +68,7 @@ function xmlrpc_test_xmlrpc() { * Hide (or not) the system.methodSignature() service depending on a variable. */ function xmlrpc_test_xmlrpc_alter(&$services) { - $xmlprc_alter = state()->get('xmlrpc_test.alter') ?: FALSE; + $xmlprc_alter = Drupal::state()->get('xmlrpc_test.alter') ?: FALSE; if ($xmlprc_alter) { $remove = NULL; foreach ($services as $key => $value) {