diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -5,7 +5,6 @@ * Functions that need to be loaded on every Drupal request. */ -use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; @@ -228,34 +227,33 @@ return $extension_list->getPathname($name); } catch (\InvalidArgumentException $e) { - // Catch the exception and trigger error to maintain existing behavior. - trigger_error(new FormattableMarkup('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING); + // Catch the exception. This will result in triggering an error. } } + else { - if (!isset($files[$type])) { - $files[$type] = []; - } + if (!isset($files[$type])) { + $files[$type] = []; + } - if (isset($filename)) { - $files[$type][$name] = $filename; - } - elseif (!isset($files[$type][$name])) { - // If still unknown, retrieve the file list prepared in state by - // system_rebuild_module_data() and - // \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). - if (!isset($files[$type][$name]) && \Drupal::hasService('state')) { - $files[$type] += \Drupal::state()->get('system.' . $type . '.files', []); + if (isset($filename)) { + $files[$type][$name] = $filename; } - // If still unknown, create a user-level error message. - if (!isset($files[$type][$name])) { - trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING); + elseif (!isset($files[$type][$name])) { + // If still unknown, retrieve the file list prepared in state by + // system_rebuild_module_data() and + // \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). + if (!isset($files[$type][$name]) && \Drupal::hasService('state')) { + $files[$type] += \Drupal::state()->get('system.' . $type . '.files', []); + } } - } - if (isset($files[$type][$name])) { - return $files[$type][$name]; + if (isset($files[$type][$name])) { + return $files[$type][$name]; + } } + // If the filename is still unknown, create a user-level error message. + trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING); } /** diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1071,7 +1071,7 @@ file_ensure_htaccess(); // Prime the drupal_get_filename() static cache with the user module's - // location. + // exact location. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('module', 'user', 'core/modules/user/user.info.yml'); diff -u b/core/includes/install.inc b/core/includes/install.inc --- b/core/includes/install.inc +++ b/core/includes/install.inc @@ -626,7 +626,7 @@ // Before having installed the system module and being able to do a module // rebuild, prime the ModuleExtensionList static cache with the module's - // exact location. + // location. // @todo Try to install system as any other module, see // https://www.drupal.org/node/2719315. \Drupal::service('extension.list.module')->setPathname('system', 'core/modules/system/system.info.yml'); reverted: --- b/core/lib/Drupal/Core/DrupalKernel.php +++ a/core/lib/Drupal/Core/DrupalKernel.php @@ -841,10 +841,7 @@ if (isset($this->container)) { // Save the id of the currently logged in user. if ($this->container->initialized('current_user')) { + $current_user_id = $this->container->get('current_user')->id(); - /** @var \Drupal\Core\Session\AccountProxyInterface $current_user */ - $current_user = $this->container->get('current_user'); - // Ensure to not accidentally initialize the user. - $current_user_id = $current_user->hasAccount() ? $current_user->id() : 0; } // If there is a session, close and save it. diff -u b/core/lib/Drupal/Core/Extension/ExtensionList.php b/core/lib/Drupal/Core/Extension/ExtensionList.php --- b/core/lib/Drupal/Core/Extension/ExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ExtensionList.php @@ -522,7 +522,7 @@ /** * Gets the path to an extension of a specific type (module, theme, etc.). - * + * * The path is the directory in which the .info file is located. This name is * coming from \SplFileInfo. * reverted: --- b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php +++ a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php @@ -306,9 +306,6 @@ * @return string * Returns the human readable name of the module or the machine name passed * in if no matching module is found. - * - * @deprecated in Drupal 8.4.0, will be removed before Drupal 9.0.0. - * Use \Drupal::service('extension.list.module')->getName() instead. */ public function getName($module); reverted: --- b/core/lib/Drupal/Core/Session/AccountProxy.php +++ a/core/lib/Drupal/Core/Session/AccountProxy.php @@ -52,13 +52,6 @@ date_default_timezone_set(drupal_get_user_timezone()); } - /** - * {@inheritdoc} - */ - public function hasAccount() { - return isset($this->account); - } - /** * {@inheritdoc} */ reverted: --- b/core/lib/Drupal/Core/Session/AccountProxyInterface.php +++ a/core/lib/Drupal/Core/Session/AccountProxyInterface.php @@ -6,7 +6,6 @@ * Defines an interface for a service which has the current account stored. * * @ingroup user_api - * @internal */ interface AccountProxyInterface extends AccountInterface { @@ -44,12 +43,4 @@ */ public function setInitialAccountId($account_id); - /** - * Checks whether an account is currently wrapped. - * - * @return bool - * TRUE, if an account is currently wrapped. FALSE otherwise. - */ - public function hasAccount(); - } diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -995,8 +995,11 @@ * * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. This * function is no longer used in Drupal core. + * + * @see https://www.drupal.org/node/2709919 */ function _system_rebuild_module_data_ensure_required($module, &$modules) { + @trigger_error("_system_rebuild_module_data_ensure_required() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. This function is no longer used in Drupal core. See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); if (!empty($module->info['required'])) { foreach ($module->info['dependencies'] as $dependency) { $dependency_name = ModuleHandler::parseDependency($dependency)['name']; @@ -1016,12 +1019,14 @@ * @return \Drupal\Core\Extension\Extension[] * An associative array of module information. * - * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. + * @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. * Use \Drupal::service('extension.list.module')->reset()->list() * instead. Note: You probably don't need the reset() method. + * + * @see https://www.drupal.org/node/2709919 */ function _system_rebuild_module_data() { - @trigger_error("_system_rebuild_module_data() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->reset()->list(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); + @trigger_error("_system_rebuild_module_data() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->reset()->list(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); return \Drupal::service('extension.list.module')->reset()->list(); } @@ -1030,11 +1035,8 @@ * * @return \Drupal\Core\Extension\Extension[] * Array of all available modules and their data. - * - * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. */ function system_rebuild_module_data() { - @trigger_error("system_rebuild_module_data() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->reset()->list(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED); return \Drupal::service('extension.list.module')->reset()->list(); } reverted: --- b/core/tests/Drupal/Tests/Core/Session/AccountProxyTest.php +++ a/core/tests/Drupal/Tests/Core/Session/AccountProxyTest.php @@ -42,17 +42,6 @@ $account_proxy->setInitialAccountId(1); } - /** - * @covers ::hasAccount - */ - public function testHasAccount() { - $account_proxy = new AccountProxy(); - $this->assertFalse($account_proxy->hasAccount()); - - $account_proxy->getAccount(); - $this->assertTrue($account_proxy->hasAccount()); - } - } namespace Drupal\Core\Session; only in patch2: unchanged: --- a/core/modules/filter/tests/src/Functional/FilterFormTest.php +++ b/core/modules/filter/tests/src/Functional/FilterFormTest.php @@ -72,7 +72,7 @@ public function testFilterForm() { // @see https://www.drupal.org/node/2387983 \Drupal::service('module_installer')->install(['filter_test_plugin']); // Force rebuild module data. - _system_rebuild_module_data(); + \Drupal::service('extension.list.module')->reset(); } /** only in patch2: unchanged: --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -625,7 +625,6 @@ function template_preprocess_update_last_check(&$variables) { * version of Drupal core. * * @see \Drupal\Core\Extension\ExtensionDiscovery - * @see _system_rebuild_module_data() */ function update_verify_update_archive($project, $archive_file, $directory) { $errors = []; only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php +++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php @@ -49,20 +49,24 @@ public function testDrupalGetFilename() { // a fixed location and naming. $this->assertIdentical(drupal_get_filename('profile', 'testing'), 'core/profiles/testing/testing.info.yml'); - // Generate a non-existing module name. - $non_existing_module = uniqid("", TRUE); - // Set a custom error handler so we can ignore the file not found error. set_error_handler(function ($severity, $message, $file, $line) { // Skip error handling if this is a "file not found" error. if (strstr($message, 'is missing from the file system:')) { - \Drupal::state()->set('get_filename_test_triggered_error', TRUE); + \Drupal::state()->set('get_filename_test_triggered_error', $message); return; } throw new \ErrorException($message, 0, $severity, $file, $line); }); - $this->assertNull(drupal_get_filename('module', $non_existing_module), 'Searching for an item that does not exist returns NULL.'); - $this->assertTrue(\Drupal::state()->get('get_filename_test_triggered_error'), 'Searching for an item that does not exist triggers an error.'); + $this->assertNull(drupal_get_filename('module', 'there_is_a_module_for_that'), 'Searching for an item that does not exist returns NULL.'); + $this->assertEquals('The following module is missing from the file system: there_is_a_module_for_that', \Drupal::state()->get('get_filename_test_triggered_error')); + + $this->assertNull(drupal_get_filename('theme', 'there_is_a_theme_for_you'), 'Searching for an item that does not exist returns NULL.'); + $this->assertEquals('The following theme is missing from the file system: there_is_a_theme_for_you', \Drupal::state()->get('get_filename_test_triggered_error')); + + $this->assertNull(drupal_get_filename('profile', 'there_is_an_install_profile_for_you'), 'Searching for an item that does not exist returns NULL.'); + $this->assertEquals('The following profile is missing from the file system: there_is_an_install_profile_for_you', \Drupal::state()->get('get_filename_test_triggered_error')); + // Restore the original error handler. restore_error_handler(); }