diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -264,10 +264,10 @@ } // If still unknown, perform a filesystem scan. if (!isset($files[$type][$name])) { - if (is_null($missing)) { + if (!isset($missing)) { $missing = array(); if (\Drupal::hasService('cache.bootstrap')) { - $cache = \Drupal::cache('bootstrap')->get('drupal_get_filename:missing', TRUE); + $cache = \Drupal::cache('bootstrap')->get('drupal_get_filename:missing'); if ($cache && $cache->data) { $missing = $cache->data; } @@ -295,7 +295,7 @@ // theme list pages. $missing[$type][$name] = TRUE; if (\Drupal::hasService('cache.bootstrap')) { - \Drupal::cache('bootstrap')->set('drupal_get_filename:missing', $missing, REQUEST_TIME); + \Drupal::cache('bootstrap')->set('drupal_get_filename:missing', $missing, REQUEST_TIME + 24 * 60 * 60); } trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', array('@type' => $type, '@name' => $name)), E_USER_WARNING); } diff -u b/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php --- b/core/modules/system/src/Controller/SystemController.php +++ b/core/modules/system/src/Controller/SystemController.php @@ -15,6 +15,7 @@ use Drupal\Core\Menu\MenuLinkTreeInterface; use Drupal\Core\Menu\MenuTreeParameters; use Drupal\Core\Theme\ThemeAccessCheck; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Url; use Drupal\system\SystemManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -67,6 +68,13 @@ protected $menuLinkTree; /** + * The bootstrap cache service. + * + * @var \Drupal\Core\Cache\CacheBackendInterface + */ + protected $bootstrapCache; + + /** * Constructs a new SystemController. * * @param \Drupal\system\SystemManager $systemManager @@ -81,14 +89,17 @@ * The theme handler. * @param \Drupal\Core\Menu\MenuLinkTreeInterface * The menu link tree service. + * @parm \Drupal\Core\Cache\CacheBackendInterface + * The bootstrap cache service. */ - public function __construct(SystemManager $systemManager, QueryFactory $queryFactory, ThemeAccessCheck $theme_access, FormBuilderInterface $form_builder, ThemeHandlerInterface $theme_handler, MenuLinkTreeInterface $menu_link_tree) { + public function __construct(SystemManager $systemManager, QueryFactory $queryFactory, ThemeAccessCheck $theme_access, FormBuilderInterface $form_builder, ThemeHandlerInterface $theme_handler, MenuLinkTreeInterface $menu_link_tree, CacheBackendInterface $bootstrap_cache) { $this->systemManager = $systemManager; $this->queryFactory = $queryFactory; $this->themeAccess = $theme_access; $this->formBuilder = $form_builder; $this->themeHandler = $theme_handler; $this->menuLinkTree = $menu_link_tree; + $this->bootstrapCache = $bootstrap_cache; } /** @@ -101,7 +112,8 @@ $container->get('access_check.theme'), $container->get('form_builder'), $container->get('theme_handler'), - $container->get('menu.link_tree') + $container->get('menu.link_tree'), + $container->get('cache.bootstrap') ); } @@ -187,10 +199,8 @@ */ public function themesPage() { // Clean up the bootstrap "missing files" cache when listing themes. - if (\Drupal::hasService('cache.bootstrap')) { - \Drupal::cache('bootstrap')->invalidate('drupal_get_filename:missing'); - drupal_static_reset('drupal_get_filename:missing'); - } + $this->bootstrapCache->delete('drupal_get_filename:missing'); + drupal_static_reset('drupal_get_filename:missing'); $config = $this->config('system.theme'); // Get all available themes. diff -u b/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php --- b/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -175,10 +175,8 @@ $this->moduleHandler->loadInclude('system', 'inc', 'system.admin'); // Clean up the "missing files" cache when listing modules. - if (\Drupal::hasService('cache.bootstrap')) { - \Drupal::cache('bootstrap')->invalidate('drupal_get_filename:missing'); - drupal_static_reset('drupal_get_filename:missing'); - } + \Drupal::cache('bootstrap')->delete('drupal_get_filename:missing'); + drupal_static_reset('drupal_get_filename:missing'); $form['filters'] = array( '#type' => 'container', diff -u b/core/modules/system/src/Tests/Bootstrap/GetFilenameUnitTest.php b/core/modules/system/src/Tests/Bootstrap/GetFilenameUnitTest.php --- b/core/modules/system/src/Tests/Bootstrap/GetFilenameUnitTest.php +++ b/core/modules/system/src/Tests/Bootstrap/GetFilenameUnitTest.php @@ -73,8 +73,18 @@ // 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 (!(error_reporting() & $severity) || strstr($message, 'is missing from the file system:')) { + return; + } + throw new ErrorException($message, 0, $severity, $file, $line); + }); // Searching for an item that does not exist returns NULL. $this->assertNull(drupal_get_filename('module', $non_existing_module), 'Searching for an item that does not exist returns NULL.'); + // Restore the original error handler. + restore_error_handler(); // Get the missing records static from drupal_get_filename. $missing = &drupal_static('drupal_get_filename:missing'); reverted: --- b/core/modules/system/system.module +++ a/core/modules/system/system.module @@ -1201,12 +1201,6 @@ $cache_backend->garbageCollection(); } - // Clean up the bootstrap "missing files" cache when running cron. - if (\Drupal::hasService('cache.bootstrap')) { - \Drupal::cache('bootstrap')->invalidate('drupal_get_filename:missing'); - drupal_static_reset('drupal_get_filename:missing'); - } - // Clean up the expirable key value database store. if (\Drupal::service('keyvalue.expirable.database') instanceof KeyValueDatabaseExpirableFactory) { \Drupal::service('keyvalue.expirable.database')->garbageCollection(); only in patch2: unchanged: --- a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php +++ b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php @@ -27,7 +27,6 @@ class CommentStringIdEntitiesTest extends KernelTestBase { 'user', 'field', 'field_ui', - 'entity', 'entity_test', 'text', ); only in patch2: unchanged: --- a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php +++ b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php @@ -74,10 +74,20 @@ function testDefault() { * Tests non-existing libraries. */ function testLibraryUnknown() { + // 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 (!(error_reporting() & $severity) || strstr($message, 'is missing from the file system:')) { + return; + } + throw new ErrorException($message, 0, $severity, $file, $line); + }); $build['#attached']['library'][] = 'unknown/unknown'; $assets = AttachedAssets::createFromRenderArray($build); $this->assertIdentical([], $this->assetResolver->getJsAssets($assets, FALSE)[0], 'Unknown library was not added to the page.'); + // Restore the original error handler. + restore_error_handler(); } /** only in patch2: unchanged: --- a/core/modules/system/src/Tests/Entity/EntitySchemaTest.php +++ b/core/modules/system/src/Tests/Entity/EntitySchemaTest.php @@ -28,7 +28,7 @@ class EntitySchemaTest extends EntityUnitTestBase { * * @var array */ - public static $modules = array('menu_link'); + public static $modules = array('menu_link_content'); /** * {@inheritdoc} only in patch2: unchanged: --- a/core/modules/taxonomy/src/Tests/TermKernelTest.php +++ b/core/modules/taxonomy/src/Tests/TermKernelTest.php @@ -23,7 +23,7 @@ class TermKernelTest extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = array( 'filter', 'taxonomy', 'taxonomy_term', 'text', 'user' ); + public static $modules = array( 'filter', 'taxonomy', 'text', 'user' ); /** * {@inheritdoc} only in patch2: unchanged: --- a/core/modules/views/src/Tests/Plugin/RowEntityTest.php +++ b/core/modules/views/src/Tests/Plugin/RowEntityTest.php @@ -24,7 +24,7 @@ class RowEntityTest extends ViewUnitTestBase { * * @var array */ - public static $modules = ['taxonomy', 'text', 'filter', 'field', 'entity', 'system', 'node', 'user']; + public static $modules = ['taxonomy', 'text', 'filter', 'field', 'system', 'node', 'user']; /** * Views used by this test.