diff options
Diffstat (limited to 'core/modules/system')
18 files changed, 155 insertions, 75 deletions
diff --git a/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php b/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php index c9250047f1fa..777efab6b0c5 100644 --- a/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php +++ b/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php @@ -23,7 +23,7 @@ class AccessRouteAlterSubscriber implements EventSubscriberInterface { } /** - * Adds _access_admin_menu_block_page requirement to routes pointing to SystemController::systemAdminMenuBlockPage. + * Adds requirements to some System Controller routes. * * @param \Drupal\Core\Routing\RouteBuildEvent $event * The event to process. diff --git a/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php b/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php index ee1550984f77..2fbfd980d344 100644 --- a/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php +++ b/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php @@ -16,7 +16,7 @@ class SystemUpdate7000 extends ProcessPluginBase { /** * {@inheritdoc} * - * Rename blog and forum permissions to be consistent with other content types. + * Makes blog and forum permissions to be consistent with other content types. */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $value = preg_replace('/(?<=^|,\ )create\ blog\ entries(?=,|$)/', 'create blog content', $value); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index c7ed1808206f..dbda1e1b6b4b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -223,7 +223,7 @@ function template_preprocess_entity_add_list(&$variables): void { * Optional string to use as the page title once redirected to authorize.php. */ function system_authorized_init($callback, $file, $arguments = [], $page_title = NULL): void { - @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); $session = \Drupal::request()->getSession(); // First, figure out what file transfer backends the site supports, and put @@ -255,7 +255,7 @@ function system_authorized_init($callback, $file, $arguments = [], $page_title = * @see system_authorized_init() */ function system_authorized_get_url(array $options = []) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); // core/authorize.php is an unrouted URL, so using the base: scheme is // the correct usage for this case. @@ -275,7 +275,7 @@ function system_authorized_get_url(array $options = []) { * The full URL for the authorize.php script with batch processing options. */ function system_authorized_batch_processing_url(array $options = []) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); $options['query'] = ['batch' => '1']; return system_authorized_get_url($options); @@ -287,7 +287,7 @@ function system_authorized_batch_processing_url(array $options = []) { * @see system_authorized_init() */ function system_authorized_run($callback, $file, $arguments = [], $page_title = NULL) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); system_authorized_init($callback, $file, $arguments, $page_title); return new RedirectResponse(system_authorized_get_url()->toString()); @@ -299,7 +299,7 @@ function system_authorized_run($callback, $file, $arguments = [], $page_title = * @see batch_process() */ function system_authorized_batch_process() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); $finish_url = system_authorized_get_url(); $process_url = system_authorized_batch_processing_url(); diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php index b1ed3dbe019f..ce110e2c2f36 100644 --- a/core/modules/system/system.post_update.php +++ b/core/modules/system/system.post_update.php @@ -108,7 +108,7 @@ function system_post_update_remove_path_key(): void { } /** - * Updates all entity_form_mode configuration entities to set description from empty string to null. + * Updates entity_form_mode descriptions from empty string to null. */ function system_post_update_convert_empty_description_entity_form_modes_to_null(array &$sandbox): void { \Drupal::classResolver(ConfigEntityUpdater::class) diff --git a/core/modules/system/templates/authorize-report.html.twig b/core/modules/system/templates/authorize-report.html.twig index 914458684775..f6f443c58075 100644 --- a/core/modules/system/templates/authorize-report.html.twig +++ b/core/modules/system/templates/authorize-report.html.twig @@ -12,6 +12,11 @@ * @see template_preprocess_authorize_report() * * @ingroup themeable + * + * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no + * replacement. Use composer to manage the code for your site. + * + * @see https://www.drupal.org/node/3522119 */ #} {% if messages %} diff --git a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php index 44308c3f6a9c..33dba9b0bf6f 100644 --- a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php +++ b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php @@ -7,13 +7,14 @@ namespace Drupal\element_info_test\Element; use Drupal\Core\Render\Attribute\FormElement; use Drupal\Core\Render\Element\FormElement as FormElementDeprecated; +// @phpcs:disable /** * Provides render element that extends deprecated FormElement for testing. - * - * @phpstan-ignore class.extendsDeprecatedClass */ #[FormElement('deprecated_extends_form')] +// @phpstan-ignore class.extendsDeprecatedClass class DeprecatedExtendsFormElement extends FormElementDeprecated { +// @phpcs:enable /** * {@inheritdoc} diff --git a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php index 514a3b01a4bc..72a608bfc5e1 100644 --- a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php +++ b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php @@ -7,13 +7,14 @@ namespace Drupal\element_info_test\Element; use Drupal\Core\Render\Attribute\RenderElement; use Drupal\Core\Render\Element\RenderElement as RenderElementDeprecated; +// @phpcs:disable /** * Provides render element that extends deprecated RenderElement for testing. - * - * @phpstan-ignore class.extendsDeprecatedClass */ #[RenderElement('deprecated_extends_render')] +// @phpstan-ignore class.extendsDeprecatedClass class DeprecatedExtendsRenderElement extends RenderElementDeprecated { +// @phpcs:enable /** * {@inheritdoc} diff --git a/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml b/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml index 39d5a0f81252..25c13b4cd4cd 100644 --- a/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml +++ b/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml @@ -77,6 +77,7 @@ display: type: table options: grouping: { } + class: '' row_class: '' default_row_class: true override: true diff --git a/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php b/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php index 1528a0839816..6877871e2d29 100644 --- a/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php +++ b/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php @@ -112,7 +112,9 @@ class RenderPlaceholderMessageTestController implements TrustedCallbackInterface $reordered = []; foreach ($placeholder_order as $placeholder) { - $reordered[$placeholder] = $build['#attached']['placeholders'][$placeholder]; + if (isset($build['#attached']['placeholders'][$placeholder])) { + $reordered[$placeholder] = $build['#attached']['placeholders'][$placeholder]; + } } $build['#attached']['placeholders'] = $reordered; diff --git a/core/modules/system/tests/modules/requirements1_test/requirements1_test.install b/core/modules/system/tests/modules/requirements1_test/requirements1_test.install index 70767c16544d..fb84be133cd7 100644 --- a/core/modules/system/tests/modules/requirements1_test/requirements1_test.install +++ b/core/modules/system/tests/modules/requirements1_test/requirements1_test.install @@ -9,6 +9,8 @@ declare(strict_types=1); /** * Implements hook_requirements(). + * + * This tests the procedural implementations for this hook. */ function requirements1_test_requirements($phase): array { $requirements = []; diff --git a/core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php b/core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php new file mode 100644 index 000000000000..5927e31e460b --- /dev/null +++ b/core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php @@ -0,0 +1,59 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\update_script_test\Hook; + +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Requirements for the Update Script Test module. + */ +class UpdateScriptTestRequirements { + + public function __construct( + protected readonly ConfigFactoryInterface $configFactory, + ) {} + + /** + * Implements hook_update_requirements(). + */ + #[Hook('update_requirements')] + public function update(): array { + $requirements = []; + // Set a requirements warning or error when the test requests it. + $requirement_type = $this->configFactory->get('update_script_test.settings')->get('requirement_type'); + switch ($requirement_type) { + case REQUIREMENT_WARNING: + $requirements['update_script_test'] = [ + 'title' => 'Update script test', + 'value' => 'Warning', + 'description' => 'This is a requirements warning provided by the update_script_test module.', + 'severity' => REQUIREMENT_WARNING, + ]; + break; + + case REQUIREMENT_ERROR: + $requirements['update_script_test'] = [ + 'title' => 'Update script test', + 'value' => 'Error', + 'description' => 'This is a (buggy description fixed in update_script_test_requirements_alter()) requirements error provided by the update_script_test module.', + 'severity' => REQUIREMENT_ERROR, + ]; + break; + } + return $requirements; + } + + /** + * Implements hook_update_requirements_alter(). + */ + #[Hook('update_requirements_alter')] + public function updateAlter(array &$requirements): void { + if (isset($requirements['update_script_test']) && $requirements['update_script_test']['severity'] === REQUIREMENT_ERROR) { + $requirements['update_script_test']['description'] = 'This is a requirements error provided by the update_script_test module.'; + } + } + +} diff --git a/core/modules/system/tests/modules/update_script_test/update_script_test.install b/core/modules/system/tests/modules/update_script_test/update_script_test.install index 5a641fd95644..c380aabd7ff7 100644 --- a/core/modules/system/tests/modules/update_script_test/update_script_test.install +++ b/core/modules/system/tests/modules/update_script_test/update_script_test.install @@ -8,48 +8,6 @@ declare(strict_types=1); /** - * Implements hook_requirements(). - */ -function update_script_test_requirements($phase): array { - $requirements = []; - - if ($phase == 'update') { - // Set a requirements warning or error when the test requests it. - $requirement_type = \Drupal::config('update_script_test.settings')->get('requirement_type'); - switch ($requirement_type) { - case REQUIREMENT_WARNING: - $requirements['update_script_test'] = [ - 'title' => 'Update script test', - 'value' => 'Warning', - 'description' => 'This is a requirements warning provided by the update_script_test module.', - 'severity' => REQUIREMENT_WARNING, - ]; - break; - - case REQUIREMENT_ERROR: - $requirements['update_script_test'] = [ - 'title' => 'Update script test', - 'value' => 'Error', - 'description' => 'This is a (buggy description fixed in update_script_test_requirements_alter()) requirements error provided by the update_script_test module.', - 'severity' => REQUIREMENT_ERROR, - ]; - break; - } - } - - return $requirements; -} - -/** - * Implements hook_requirements_alter(). - */ -function update_script_test_requirements_alter(array &$requirements): void { - if (isset($requirements['update_script_test']) && $requirements['update_script_test']['severity'] === REQUIREMENT_ERROR) { - $requirements['update_script_test']['description'] = 'This is a requirements error provided by the update_script_test module.'; - } -} - -/** * Implements hook_update_last_removed(). */ function update_script_test_update_last_removed(): int { diff --git a/core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php b/core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php new file mode 100644 index 000000000000..de96ce3e36a5 --- /dev/null +++ b/core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php @@ -0,0 +1,33 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\update_test_schema\Hook; + +use Drupal\Component\Render\FormattableMarkup; +use Drupal\Core\Hook\Attribute\Hook; +use Drupal\Core\Url; + +/** + * Requirements for the Update Test Schema module. + */ +class UpdateTestSchemaRequirements { + + /** + * Implements hook_runtime_requirements(). + */ + #[Hook('runtime_requirements')] + public function runtime(): array { + $requirements = []; + $requirements['path_alias_test'] = [ + 'title' => 'Path alias test', + 'value' => 'Check a path alias for the admin page', + 'severity' => REQUIREMENT_INFO, + 'description' => new FormattableMarkup('Visit <a href=":link">the structure page</a> to do many useful things.', [ + ':link' => Url::fromRoute('system.admin_structure')->toString(), + ]), + ]; + return $requirements; + } + +} diff --git a/core/modules/system/tests/modules/update_test_schema/update_test_schema.install b/core/modules/system/tests/modules/update_test_schema/update_test_schema.install index 305d2cc7913e..0ad88c618bd0 100644 --- a/core/modules/system/tests/modules/update_test_schema/update_test_schema.install +++ b/core/modules/system/tests/modules/update_test_schema/update_test_schema.install @@ -12,25 +12,6 @@ use Drupal\Core\Url; use Drupal\Component\Render\FormattableMarkup; /** - * Implements hook_requirements(). - */ -function update_test_schema_requirements($phase): array { - $requirements = []; - if ($phase === 'runtime') { - $requirements['path_alias_test'] = [ - 'title' => 'Path alias test', - 'value' => 'Check a path alias for the admin page', - 'severity' => REQUIREMENT_INFO, - 'description' => new FormattableMarkup('Visit <a href=":link">the structure page</a> to do many useful things.', [ - ':link' => Url::fromRoute('system.admin_structure')->toString(), - ]), - ]; - } - - return $requirements; -} - -/** * Implements hook_schema(). * * The schema defined here will vary on state to allow for update hook testing. diff --git a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php index 42605c114ffa..dcf46af35c9d 100644 --- a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php +++ b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php @@ -50,9 +50,11 @@ class TestFileTransfer extends FileTransfer { * Establishes a mock connection for file transfer. */ public function connect() { + // @phpstan-ignore property.deprecatedClass $this->connection = new MockTestConnection(); // Access the connection via the property. The property used to be set via a // magic method and this can cause problems if coded incorrectly. + // @phpstan-ignore property.deprecatedClass $this->connection->connectionString = 'test://' . urlencode($this->username) . ':' . urlencode($this->password) . "@$this->host:$this->port/"; } @@ -60,6 +62,7 @@ class TestFileTransfer extends FileTransfer { * Copies a file within the jailed environment. */ public function copyFileJailed($source, $destination) { + // @phpstan-ignore property.deprecatedClass $this->connection->run("copyFile $source $destination"); } @@ -67,6 +70,7 @@ class TestFileTransfer extends FileTransfer { * Removes a directory within the jailed environment. */ protected function removeDirectoryJailed($directory) { + // @phpstan-ignore property.deprecatedClass $this->connection->run("rmdir $directory"); } @@ -74,6 +78,7 @@ class TestFileTransfer extends FileTransfer { * Creates a directory within the jailed environment. */ public function createDirectoryJailed($directory) { + // @phpstan-ignore property.deprecatedClass $this->connection->run("mkdir $directory"); } @@ -81,6 +86,7 @@ class TestFileTransfer extends FileTransfer { * Removes a file within the jailed environment. */ public function removeFileJailed($destination) { + // @phpstan-ignore property.deprecatedClass $this->connection->run("rm $destination"); } diff --git a/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php b/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php index 4b2779ead48a..63e325c51111 100644 --- a/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php +++ b/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php @@ -17,7 +17,10 @@ class PlaceholderMessageTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected static $modules = ['render_placeholder_message_test']; + protected static $modules = [ + 'render_placeholder_message_test', + 'big_pipe_messages_test', + ]; /** * {@inheritdoc} diff --git a/core/modules/system/tests/src/Kernel/Block/StubPathMatcher.php b/core/modules/system/tests/src/Kernel/Block/StubPathMatcher.php new file mode 100644 index 000000000000..c2bd82782b05 --- /dev/null +++ b/core/modules/system/tests/src/Kernel/Block/StubPathMatcher.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\system\Kernel\Block; + +use Drupal\Core\Path\PathMatcher; + +/** + * A class extending PatchMatcher for testing purposes. + */ +class StubPathMatcher extends PathMatcher { + + /** + * {@inheritdoc} + */ + public function isFrontPage(): bool { + return FALSE; + } + +} diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php index e2ceead3475d..6d4ff90d5f46 100644 --- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php +++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php @@ -341,6 +341,13 @@ class SystemMenuBlockTest extends KernelTestBase { * @dataProvider configExpandedTestCases */ public function testConfigExpanded($active_route, $menu_block_level, $expected_items): void { + // Replace the path.matcher service so it always returns FALSE when + // checking whether a route is the front page. Otherwise, the default + // service throws an exception when checking routes because all of these + // are mocked. + $service_definition = $this->container->getDefinition('path.matcher'); + $service_definition->setClass(StubPathMatcher::class); + $block = $this->blockManager->createInstance('system_menu_block:' . $this->menu->id(), [ 'region' => 'footer', 'id' => 'machine_name', |