diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 36c9c741a8c9..6d7826e123ea 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -483,11 +483,6 @@ function &drupal_static($name, $default_value = NULL, $reset = FALSE) { * unit tests with a clean environment. */ function drupal_static_reset($name = NULL) { - switch ($name) { - case 'system_get_module_admin_tasks': - @trigger_error("Calling " . __FUNCTION__ . "() with 'system_get_module_admin_tasks' as an argument is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3038972", E_USER_DEPRECATED); - break; - } drupal_static($name, NULL, TRUE); } diff --git a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php deleted file mode 100644 index ec3b805c971d..000000000000 --- a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php +++ /dev/null @@ -1,218 +0,0 @@ -grouper = $grouper; - $this->optimizer = $optimizer; - $this->dumper = $dumper; - $this->state = $state; - $this->fileSystem = $file_system; - } - - /** - * {@inheritdoc} - * - * The cache file name is retrieved on a page load via a lookup variable that - * contains an associative array. The array key is the hash of the file names - * in $css while the value is the cache file name. The cache file is generated - * in two cases. First, if there is no file name value for the key, which will - * happen if a new file name has been added to $css or after the lookup - * variable is emptied to force a rebuild of the cache. Second, the cache file - * is generated if it is missing on disk. Old cache files are not deleted - * immediately when the lookup variable is emptied, but are deleted after a - * configurable period (@code system.performance.stale_file_threshold @endcode) - * to ensure that files referenced by a cached page will still be available. - */ - public function optimize(array $css_assets, array $libraries) { - // Group the assets. - $css_groups = $this->grouper->group($css_assets); - - // Now optimize (concatenate + minify) and dump each asset group, unless - // that was already done, in which case it should appear in - // drupal_css_cache_files. - // Drupal contrib can override this default CSS aggregator to keep the same - // grouping, optimizing and dumping, but change the strategy that is used to - // determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …). - $map = $this->state->get('drupal_css_cache_files', []); - $css_assets = []; - foreach ($css_groups as $order => $css_group) { - // We have to return a single asset, not a group of assets. It is now up - // to one of the pieces of code in the switch statement below to set the - // 'data' property to the appropriate value. - $css_assets[$order] = $css_group; - unset($css_assets[$order]['items']); - - switch ($css_group['type']) { - case 'file': - // No preprocessing, single CSS asset: just use the existing URI. - if (!$css_group['preprocess']) { - $uri = $css_group['items'][0]['data']; - $css_assets[$order]['data'] = $uri; - } - // Preprocess (aggregate), unless the aggregate file already exists. - else { - $key = $this->generateHash($css_group); - $uri = ''; - if (isset($map[$key])) { - $uri = $map[$key]; - } - if (empty($uri) || !file_exists($uri)) { - // Optimize each asset within the group. - $data = ''; - $current_license = FALSE; - foreach ($css_group['items'] as $css_asset) { - // Ensure license information is available as a comment after - // optimization. - if ($css_asset['license'] !== $current_license) { - $data .= "/* @license " . $css_asset['license']['name'] . " " . $css_asset['license']['url'] . " */\n"; - } - $current_license = $css_asset['license']; - $data .= $this->optimizer->optimize($css_asset); - } - // Per the W3C specification at - // http://www.w3.org/TR/REC-CSS2/cascade.html#at-import, @import - // rules must precede any other style, so we move those to the - // top. The regular expression is expressed in NOWDOC since it is - // detecting backslashes as well as single and double quotes. It - // is difficult to read when represented as a quoted string. - $regexp = <<<'REGEXP' -/@import\s*(?:'(?:\\'|.)*'|"(?:\\"|.)*"|url\(\s*(?:\\[\)\'\"]|[^'")])*\s*\)|url\(\s*'(?:\'|.)*'\s*\)|url\(\s*"(?:\"|.)*"\s*\)).*;/iU -REGEXP; - preg_match_all($regexp, $data, $matches); - $data = preg_replace($regexp, '', $data); - $data = implode('', $matches[0]) . (!empty($matches[0]) ? "\n" : '') . $data; - // Dump the optimized CSS for this group into an aggregate file. - $uri = $this->dumper->dump($data, 'css'); - // Set the URI for this group's aggregate file. - $css_assets[$order]['data'] = $uri; - // Persist the URI for this aggregate file. - $map[$key] = $uri; - $this->state->set('drupal_css_cache_files', $map); - } - else { - // Use the persisted URI for the optimized CSS file. - $css_assets[$order]['data'] = $uri; - } - $css_assets[$order]['preprocessed'] = TRUE; - } - break; - - case 'external': - // We don't do any aggregation and hence also no caching for external - // CSS assets. - $uri = $css_group['items'][0]['data']; - $css_assets[$order]['data'] = $uri; - break; - } - } - - return $css_assets; - } - - /** - * Generate a hash for a given group of CSS assets. - * - * @param array $css_group - * A group of CSS assets. - * - * @return string - * A hash to uniquely identify the given group of CSS assets. - */ - protected function generateHash(array $css_group) { - $css_data = []; - foreach ($css_group['items'] as $css_file) { - $css_data[] = $css_file['data']; - } - return hash('sha256', serialize($css_data)); - } - - /** - * {@inheritdoc} - */ - public function getAll() { - return $this->state->get('drupal_css_cache_files'); - } - - /** - * {@inheritdoc} - */ - public function deleteAll() { - $this->state->delete('drupal_css_cache_files'); - - $delete_stale = function ($uri) { - // Default stale file threshold is 30 days. - if (\Drupal::time()->getRequestTime() - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) { - $this->fileSystem->delete($uri); - } - }; - if (is_dir('assets://css')) { - $this->fileSystem->scanDirectory('assets://css', '/.*/', ['callback' => $delete_stale]); - } - } - -} diff --git a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php deleted file mode 100644 index 2d3597002cf8..000000000000 --- a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php +++ /dev/null @@ -1,216 +0,0 @@ -grouper = $grouper; - $this->optimizer = $optimizer; - $this->dumper = $dumper; - $this->state = $state; - $this->fileSystem = $file_system; - } - - /** - * {@inheritdoc} - * - * The cache file name is retrieved on a page load via a lookup variable that - * contains an associative array. The array key is the hash of the names in - * $files while the value is the cache file name. The cache file is generated - * in two cases. First, if there is no file name value for the key, which will - * happen if a new file name has been added to $files or after the lookup - * variable is emptied to force a rebuild of the cache. Second, the cache file - * is generated if it is missing on disk. Old cache files are not deleted - * immediately when the lookup variable is emptied, but are deleted after a - * configurable period (@code system.performance.stale_file_threshold @endcode) - * to ensure that files referenced by a cached page will still be available. - */ - public function optimize(array $js_assets, array $libraries) { - // Group the assets. - $js_groups = $this->grouper->group($js_assets); - - // Now optimize (concatenate, not minify) and dump each asset group, unless - // that was already done, in which case it should appear in - // system.js_cache_files. - // Drupal contrib can override this default JS aggregator to keep the same - // grouping, optimizing and dumping, but change the strategy that is used to - // determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …). - $map = $this->state->get('system.js_cache_files', []); - $js_assets = []; - foreach ($js_groups as $order => $js_group) { - // We have to return a single asset, not a group of assets. It is now up - // to one of the pieces of code in the switch statement below to set the - // 'data' property to the appropriate value. - $js_assets[$order] = $js_group; - unset($js_assets[$order]['items']); - - switch ($js_group['type']) { - case 'file': - // No preprocessing, single JS asset: just use the existing URI. - if (!$js_group['preprocess']) { - $uri = $js_group['items'][0]['data']; - $js_assets[$order]['data'] = $uri; - } - // Preprocess (aggregate), unless the aggregate file already exists. - else { - $key = $this->generateHash($js_group); - $uri = ''; - if (isset($map[$key])) { - $uri = $map[$key]; - } - if (empty($uri) || !file_exists($uri)) { - // Concatenate each asset within the group. - $data = ''; - $current_license = FALSE; - foreach ($js_group['items'] as $js_asset) { - // Ensure license information is available as a comment after - // optimization. - if ($js_asset['license'] !== $current_license) { - $data .= "/* @license " . $js_asset['license']['name'] . " " . $js_asset['license']['url'] . " */\n"; - } - $current_license = $js_asset['license']; - // Optimize this JS file, but only if it's not yet minified. - if (isset($js_asset['minified']) && $js_asset['minified']) { - $data .= file_get_contents($js_asset['data']); - } - else { - $data .= $this->optimizer->optimize($js_asset); - } - // Append a ';' and a newline after each JS file to prevent them - // from running together. - $data .= ";\n"; - } - // Remove unwanted JS code that cause issues. - $data = $this->optimizer->clean($data); - // Dump the optimized JS for this group into an aggregate file. - $uri = $this->dumper->dump($data, 'js'); - // Set the URI for this group's aggregate file. - $js_assets[$order]['data'] = $uri; - // Persist the URI for this aggregate file. - $map[$key] = $uri; - $this->state->set('system.js_cache_files', $map); - } - else { - // Use the persisted URI for the optimized JS file. - $js_assets[$order]['data'] = $uri; - } - $js_assets[$order]['preprocessed'] = TRUE; - } - break; - - case 'external': - // We don't do any aggregation and hence also no caching for external - // JS assets. - $uri = $js_group['items'][0]['data']; - $js_assets[$order]['data'] = $uri; - break; - } - } - - return $js_assets; - } - - /** - * Generate a hash for a given group of JavaScript assets. - * - * @param array $js_group - * A group of JavaScript assets. - * - * @return string - * A hash to uniquely identify the given group of JavaScript assets. - */ - protected function generateHash(array $js_group) { - $js_data = []; - foreach ($js_group['items'] as $js_file) { - $js_data[] = $js_file['data']; - } - return hash('sha256', serialize($js_data)); - } - - /** - * {@inheritdoc} - */ - public function getAll() { - return $this->state->get('system.js_cache_files'); - } - - /** - * {@inheritdoc} - */ - public function deleteAll() { - $this->state->delete('system.js_cache_files'); - $delete_stale = function ($uri) { - // Default stale file threshold is 30 days. - if (\Drupal::time()->getRequestTime() - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) { - $this->fileSystem->delete($uri); - } - }; - if (is_dir('assets://js')) { - $this->fileSystem->scanDirectory('assets://js', '/.*/', ['callback' => $delete_stale]); - } - } - -} diff --git a/core/lib/Drupal/Core/Block/BlockPluginTrait.php b/core/lib/Drupal/Core/Block/BlockPluginTrait.php index a9567546af6e..55474a1cdb13 100644 --- a/core/lib/Drupal/Core/Block/BlockPluginTrait.php +++ b/core/lib/Drupal/Core/Block/BlockPluginTrait.php @@ -248,9 +248,6 @@ trait BlockPluginTrait { $definition = $this->getPluginDefinition(); $admin_label = $definition['admin_label']; - // @todo This is basically the same as what is done in - // \Drupal\system\MachineNameController::transliterate(), so it might make - // sense to provide a common service for the two. $transliterated = $this->transliteration()->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_'); $transliterated = mb_strtolower($transliterated); diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module index 9ac8f65d1da7..6692621ba317 100644 --- a/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -9,7 +9,6 @@ use Drupal\Core\Breadcrumb\Breadcrumb; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\FieldableEntityInterface; -use Drupal\Core\Field\Plugin\Field\FieldFormatter\TimestampFormatter; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; use Drupal\Core\Render\Element; @@ -18,7 +17,6 @@ use Drupal\Core\Url; use Drupal\field\FieldConfigInterface; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage; -use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface; use Drupal\layout_builder\Form\DefaultsEntityForm; use Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm; use Drupal\layout_builder\Form\OverridesEntityForm; @@ -414,44 +412,3 @@ function layout_builder_theme_suggestions_field_alter(&$suggestions, array $vari } return $suggestions; } - -/** - * Implements hook_ENTITY_TYPE_presave() for entity_view_display entities. - * - * Provides a BC layer for modules providing old configurations. - * - * @see https://www.drupal.org/node/2993639 - * - * @todo Remove this BC layer in drupal:11.0.0. - */ -function layout_builder_entity_view_display_presave(EntityViewDisplayInterface $entity_view_display): void { - if (!$entity_view_display instanceof LayoutEntityDisplayInterface || !$entity_view_display->isLayoutBuilderEnabled()) { - return; - } - - /** @var \Drupal\Core\Field\FormatterPluginManager $field_formatter_manager */ - $field_formatter_manager = \Drupal::service('plugin.manager.field.formatter'); - - foreach ($entity_view_display->getSections() as $section) { - foreach ($section->getComponents() as $component) { - if (str_starts_with($component->getPluginId(), 'field_block:')) { - $configuration = $component->get('configuration'); - $formatter =& $configuration['formatter']; - if ($formatter && isset($formatter['type'])) { - $plugin_definition = $field_formatter_manager->getDefinition($formatter['type'], FALSE); - // Check also potential plugins extending TimestampFormatter. - if (!$plugin_definition || !is_a($plugin_definition['class'], TimestampFormatter::class, TRUE)) { - continue; - } - if (!isset($formatter['settings']['tooltip']) || !isset($formatter['settings']['time_diff'])) { - @trigger_error("Using the 'timestamp' formatter plugin without the 'tooltip' and 'time_diff' settings is deprecated in drupal:10.1.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/2993639", E_USER_DEPRECATED); - $formatter['settings'] += $plugin_definition['class']::defaultSettings(); - // Existing timestamp formatters don't have tooltip. - $formatter['settings']['tooltip']['date_format'] = ''; - $component->set('configuration', $configuration); - } - } - } - } - } -} diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceImageTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceImageTest.php index 19a1a528cf63..0707eebad23b 100644 --- a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceImageTest.php +++ b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceImageTest.php @@ -100,8 +100,6 @@ class MediaSourceImageTest extends MediaSourceTestBase { 'administer media types', 'administer media display', 'view media', - // We need 'access content' for system.machine_name_transliterate. - 'access content', ])); $page = $this->getSession()->getPage(); @@ -126,8 +124,6 @@ class MediaSourceImageTest extends MediaSourceTestBase { 'administer media', 'administer media types', 'view media', - // We need 'access content' for system.machine_name_transliterate. - 'access content', ])); // Test that hook_requirements adds warning about the lack of an image // style. diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml index d9f36cc507f9..d26ab68f91e0 100644 --- a/core/modules/system/config/schema/system.schema.yml +++ b/core/modules/system/config/schema/system.schema.yml @@ -182,10 +182,6 @@ system.performance: gzip: type: boolean label: 'Compress JavaScript files.' - stale_file_threshold: - type: integer - label: 'Stale file threshold' - deprecated: 'The system.performance.stale_file_threshold config key is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3301744' system.rss: type: config_object diff --git a/core/modules/system/src/Controller/AdminController.php b/core/modules/system/src/Controller/AdminController.php index 079a8cc13502..135d6281be79 100644 --- a/core/modules/system/src/Controller/AdminController.php +++ b/core/modules/system/src/Controller/AdminController.php @@ -6,67 +6,20 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\ModuleExtensionList; use Drupal\system\ModuleAdminLinksHelper; use Drupal\user\ModulePermissionsLinkHelper; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Controller for admin section. */ class AdminController extends ControllerBase { - /** - * The module extension list. - * - * @var \Drupal\Core\Extension\ModuleExtensionList - */ - protected $moduleExtensionList; - - /** - * The module admin links service. - * - * @var \Drupal\system\ModuleAdminLinksHelper - */ - protected ModuleAdminLinksHelper $moduleAdminLinks; - - /** - * The module permissions link service. - * - * @var \Drupal\user\ModulePermissionsLinkHelper - */ - protected ModulePermissionsLinkHelper $modulePermissionsLinks; - /** * AdminController constructor. - * - * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module - * The module extension list. - * @param \Drupal\system\ModuleAdminLinksHelper|null $module_admin_links - * The module admin links. - * @param \Drupal\user\ModulePermissionsLinkHelper|null $module_permissions_link - * The module permission link. */ - public function __construct(ModuleExtensionList $extension_list_module, ModuleAdminLinksHelper $module_admin_links = NULL, ModulePermissionsLinkHelper $module_permissions_link = NULL) { - $this->moduleExtensionList = $extension_list_module; - if (!isset($module_admin_links)) { - @trigger_error('Calling ' . __METHOD__ . '() without the $module_admin_tasks_helper argument is deprecated in drupal:10.2.0 and the $module_admin_tasks_helper argument will be required in drupal:11.0.0. See https://www.drupal.org/node/3038972', E_USER_DEPRECATED); - $module_admin_links = \Drupal::service('system.module_admin_links_helper'); - } - $this->moduleAdminLinks = $module_admin_links; - if (!isset($module_permissions_link)) { - @trigger_error('Calling ' . __METHOD__ . ' without the $module_permissions_link argument is deprecated in drupal:10.2.0 and the $module_permissions_link argument will be required in drupal:11.0.0. See https://www.drupal.org/node/3038972', E_USER_DEPRECATED); - $module_permissions_link = \Drupal::service('user.module_permissions_link_helper'); - } - $this->modulePermissionsLinks = $module_permissions_link; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('extension.list.module'), - $container->get('system.module_admin_links_helper'), - $container->get('user.module_permissions_link_helper') - ); + public function __construct( + protected ModuleExtensionList $moduleExtensionList, + protected ModuleAdminLinksHelper $moduleAdminLinks, + protected ModulePermissionsLinkHelper $modulePermissionsLinks, + ) { } /** diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index c7166aa329b1..42a8c7b8a41f 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -101,7 +101,17 @@ class DbUpdateController extends ControllerBase { * @param \Drupal\Core\Asset\AssetQueryStringInterface $assetQueryString * The asset query string. */ - public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry, protected ?AssetQueryStringInterface $assetQueryString = NULL) { + public function __construct( + $root, + KeyValueExpirableFactoryInterface $key_value_expirable_factory, + CacheBackendInterface $cache, + StateInterface $state, + ModuleHandlerInterface $module_handler, + AccountInterface $account, + BareHtmlPageRendererInterface $bare_html_page_renderer, + UpdateRegistry $post_update_registry, + protected AssetQueryStringInterface $assetQueryString, + ) { $this->root = $root; $this->keyValueExpirableFactory = $key_value_expirable_factory; $this->cache = $cache; @@ -110,11 +120,6 @@ class DbUpdateController extends ControllerBase { $this->account = $account; $this->bareHtmlPageRenderer = $bare_html_page_renderer; $this->postUpdateRegistry = $post_update_registry; - if ($this->assetQueryString === NULL) { - $this->assetQueryString = \Drupal::service('asset.query_string'); - @trigger_error('Calling' . __METHOD__ . '() without the $assetQueryString argument is deprecated in drupal:10.2.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3358337', E_USER_DEPRECATED); - } - } /** diff --git a/core/modules/system/src/DateFormatListBuilder.php b/core/modules/system/src/DateFormatListBuilder.php index 8eacfaca2bd2..ad2c2223f3ee 100644 --- a/core/modules/system/src/DateFormatListBuilder.php +++ b/core/modules/system/src/DateFormatListBuilder.php @@ -17,13 +17,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; */ class DateFormatListBuilder extends ConfigEntityListBuilder { - /** - * The date formatter service. - * - * @var \Drupal\Core\Datetime\DateFormatterInterface - */ - protected $dateFormatter; - /** * Constructs a new DateFormatListBuilder object. * @@ -31,19 +24,18 @@ class DateFormatListBuilder extends ConfigEntityListBuilder { * The entity type definition. * @param \Drupal\Core\Entity\EntityStorageInterface $storage * The entity storage class. - * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter + * @param \Drupal\Core\Datetime\DateFormatterInterface $dateFormatter * The date formatter service. - * @param \Drupal\Component\Datetime\TimeInterface|null $time + * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $date_formatter, protected ?TimeInterface $time = NULL) { + public function __construct( + EntityTypeInterface $entity_type, + EntityStorageInterface $storage, + protected DateFormatterInterface $dateFormatter, + protected TimeInterface $time, + ) { parent::__construct($entity_type, $storage); - - $this->dateFormatter = $date_formatter; - if ($this->time === NULL) { - @trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3112298', E_USER_DEPRECATED); - $this->time = \Drupal::service('datetime.time'); - } } /** diff --git a/core/modules/system/src/EventSubscriber/ConfigCacheTag.php b/core/modules/system/src/EventSubscriber/ConfigCacheTag.php index 06fdde86103c..4a7e4b81809d 100644 --- a/core/modules/system/src/EventSubscriber/ConfigCacheTag.php +++ b/core/modules/system/src/EventSubscriber/ConfigCacheTag.php @@ -14,37 +14,14 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; */ class ConfigCacheTag implements EventSubscriberInterface { - /** - * The theme handler. - * - * @var \Drupal\Core\Extension\ThemeHandlerInterface - */ - protected $themeHandler; - - /** - * The cache tags invalidator. - * - * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface - */ - protected $cacheTagsInvalidator; - /** * Constructs a ConfigCacheTag object. - * - * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler - * The theme handler. - * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator - * The cache tags invalidator. - * @param \Drupal\Core\Theme\Registry|null $themeRegistry - * The theme registry. */ - public function __construct(ThemeHandlerInterface $theme_handler, CacheTagsInvalidatorInterface $cache_tags_invalidator, protected ?Registry $themeRegistry = NULL) { - $this->themeHandler = $theme_handler; - $this->cacheTagsInvalidator = $cache_tags_invalidator; - if ($this->themeRegistry === NULL) { - @trigger_error('Calling ' . __METHOD__ . '() without the $themeRegistry argument is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3355227', E_USER_DEPRECATED); - $this->themeRegistry = \Drupal::service('theme.registry'); - } + public function __construct( + protected ThemeHandlerInterface $themeHandler, + protected CacheTagsInvalidatorInterface $cacheTagsInvalidator, + protected Registry $themeRegistry, + ) { } /** diff --git a/core/modules/system/src/Form/DateFormatDeleteForm.php b/core/modules/system/src/Form/DateFormatDeleteForm.php index 56be2806c58e..419cf4972814 100644 --- a/core/modules/system/src/Form/DateFormatDeleteForm.php +++ b/core/modules/system/src/Form/DateFormatDeleteForm.php @@ -14,27 +14,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface; */ class DateFormatDeleteForm extends EntityDeleteForm { - /** - * The date formatter service. - * - * @var \Drupal\Core\Datetime\DateFormatterInterface - */ - protected $dateFormatter; - /** * Constructs a DateFormatDeleteForm object. - * - * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter - * The date formatter service. - * @param \Drupal\Component\Datetime\TimeInterface|null $time - * The time service. */ - public function __construct(DateFormatterInterface $date_formatter, protected ?TimeInterface $time = NULL) { - $this->dateFormatter = $date_formatter; - if ($this->time === NULL) { - @trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3112298', E_USER_DEPRECATED); - $this->time = \Drupal::service('datetime.time'); - } + public function __construct( + protected DateFormatterInterface $dateFormatter, + protected TimeInterface $time, + ) { } /** diff --git a/core/modules/system/src/Form/DateFormatEditForm.php b/core/modules/system/src/Form/DateFormatEditForm.php index 538076cb4709..177082957407 100644 --- a/core/modules/system/src/Form/DateFormatEditForm.php +++ b/core/modules/system/src/Form/DateFormatEditForm.php @@ -22,15 +22,15 @@ class DateFormatEditForm extends DateFormatFormBase { * The date service. * @param \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $date_format_storage * The date format storage. - * @param \Drupal\Component\Datetime\TimeInterface|null $time + * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. */ - public function __construct(DateFormatterInterface $date_formatter, ConfigEntityStorageInterface $date_format_storage, protected ?TimeInterface $time = NULL) { + public function __construct( + DateFormatterInterface $date_formatter, + ConfigEntityStorageInterface $date_format_storage, + protected TimeInterface $time, + ) { parent::__construct($date_formatter, $date_format_storage); - if ($this->time === NULL) { - @trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3112298', E_USER_DEPRECATED); - $this->time = \Drupal::service('datetime.time'); - } } /** diff --git a/core/modules/system/src/MachineNameController.php b/core/modules/system/src/MachineNameController.php deleted file mode 100644 index 693a271eaee9..000000000000 --- a/core/modules/system/src/MachineNameController.php +++ /dev/null @@ -1,99 +0,0 @@ -transliteration = $transliteration; - $this->tokenGenerator = $token_generator; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('transliteration'), - $container->get('csrf_token') - ); - } - - /** - * Transliterates a string in given language. Various postprocessing possible. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * The input string and language for the transliteration. - * Optionally may contain the replace_pattern, replace, lowercase parameters. - * - * @return \Symfony\Component\HttpFoundation\JsonResponse - * The transliterated string. - */ - public function transliterate(Request $request) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3367037', E_USER_DEPRECATED); - $text = $request->query->get('text'); - $langcode = $request->query->get('langcode'); - $replace_pattern = $request->query->get('replace_pattern'); - $replace_token = $request->query->get('replace_token'); - $replace = $request->query->get('replace'); - $lowercase = $request->query->get('lowercase'); - - $transliterated = $this->transliteration->transliterate($text, $langcode, '_'); - if ($lowercase) { - $transliterated = mb_strtolower($transliterated); - } - - if (isset($replace_pattern) && isset($replace)) { - if (!isset($replace_token)) { - throw new AccessDeniedHttpException("Missing 'replace_token' query parameter."); - } - elseif (!$this->tokenGenerator->validate($replace_token, $replace_pattern)) { - throw new AccessDeniedHttpException("Invalid 'replace_token' query parameter."); - } - - // Quote the pattern delimiter and remove null characters to avoid the e - // or other modifiers being injected. - $transliterated = preg_replace('@' . strtr($replace_pattern, ['@' => '\@', chr(0) => '']) . '@', $replace, $transliterated); - } - return new JsonResponse($transliterated); - } - -} diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index 59ec59ee31fa..035aa5619c04 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -111,85 +111,6 @@ class GDToolkit extends ImageToolkitBase { ); } - /** - * {@inheritdoc} - */ - public function __get(string $name) { - if ($name === 'resource') { - @trigger_error('Accessing the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED); - return $this->image; - } - } - - /** - * {@inheritdoc} - */ - public function __set(string $name, mixed $value): void { - if ($name === 'resource') { - @trigger_error('Setting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED); - $this->image = $value; - } - } - - /** - * {@inheritdoc} - */ - public function __isset(string $name): bool { - if ($name === 'resource') { - @trigger_error('Checking the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED); - return isset($this->image); - } - return FALSE; - } - - /** - * {@inheritdoc} - */ - public function __unset(string $name): void { - if ($name === 'resource') { - @trigger_error('Unsetting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED); - unset($this->image); - } - } - - /** - * Sets the GD image resource. - * - * @param \GdImage $resource - * The GD image resource. - * - * @return $this - * An instance of the current toolkit object. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * \Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage() instead. - * - * @see https://www.drupal.org/node/3265963 - */ - public function setResource($resource) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage() instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED); - if (!$resource instanceof \GdImage) { - throw new \InvalidArgumentException('Invalid resource argument'); - } - return $this->setImage($resource); - } - - /** - * Retrieves the GD image resource. - * - * @return \GdImage|null - * The GD image resource, or NULL if not available. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * \Drupal\system\Plugin\ImageToolkit\GDToolkit::getImage() instead. - * - * @see https://www.drupal.org/node/3265963 - */ - public function getResource() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::getImage() instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED); - return $this->getImage(); - } - /** * Sets an image or resets existing one. * diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2de128319862..2092aee4491b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -13,16 +13,8 @@ use Drupal\Core\Asset\AttachedAssetsInterface; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Query\AlterableInterface; -use Drupal\Core\Datetime\TimeZoneFormHelper; use Drupal\Core\Entity\ContentEntityTypeInterface; -use Drupal\Core\Entity\EntityViewModeInterface; -use Drupal\Core\Entity\EntityFormModeInterface; -use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Extension\Extension; -use Drupal\Core\Field\Plugin\Field\FieldFormatter\TimestampFormatter; -use Drupal\Core\File\Exception\FileException; -use Drupal\Core\File\Exception\InvalidStreamWrapperException; -use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\KeyValueStore\KeyValueDatabaseExpirableFactory; use Drupal\Core\Language\LanguageInterface; @@ -35,7 +27,6 @@ use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\LocalStream; use Drupal\Core\StreamWrapper\StreamWrapperManager; use Drupal\Core\Url; -use Psr\Http\Client\ClientExceptionInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; @@ -967,35 +958,6 @@ function system_admin_compact_mode() { return \Drupal::request()->cookies->get('Drupal_visitor_admin_compact_mode', \Drupal::config('system.site')->get('admin_compact_mode')); } -/** - * Generate a list of tasks offered by a specified module. - * - * @param string $module - * Module name. - * @param string|array $module_name - * The module's display name. Passing information, as provided by - * \Drupal::service('extension.list.module')->getExtensionInfo() is - * deprecated in drupal:10.2.0. Pass only $info["name"] instead. - * - * @return array - * An array of task links. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the - * 'system.module_admin_links_helper' service with the getModuleAdminLinks() method - * and 'user.module_permissions_link_helper' service with the - * ::getModulePermissionsLink() method instead. - * - * @see https://www.drupal.org/node/3038972 - */ -function system_get_module_admin_tasks($module, string|array $module_name) { - @trigger_error("system_get_module_admin_tasks() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the 'system.module_admin_links_helper' service with the getModuleAdminLinks() method and 'user.module_permissions_link_helper' service with the ::getModulePermissionsLink() method instead. See https://www.drupal.org/node/3038972", E_USER_DEPRECATED); - $module_admin_links = \Drupal::service('system.module_admin_links_helper')->getModuleAdminLinks($module); - if ($module_permissions_link = \Drupal::service('user.module_permissions_link_helper')->getModulePermissionsLink($module, $module_name)) { - $module_admin_links["user.admin_permissions.{$module}"] = $module_permissions_link; - } - return $module_admin_links; -} - /** * Implements hook_cron(). * @@ -1055,111 +1017,6 @@ function system_mail($key, &$message, $params) { $message['body'][] = $body; } -/** - * Generate an array of time zones and their local time&date. - * - * @param mixed $blank - * If evaluates true, prepend an empty time zone option to the array. - * @param bool $grouped - * (optional) Whether the timezones should be grouped by region. - * - * @return array - * An array or nested array containing time zones, keyed by the system name. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. This function - * is no longer used in Drupal core. Use - * \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList() or - * \DateTimeZone::listIdentifiers() instead. - * - * @see https://www.drupal.org/node/3023528 - */ -function system_time_zones($blank = NULL, $grouped = FALSE) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. This function is no longer used in Drupal core. Use \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(), \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion() or \DateTimeZone::listIdentifiers() instead. See https://www.drupal.org/node/3023528', E_USER_DEPRECATED); - return $grouped ? TimeZoneFormHelper::getOptionsListByRegion((bool) $blank) : TimeZoneFormHelper::getOptionsList((bool) $blank); -} - -/** - * Attempts to get a file using Guzzle HTTP client and to store it locally. - * - * @param string $url - * The URL of the file to grab. - * @param string $destination - * Stream wrapper URI specifying where the file should be placed. If a - * directory path is provided, the file is saved into that directory under - * its original name. If the path contains a filename as well, that one will - * be used instead. - * If this value is omitted, the site's default files scheme will be used, - * usually "public://". - * @param bool $managed - * If this is set to TRUE, the file API hooks will be invoked and the file is - * registered in the database. - * @param int $replace - * Replace behavior when the destination file already exists: - * - FileSystemInterface::EXISTS_REPLACE: Replace the existing file. - * - FileSystemInterface::EXISTS_RENAME: Append _{incrementing number} until - * the filename is unique. - * - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE. - * - * @return mixed - * One of these possibilities: - * - If it succeeds and $managed is FALSE, the location where the file was - * saved. - * - If it succeeds and $managed is TRUE, a \Drupal\file\FileInterface - * object which describes the file. - * - If it fails, FALSE. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no - * replacement. - * - * @see https://www.drupal.org/node/3223362 - */ -function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FileSystemInterface::EXISTS_RENAME) { - @trigger_error('system_retrieve_file is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3223362', E_USER_DEPRECATED); - $parsed_url = parse_url($url); - /** @var \Drupal\Core\File\FileSystemInterface $file_system */ - $file_system = \Drupal::service('file_system'); - if (!isset($destination)) { - $path = $file_system->basename($parsed_url['path']); - $path = \Drupal::config('system.file')->get('default_scheme') . '://' . $path; - $path = \Drupal::service('stream_wrapper_manager')->normalizeUri($path); - } - else { - if (is_dir($file_system->realpath($destination))) { - // Prevent URIs with triple slashes when glueing parts together. - $path = str_replace('///', '//', "$destination/") . \Drupal::service('file_system')->basename($parsed_url['path']); - } - else { - $path = $destination; - } - } - try { - $data = (string) \Drupal::httpClient() - ->get($url) - ->getBody(); - if ($managed) { - /** @var \Drupal\file\FileRepositoryInterface $file_repository */ - $file_repository = \Drupal::service('file.repository'); - $local = $file_repository->writeData($data, $path, $replace); - } - else { - $local = $file_system->saveData($data, $path, $replace); - } - } - catch (ClientExceptionInterface $exception) { - \Drupal::messenger()->addError(t('Failed to fetch file due to error "%error"', ['%error' => $exception->getMessage()])); - return FALSE; - } - catch (FileException | InvalidStreamWrapperException $e) { - \Drupal::messenger()->addError(t('Failed to save file due to error "%error"', ['%error' => $e->getMessage()])); - return FALSE; - } - if (!$local) { - \Drupal::messenger()->addError(t('@remote could not be saved to @path.', ['@remote' => $url, '@path' => $path])); - } - - return $local; -} - /** * Implements hook_entity_type_build(). */ @@ -1363,62 +1220,3 @@ function system_archiver_info_alter(&$info) { unset($info['Zip']); } } - -/** - * Implements hook_ENTITY_TYPE_presave() for entity_view_display entities. - * - * Provides a BC layer for modules providing old configurations. - * - * @see https://www.drupal.org/node/2993639 - * - * @todo Remove this BC layer in drupal:11.0.0. - */ -function system_entity_view_display_presave(EntityViewDisplayInterface $entity_view_display): void { - /** @var \Drupal\Core\Field\FormatterPluginManager $field_formatter_manager */ - $field_formatter_manager = \Drupal::service('plugin.manager.field.formatter'); - - foreach ($entity_view_display->getComponents() as $name => $component) { - if (empty($component['type'])) { - continue; - } - if (!$plugin_definition = $field_formatter_manager->getDefinition($component['type'], FALSE)) { - continue; - } - - // Check also potential plugins that extends TimestampFormatter. - if (!is_a($plugin_definition['class'], TimestampFormatter::class, TRUE)) { - continue; - } - - if (!isset($component['settings']['tooltip']) || !isset($component['settings']['time_diff'])) { - @trigger_error("Using the 'timestamp' formatter plugin without the 'tooltip' and 'time_diff' settings is deprecated in drupal:10.1.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/2993639", E_USER_DEPRECATED); - $entity_view_display->setComponent($name, $component); - } - } -} - -/** - * Implements hook_ENTITY_TYPE_presave() for view mode entities. - * - * Sets the description property to an empty string. - * - * @todo Remove this BC layer in drupal:11.0.0. - */ -function system_entity_view_mode_presave(EntityViewModeInterface $entity_view_mode) { - if ($entity_view_mode->get('description') === NULL) { - $entity_view_mode->set('description', ''); - } -} - -/** - * Implements hook_ENTITY_TYPE_presave() for form mode entities. - * - * Sets the description property to an empty string. - * - * @todo Remove this BC layer in drupal:11.0.0. - */ -function system_entity_form_mode_presave(EntityFormModeInterface $entity_form_mode) { - if ($entity_form_mode->get('description') === NULL) { - $entity_form_mode->set('description', ''); - } -} diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index dee60fb189cb..5b404cae30ba 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -143,16 +143,6 @@ system.admin_compact_page: requirements: _permission: 'access administration pages' -# @todo Deprecate this route once -# https://www.drupal.org/i/3159210 is fixed, or remove it in Drupal 11. -# @see https://www.drupal.org/node/3367037 -system.machine_name_transliterate: - path: '/machine_name/transliterate' - defaults: - _controller: '\Drupal\system\MachineNameController::transliterate' - requirements: - _permission: 'access content' - system.site_information_settings: path: '/admin/config/system/site-information' defaults: diff --git a/core/modules/system/tests/modules/database_statement_monitoring_test/database_statement_monitoring_test.info.yml b/core/modules/system/tests/modules/database_statement_monitoring_test/database_statement_monitoring_test.info.yml deleted file mode 100644 index 33b576e85455..000000000000 --- a/core/modules/system/tests/modules/database_statement_monitoring_test/database_statement_monitoring_test.info.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: 'Database Statement Monitoring Test' -type: module -description: 'Support module for Database layer tests that need to monitor executed database statements.' -package: Testing -version: VERSION -lifecycle: deprecated -lifecycle_link: 'https://www.drupal.org/node/3318162' diff --git a/core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php b/core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php deleted file mode 100644 index 553755104a46..000000000000 --- a/core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php +++ /dev/null @@ -1,75 +0,0 @@ -loggedStatements[] = str_replace(array_keys($stringified_args), array_values($stringified_args), $query); - } - return parent::query($query, $args, $options); - } - - /** - * Resets logged statements. - * - * @return $this - */ - public function resetLoggedStatements() { - $this->loggedStatements = []; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getDriverClass($class) { - static $fixed_namespace; - if (!$fixed_namespace) { - // Override because we've altered the namespace in - // \Drupal\KernelTests\Core\Cache\EndOfTransactionQueriesTest::getDatabaseConnectionInfo() - // to use the logging Connection classes. Set to a proper database driver - // namespace. - $this->connectionOptions['namespace'] = (new \ReflectionClass(get_parent_class($this)))->getNamespaceName(); - $fixed_namespace = TRUE; - } - return parent::getDriverClass($class); - } - - /** - * Returns the executed queries. - * - * @return string[] - */ - public function getLoggedStatements() { - return $this->loggedStatements; - } - -} diff --git a/core/modules/system/tests/modules/database_statement_monitoring_test/src/mysql/Connection.php b/core/modules/system/tests/modules/database_statement_monitoring_test/src/mysql/Connection.php deleted file mode 100644 index 2af9c20b7c9f..000000000000 --- a/core/modules/system/tests/modules/database_statement_monitoring_test/src/mysql/Connection.php +++ /dev/null @@ -1,21 +0,0 @@ -verifyPageCache($nonempty_entity_listing_url, 'HIT', $nonempty_entity_listing_cache_tags); } - /** - * Creates a cache ID from a list of cache keys and a set of cache contexts. - * - * @param string[] $keys - * A list of cache keys. - * @param string[] $contexts - * A set of cache contexts. - * - * @return string - * The cache ID string. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no - * replacement. - * - * @see https://www.drupal.org/node/3354596 - */ - protected function createCacheId(array $keys, array $contexts) { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3354596', E_USER_DEPRECATED); - $cid_parts = $keys; - - $contexts = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($contexts); - $cid_parts = array_merge($cid_parts, $contexts->getKeys()); - - return implode(':', $cid_parts); - } - /** * Verify that a given render cache entry exists, with the correct cache tags. * diff --git a/core/modules/system/tests/src/Functional/System/RetrieveFileTest.php b/core/modules/system/tests/src/Functional/System/RetrieveFileTest.php deleted file mode 100644 index 1620e88cd95d..000000000000 --- a/core/modules/system/tests/src/Functional/System/RetrieveFileTest.php +++ /dev/null @@ -1,63 +0,0 @@ -mkdir($source_dir = 'public://' . $this->randomMachineName()); - // cSpell:disable-next-line - $filename = 'Файл для тестирования ' . $this->randomMachineName(); - $url = \Drupal::service('file_url_generator')->generateAbsoluteString($source_dir . '/' . $filename); - $retrieved_file = system_retrieve_file($url); - $this->assertFalse($retrieved_file, 'Non-existent file not fetched.'); - - // Actually create that file, download it via HTTP and test the returned path. - file_put_contents($source_dir . '/' . $filename, 'testing'); - $retrieved_file = system_retrieve_file($url); - - // URLs could not contains characters outside the ASCII set so $filename - // has to be encoded. - $encoded_filename = rawurlencode($filename); - - $this->assertEquals('public://' . $encoded_filename, $retrieved_file, 'Sane path for downloaded file returned (public:// scheme).'); - $this->assertFileExists($retrieved_file); - $this->assertEquals(7, filesize($retrieved_file), 'File size of downloaded file is correct (public:// scheme).'); - /** @var \Drupal\Core\File\FileSystemInterface $file_system */ - $file_system = \Drupal::service('file_system'); - $file_system->delete($retrieved_file); - - // Test downloading file to a different location. - $file_system->mkdir($target_dir = 'temporary://' . $this->randomMachineName()); - $retrieved_file = system_retrieve_file($url, $target_dir); - $this->assertEquals("{$target_dir}/{$encoded_filename}", $retrieved_file, 'Sane path for downloaded file returned (temporary:// scheme).'); - $this->assertFileExists($retrieved_file); - $this->assertEquals(7, filesize($retrieved_file), 'File size of downloaded file is correct (temporary:// scheme).'); - $file_system->delete($retrieved_file); - - $file_system->deleteRecursive($source_dir); - $file_system->deleteRecursive($target_dir); - } - -} diff --git a/core/modules/system/tests/src/Functional/Update/TimestampFormatterSettingsUpdateTest.php b/core/modules/system/tests/src/Functional/Update/TimestampFormatterSettingsUpdateTest.php deleted file mode 100644 index 9b85c14867ea..000000000000 --- a/core/modules/system/tests/src/Functional/Update/TimestampFormatterSettingsUpdateTest.php +++ /dev/null @@ -1,75 +0,0 @@ -databaseDumpFiles = [ - __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz', - __DIR__ . '/../../../../../layout_builder/tests/fixtures/update/layout-builder.php', - __DIR__ . '/../../../../../system/tests/fixtures/update/drupal.timestamp-formatter-settings-2921810.php', - ]; - } - - /** - * Tests the update of timestamp formatter settings. - * - * @covers \system_post_update_timestamp_formatter - * @covers \views_post_update_timestamp_formatter - * @covers \layout_builder_post_update_timestamp_formatter - */ - public function testPostUpdateTimestampFormatter(): void { - $config_factory = \Drupal::configFactory(); - - $test_cases = [ - // Timestamp formatter in entity view display. - 'content.field_foo.settings' => 'core.entity_view_display.node.page.default', - // Timestamp formatter in view. - 'display.default.display_options.fields.changed.settings' => 'views.view.content', - // Timestamp formatter in Layout Builder field block. - 'third_party_settings.layout_builder.sections.0.components.93bf4359-06a6-4263-bce9-15c90dc8f357.configuration.formatter.settings' => 'core.entity_view_display.node.page.default', - ]; - - foreach ($test_cases as $config_path => $config_name) { - // Check that 'tooltip' and 'time_diff' are missing before update. - $settings = $config_factory->get($config_name)->get($config_path); - Assert::assertArrayNotHasKey('tooltip', $settings); - Assert::assertArrayNotHasKey('time_diff', $settings); - } - - $this->runUpdates(); - - foreach ($test_cases as $config_path => $config_name) { - // Check that 'tooltip' and 'time_diff' were created after update. - $settings = $config_factory->get($config_name)->get($config_path); - Assert::assertArrayHasKey('tooltip', $settings); - // Check that 'tooltip' is disabled for existing formatters. - Assert::assertSame([ - 'date_format' => '', - 'custom_date_format' => '', - ], $settings['tooltip']); - Assert::assertArrayHasKey('time_diff', $settings); - } - } - -} diff --git a/core/modules/system/tests/src/Functional/Update/UpdateDescriptionConfigurationPostUpdate.php b/core/modules/system/tests/src/Functional/Update/UpdateDescriptionConfigurationPostUpdate.php deleted file mode 100644 index 03a9b9b78a4a..000000000000 --- a/core/modules/system/tests/src/Functional/Update/UpdateDescriptionConfigurationPostUpdate.php +++ /dev/null @@ -1,45 +0,0 @@ -databaseDumpFiles = [ - __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz', - ]; - } - - /** - * Ensure that an empty string is added as a default value for description. - */ - public function testUpdateDescriptionConfigurationPostUpdate(): void { - $view_mode = EntityViewMode::load('block_content.full'); - $this->assertNull($view_mode->get('description')); - - $this->runUpdates(); - - $view_mode = EntityViewMode::load('block_content.full'); - $this->assertSame('', $view_mode->get('description')); - } - -} diff --git a/core/modules/system/tests/src/Kernel/System/SystemFunctionsLegacyTest.php b/core/modules/system/tests/src/Kernel/System/SystemFunctionsLegacyTest.php deleted file mode 100644 index 2b4d1fc49867..000000000000 --- a/core/modules/system/tests/src/Kernel/System/SystemFunctionsLegacyTest.php +++ /dev/null @@ -1,54 +0,0 @@ -expectDeprecation('system_time_zones() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. This function is no longer used in Drupal core. Use \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(), \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion() or \DateTimeZone::listIdentifiers() instead. See https://www.drupal.org/node/3023528'); - system_time_zones(); - } - - /** - * @covers ::system_retrieve_file - */ - public function testSystemRetrieveFile() { - $this->expectDeprecation('system_retrieve_file is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3223362'); - $retrieved_file = system_retrieve_file('http://example.com/foo.txt'); - $this->assertFalse($retrieved_file); - } - - /** - * Tests system_get_module_admin_tasks() deprecation. - * - * @see system_get_module_admin_tasks() - * @see drupal_static_reset() - */ - public function testSystemGetModuleAdminTasksDeprecation(): void { - $this->expectDeprecation("system_get_module_admin_tasks() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the 'system.module_admin_links_helper' service with the getModuleAdminLinks() method and 'user.module_permissions_link_helper' service with the ::getModulePermissionsLink() method instead. See https://www.drupal.org/node/3038972"); - system_get_module_admin_tasks('foo', 'Foo'); - $this->expectDeprecation("Calling drupal_static_reset() with 'system_get_module_admin_tasks' as an argument is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3038972"); - drupal_static_reset('system_get_module_admin_tasks'); - } - -} diff --git a/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php b/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php deleted file mode 100644 index b1608e620120..000000000000 --- a/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php +++ /dev/null @@ -1,140 +0,0 @@ -tokenGenerator = $this->prophesize(CsrfTokenGenerator::class); - $this->tokenGenerator->validate(Argument::cetera())->will(function ($args) { - return $args[0] === 'token-' . $args[1]; - }); - - $this->machineNameController = new MachineNameController(new PhpTransliteration(), $this->tokenGenerator->reveal()); - } - - /** - * Data provider for testMachineNameController(). - * - * @see testMachineNameController() - * - * @return array - * An array containing: - * - An array of request parameters. - * - The expected content of the JSONresponse. - */ - public static function providerTestMachineNameController() { - // cspell:ignore äwesome - $valid_data = [ - [['text' => 'Bob', 'langcode' => 'en'], '"Bob"'], - [['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE], '"bob"'], - [['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob'], '"Alice"'], - [['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Tom'], '"Bob"'], - [['text' => 'Äwesome', 'langcode' => 'en', 'lowercase' => TRUE], '"awesome"'], - [['text' => 'Äwesome', 'langcode' => 'de', 'lowercase' => TRUE], '"aewesome"'], - // Tests special characters replacement in the input text. - [['text' => 'B?!"@\/-ob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.]+'], '"b_ob_e"'], - // Tests @ character in the replace_pattern regex. - [['text' => 'Bob@e\0', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.@]+'], '"bob@e_0"'], - // Tests null byte in the replace_pattern regex. - [['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"bob"'], - [['text' => 'Bob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"fail()"'], - ]; - - $valid_data = array_map(function ($data) { - if (isset($data[0]['replace_pattern'])) { - $data[0]['replace_token'] = 'token-' . $data[0]['replace_pattern']; - } - return $data; - }, $valid_data); - - return $valid_data; - } - - /** - * Tests machine name controller's transliteration functionality. - * - * @param array $request_params - * An array of request parameters. - * @param $expected_content - * The expected content of the JSONresponse. - * - * @see \Drupal\system\MachineNameController::transliterate() - * - * @dataProvider providerTestMachineNameController - */ - public function testMachineNameController(array $request_params, $expected_content) { - $request = Request::create('', 'GET', $request_params); - $json = $this->machineNameController->transliterate($request); - $this->assertEquals($expected_content, $json->getContent()); - } - - /** - * Tests the pattern validation. - */ - public function testMachineNameControllerWithInvalidReplacePattern() { - $request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob', 'replace_token' => 'invalid']); - - $this->expectException(AccessDeniedHttpException::class); - $this->expectExceptionMessage("Invalid 'replace_token' query parameter."); - $this->machineNameController->transliterate($request); - } - - /** - * Tests the pattern validation with a missing token. - */ - public function testMachineNameControllerWithMissingToken() { - $request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob']); - - $this->expectException(AccessDeniedHttpException::class); - $this->expectExceptionMessage("Missing 'replace_token' query parameter."); - $this->machineNameController->transliterate($request); - } - - /** - * Tests deprecation of MachineNameController. - */ - public function testMachineNameControllerDeprecation(): void { - $request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en']); - $this->expectDeprecation('Drupal\system\MachineNameController::transliterate() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3367037'); - $json = $this->machineNameController->transliterate($request); - $this->assertEquals('"Bob"', $json->getContent()); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php index 3e1b4ab31e11..c796a6e94a1a 100644 --- a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php +++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php @@ -537,29 +537,4 @@ class ToolkitGdTest extends KernelTestBase { ], $this->imageFactory->get()->getToolkit()->getRequirements()); } - /** - * Tests deprecated setResource() and getResource(). - * - * @group legacy - */ - public function testResourceDeprecation() { - $toolkit = $this->imageFactory->get()->getToolkit(); - $image = imagecreate(10, 10); - $this->expectDeprecation('Drupal\system\Plugin\ImageToolkit\GDToolkit::setResource() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage() instead. See https://www.drupal.org/node/3265963'); - $toolkit->setResource($image); - $this->expectDeprecation('Checking the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963'); - $this->assertTrue(isset($toolkit->resource)); - $this->expectDeprecation('Drupal\system\Plugin\ImageToolkit\GDToolkit::getResource() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::getImage() instead. See https://www.drupal.org/node/3265963'); - $this->assertSame($image, $toolkit->getResource()); - $this->expectDeprecation('Accessing the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963'); - $this->assertSame($image, $toolkit->resource); - $this->expectDeprecation('Setting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963'); - $toolkit->resource = NULL; - $this->assertNull($toolkit->getImage()); - $this->expectDeprecation('Unsetting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963'); - $toolkit->setImage($image); - unset($toolkit->resource); - $this->assertNull($toolkit->getImage()); - } - } diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionOptimizerUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionOptimizerUnitTest.php deleted file mode 100644 index 195afc7daddd..000000000000 --- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionOptimizerUnitTest.php +++ /dev/null @@ -1,158 +0,0 @@ -createMock(AssetCollectionGrouperInterface::class); - $mock_grouper->method('group') - ->willReturnCallback(function ($assets) { - return [ - [ - 'items' => $assets, - 'type' => 'file', - 'preprocess' => TRUE, - ], - ]; - }); - $mock_optimizer = $this->createMock(AssetOptimizerInterface::class); - $mock_optimizer->method('optimize') - ->willReturn( - file_get_contents(__DIR__ . '/css_test_files/css_input_with_import.css.optimized.css'), - file_get_contents(__DIR__ . '/css_test_files/css_subfolder/css_input_with_import.css.optimized.css') - ); - $mock_dumper = $this->createMock(AssetDumperInterface::class); - $mock_dumper->method('dump') - ->willReturnCallback(function ($css) { - $this->dumperData = $css; - }); - $mock_state = $this->createMock(StateInterface::class); - $mock_file_system = $this->createMock(FileSystemInterface::class); - $this->optimizer = new CssCollectionOptimizer($mock_grouper, $mock_optimizer, $mock_dumper, $mock_state, $mock_file_system); - $gpl_license = [ - 'name' => 'GNU-GPL-2.0-or-later', - 'url' => 'https://www.drupal.org/licensing/faq', - 'gpl-compatible' => TRUE, - ]; - $this->optimizer->optimize([ - 'core/modules/system/tests/modules/common_test/common_test_css_import.css' => [ - 'type' => 'file', - 'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css', - 'preprocess' => TRUE, - 'license' => $gpl_license, - ], - 'core/modules/system/tests/modules/common_test/common_test_css_import_not_preprocessed.css' => [ - 'type' => 'file', - 'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css', - 'preprocess' => TRUE, - 'license' => $gpl_license, - ], - ], - []); - self::assertEquals(file_get_contents(__DIR__ . '/css_test_files/css_input_with_import.css.optimized.aggregated.css'), $this->dumperData); - } - - /** - * Tests that CSS imports with strange letters do not destroy the CSS output. - * - * Checks that license information is added only once when several files - * have the same license. Checks that multiple licenses are added properly. - * - * @group legacy - */ - public function testCssLicenseAggregation() { - $mock_grouper = $this->createMock(AssetCollectionGrouperInterface::class); - $mock_grouper->method('group') - ->willReturnCallback(function ($assets) { - return [ - [ - 'items' => $assets, - 'type' => 'file', - 'preprocess' => TRUE, - ], - ]; - }); - $mock_optimizer = $this->createMock(AssetOptimizerInterface::class); - $mock_optimizer->method('optimize') - ->willReturn( - file_get_contents(__DIR__ . '/css_test_files/css_input_with_import.css.optimized.css'), - file_get_contents(__DIR__ . '/css_test_files/css_subfolder/css_input_with_import.css.optimized.css'), - file_get_contents(__DIR__ . '/css_test_files/css_input_without_import.css.optimized.css') - ); - $mock_dumper = $this->createMock(AssetDumperInterface::class); - $mock_dumper->method('dump') - ->willReturnCallback(function ($css) { - $this->dumperData = $css; - }); - $mock_state = $this->createMock(StateInterface::class); - $mock_file_system = $this->createMock(FileSystemInterface::class); - $this->optimizer = new CssCollectionOptimizer($mock_grouper, $mock_optimizer, $mock_dumper, $mock_state, $mock_file_system); - $gpl_license = [ - 'name' => 'GNU-GPL-2.0-or-later', - 'url' => 'https://www.drupal.org/licensing/faq', - 'gpl-compatible' => TRUE, - ]; - $this->optimizer->optimize([ - 'core/modules/system/tests/modules/common_test/common_test_css_import.css' => [ - 'type' => 'file', - 'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css', - 'preprocess' => TRUE, - 'license' => $gpl_license, - ], - 'core/modules/system/tests/modules/common_test/common_test_css_import_not_preprocessed.css' => [ - 'type' => 'file', - 'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css', - 'preprocess' => TRUE, - 'license' => $gpl_license, - ], - 'core/modules/system/tests/modules/common_test/css_input_without_import.css' => [ - 'type' => 'file', - 'data' => 'core/modules/system/tests/modules/common_test/css_input_without_import.css', - 'preprocess' => TRUE, - 'license' => [ - 'name' => 'MIT', - 'url' => 'https://opensource.org/licenses/MIT', - 'gpl-compatible' => TRUE, - ], - ], - ], - []); - self::assertEquals(file_get_contents(__DIR__ . '/css_test_files/css_license.css.optimized.aggregated.css'), $this->dumperData); - } - -} diff --git a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php index 51131d7284b5..aaf6d9dc27c4 100644 --- a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php +++ b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php @@ -99,8 +99,8 @@ class StorageComparerTest extends UnitTestCase { ], ], // Simple config. - 'system.performance' => [ - 'stale_file_threshold' => 2592000, + 'system.logging' => [ + 'error_level' => 'hide', ], ];