summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/system
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/system')
-rw-r--r--core/modules/system/css/components/position-container.module.css8
-rw-r--r--core/modules/system/src/Controller/DbUpdateController.php7
-rw-r--r--core/modules/system/src/Element/StatusReportPage.php23
-rw-r--r--core/modules/system/src/Hook/SystemHooks.php6
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php19
-rw-r--r--core/modules/system/src/SystemManager.php37
-rw-r--r--core/modules/system/system.install133
-rw-r--r--core/modules/system/system.libraries.yml1
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gzbin162581 -> 162168 bytes
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gzbin596855 -> 596593 bytes
-rw-r--r--core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install4
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php38
-rw-r--r--core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php6
-rw-r--r--core/modules/system/tests/modules/module_install_unmet_requirements/src/Install/Requirements/ModuleInstallUnmetRequirementsRequirements.php3
-rw-r--r--core/modules/system/tests/modules/module_runtime_requirements/src/Hook/ModuleRuntimeRequirementsHooks.php7
-rw-r--r--core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php6
-rw-r--r--core/modules/system/tests/modules/module_update_requirements/src/Hook/ModuleUpdateRequirementsHooks.php7
-rw-r--r--core/modules/system/tests/modules/requirements1_test/requirements1_test.install8
-rw-r--r--core/modules/system/tests/modules/requirements1_test/src/Hook/Requirements1TestHooks.php3
-rw-r--r--core/modules/system/tests/modules/session_test/session_test.routing.yml22
-rw-r--r--core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php35
-rw-r--r--core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php127
-rw-r--r--core/modules/system/tests/modules/test_htmx/css/style.css3
-rw-r--r--core/modules/system/tests/modules/test_htmx/js/behavior.js14
-rw-r--r--core/modules/system/tests/modules/test_htmx/src/Controller/HtmxTestAttachmentsController.php83
-rw-r--r--core/modules/system/tests/modules/test_htmx/src/Form/HtmxTestAjaxForm.php51
-rw-r--r--core/modules/system/tests/modules/test_htmx/test_htmx.info.yml4
-rw-r--r--core/modules/system/tests/modules/test_htmx/test_htmx.libraries.yml10
-rw-r--r--core/modules/system/tests/modules/test_htmx/test_htmx.routing.yml23
-rw-r--r--core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php4
-rw-r--r--core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php2
-rw-r--r--core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php11
-rw-r--r--core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php3
-rw-r--r--core/modules/system/tests/src/Functional/Form/FormTest.php32
-rw-r--r--core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php35
-rw-r--r--core/modules/system/tests/src/Functional/Session/LegacySessionTest.php44
-rw-r--r--core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php3
-rw-r--r--core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php7
-rw-r--r--core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php11
-rw-r--r--core/modules/system/tests/src/Kernel/Element/StatusReportPageTest.php58
-rw-r--r--core/modules/system/tests/src/Kernel/Module/RequirementsTest.php3
-rw-r--r--core/modules/system/tests/src/Kernel/System/RunTimeRequirementsTest.php5
42 files changed, 622 insertions, 284 deletions
diff --git a/core/modules/system/css/components/position-container.module.css b/core/modules/system/css/components/position-container.module.css
deleted file mode 100644
index ae209f3aa61..00000000000
--- a/core/modules/system/css/components/position-container.module.css
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * @file
- * Contain positioned elements.
- */
-
-.position-container {
- position: relative;
-}
diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php
index 131b6a075d5..2f5ae051204 100644
--- a/core/modules/system/src/Controller/DbUpdateController.php
+++ b/core/modules/system/src/Controller/DbUpdateController.php
@@ -7,6 +7,7 @@ use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface;
use Drupal\Core\Render\BareHtmlPageRendererInterface;
use Drupal\Core\Session\AccountInterface;
@@ -166,8 +167,8 @@ class DbUpdateController extends ControllerBase {
$regions = [];
$requirements = update_check_requirements();
- $severity = drupal_requirements_severity($requirements);
- if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && !$request->getSession()->has('update_ignore_warnings'))) {
+ $severity = RequirementSeverity::maxSeverityFromRequirements($requirements);
+ if ($severity === RequirementSeverity::Error || ($severity === RequirementSeverity::Warning && !$request->getSession()->has('update_ignore_warnings'))) {
$regions['sidebar_first'] = $this->updateTasksList('requirements');
$output = $this->requirements($severity, $requirements, $request);
}
@@ -543,7 +544,7 @@ class DbUpdateController extends ControllerBase {
* A render array.
*/
public function requirements($severity, array $requirements, Request $request) {
- $options = $severity == REQUIREMENT_WARNING ? ['continue' => 1] : [];
+ $options = $severity === RequirementSeverity::Warning ? ['continue' => 1] : [];
// @todo Revisit once https://www.drupal.org/node/2548095 is in. Something
// like Url::fromRoute('system.db_update')->setOptions() should then be
// possible.
diff --git a/core/modules/system/src/Element/StatusReportPage.php b/core/modules/system/src/Element/StatusReportPage.php
index 90a878831ea..2d6494f2fe3 100644
--- a/core/modules/system/src/Element/StatusReportPage.php
+++ b/core/modules/system/src/Element/StatusReportPage.php
@@ -2,9 +2,9 @@
namespace Drupal\system\Element;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Render\Attribute\RenderElement;
use Drupal\Core\Render\Element\RenderElementBase;
-use Drupal\Core\Render\Element\StatusReport;
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
/**
@@ -37,6 +37,7 @@ class StatusReportPage extends RenderElementBase {
'#theme' => 'status_report_general_info',
];
// Loop through requirements and pull out items.
+ RequirementSeverity::convertLegacyIntSeveritiesToEnums($element['#requirements'], __METHOD__);
foreach ($element['#requirements'] as $key => $requirement) {
switch ($key) {
case 'cron':
@@ -59,10 +60,10 @@ class StatusReportPage extends RenderElementBase {
case 'php':
case 'php_memory_limit':
$element['#general_info']['#' . $key] = $requirement;
- if (isset($requirement['severity']) && $requirement['severity'] < REQUIREMENT_WARNING) {
- if (empty($requirement['severity']) || $requirement['severity'] == REQUIREMENT_OK) {
- unset($element['#requirements'][$key]);
- }
+ if (isset($requirement['severity']) &&
+ in_array($requirement['severity'], [RequirementSeverity::Info, RequirementSeverity::OK], TRUE)
+ ) {
+ unset($element['#requirements'][$key]);
}
break;
}
@@ -94,18 +95,18 @@ class StatusReportPage extends RenderElementBase {
],
];
- $severities = StatusReport::getSeverities();
+ RequirementSeverity::convertLegacyIntSeveritiesToEnums($element['#requirements'], __METHOD__);
foreach ($element['#requirements'] as $key => &$requirement) {
- $severity = $severities[REQUIREMENT_INFO];
+ $severity = RequirementSeverity::Info;
if (isset($requirement['severity'])) {
- $severity = $severities[(int) $requirement['severity']];
+ $severity = $requirement['severity'];
}
elseif (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') {
- $severity = $severities[REQUIREMENT_OK];
+ $severity = RequirementSeverity::OK;
}
- if (isset($counters[$severity['status']])) {
- $counters[$severity['status']]['amount']++;
+ if (isset($counters[$severity->status()])) {
+ $counters[$severity->status()]['amount']++;
}
}
diff --git a/core/modules/system/src/Hook/SystemHooks.php b/core/modules/system/src/Hook/SystemHooks.php
index ae3e8d71074..86d18164623 100644
--- a/core/modules/system/src/Hook/SystemHooks.php
+++ b/core/modules/system/src/Hook/SystemHooks.php
@@ -276,7 +276,11 @@ class SystemHooks {
// before doing so. Also add the loaded libraries to ajaxPageState.
/** @var \Drupal\Core\Asset\LibraryDependencyResolver $library_dependency_resolver */
$library_dependency_resolver = \Drupal::service('library.dependency_resolver');
- if (isset($settings['ajaxPageState']) || in_array('core/drupal.ajax', $library_dependency_resolver->getLibrariesWithDependencies($assets->getAlreadyLoadedLibraries()))) {
+ $loaded_libraries = [];
+ if (!isset($settings['ajaxPageState'])) {
+ $loaded_libraries = $library_dependency_resolver->getLibrariesWithDependencies($assets->getAlreadyLoadedLibraries());
+ }
+ if (isset($settings['ajaxPageState']) || in_array('core/drupal.ajax', $loaded_libraries) || in_array('core/drupal.htmx', $loaded_libraries)) {
if (!defined('MAINTENANCE_MODE')) {
// The theme token is only validated when the theme requested is not the
// default, so don't generate it unless necessary.
diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
index 670fbc06cf7..2ce434e0fd3 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
@@ -4,6 +4,7 @@ namespace Drupal\system\Plugin\ImageToolkit;
use Drupal\Component\Utility\Color;
use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileExists;
use Drupal\Core\File\FileSystemInterface;
@@ -439,9 +440,6 @@ class GDToolkit extends ImageToolkitBase {
IMG_AVIF => 'AVIF',
];
$supported_formats = array_filter($check_formats, fn($type) => imagetypes() & $type, ARRAY_FILTER_USE_KEY);
- if (isset($supported_formats[IMG_AVIF]) && !$this->checkAvifSupport()) {
- unset($supported_formats[IMG_AVIF]);
- }
$unsupported_formats = array_diff_key($check_formats, $supported_formats);
$descriptions = [];
@@ -454,7 +452,7 @@ class GDToolkit extends ImageToolkitBase {
);
}
if ($unsupported_formats) {
- $requirements['version']['severity'] = REQUIREMENT_WARNING;
+ $requirements['version']['severity'] = RequirementSeverity::Warning;
$unsupported = $this->formatPlural(
count($unsupported_formats),
'Unsupported image file format: %formats.',
@@ -475,7 +473,7 @@ class GDToolkit extends ImageToolkitBase {
// Check for filter and rotate support.
if (!function_exists('imagefilter') || !function_exists('imagerotate')) {
- $requirements['version']['severity'] = REQUIREMENT_WARNING;
+ $requirements['version']['severity'] = RequirementSeverity::Warning;
$descriptions[] = $this->t('The GD Library for PHP is enabled, but was compiled without support for functions used by the rotate and desaturate effects. It was probably compiled using the official GD libraries from the <a href="https://libgd.github.io/">gdLibrary site</a> instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="https://www.php.net/manual/book.image.php">the PHP manual</a>.');
}
@@ -556,7 +554,7 @@ class GDToolkit extends ImageToolkitBase {
* @return bool
* TRUE if AVIF is fully supported, FALSE otherwise.
*/
- protected function checkAvifSupport(): bool {
+ protected static function checkAvifSupport(): bool {
static $supported = NULL;
if ($supported !== NULL) {
@@ -564,7 +562,7 @@ class GDToolkit extends ImageToolkitBase {
}
$tempFile = fopen('php://memory', 'r+');
- $supported = imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0;
+ $supported = function_exists('imageavif') && imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0;
fclose($tempFile);
return $supported;
@@ -578,13 +576,16 @@ class GDToolkit extends ImageToolkitBase {
* IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
*/
protected static function supportedTypes() {
- return [
+ $types = [
IMAGETYPE_PNG,
IMAGETYPE_JPEG,
IMAGETYPE_GIF,
IMAGETYPE_WEBP,
- IMAGETYPE_AVIF,
];
+ if (static::checkAvifSupport()) {
+ $types[] = IMAGETYPE_AVIF;
+ }
+ return $types;
}
}
diff --git a/core/modules/system/src/SystemManager.php b/core/modules/system/src/SystemManager.php
index 5534e70147b..43a53fe0542 100644
--- a/core/modules/system/src/SystemManager.php
+++ b/core/modules/system/src/SystemManager.php
@@ -2,11 +2,12 @@
namespace Drupal\system;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Menu\MenuActiveTrailInterface;
-use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuLinkInterface;
+use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuTreeParameters;
-use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -54,16 +55,31 @@ class SystemManager {
/**
* Requirement severity -- Requirement successfully met.
+ *
+ * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use
+ * \Drupal\Core\Extension\Requirement\RequirementSeverity::OK instead.
+ *
+ * @see https://www.drupal.org/node/3410939
*/
const REQUIREMENT_OK = 0;
/**
* Requirement severity -- Warning condition; proceed but flag warning.
+ *
+ * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use
+ * \Drupal\Core\Extension\Requirement\RequirementSeverity::Warning instead.
+ *
+ * @see https://www.drupal.org/node/3410939
*/
const REQUIREMENT_WARNING = 1;
/**
* Requirement severity -- Error condition; abort installation.
+ *
+ * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use
+ * \Drupal\Core\Extension\Requirement\RequirementSeverity::Error instead.
+ *
+ * @see https://www.drupal.org/node/3410939
*/
const REQUIREMENT_ERROR = 2;
@@ -94,7 +110,7 @@ class SystemManager {
*/
public function checkRequirements() {
$requirements = $this->listRequirements();
- return $this->getMaxSeverity($requirements) == static::REQUIREMENT_ERROR;
+ return RequirementSeverity::maxSeverityFromRequirements($requirements) === RequirementSeverity::Error;
}
/**
@@ -136,15 +152,16 @@ class SystemManager {
*
* @return int
* The highest severity in the array.
+ *
+ * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use
+ * \Drupal\Core\Extension\Requirement\RequirementSeverity::getMaxSeverity()
+ * instead.
+ *
+ * @see https://www.drupal.org/node/3410939
*/
public function getMaxSeverity(&$requirements) {
- $severity = static::REQUIREMENT_OK;
- foreach ($requirements as $requirement) {
- if (isset($requirement['severity'])) {
- $severity = max($severity, $requirement['severity']);
- }
- }
- return $severity;
+ @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use ' . RequirementSeverity::class . '::maxSeverityFromRequirements() instead. See https://www.drupal.org/node/3410939', \E_USER_DEPRECATED);
+ return RequirementSeverity::maxSeverityFromRequirements($requirements)->value;
}
/**
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 9b8c25c157e..431651d08e2 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -14,9 +14,9 @@ use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Extension\ExtensionLifecycle;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link;
-use Drupal\Core\Utility\PhpRequirements;
use Drupal\Core\Render\Markup;
use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\PrivateStream;
@@ -27,6 +27,7 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Update\EquivalentUpdate;
use Drupal\Core\Url;
use Drupal\Core\Utility\Error;
+use Drupal\Core\Utility\PhpRequirements;
use Psr\Http\Client\ClientExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -83,7 +84,7 @@ function system_requirements($phase): array {
$requirements['drupal'] = [
'title' => t('Drupal'),
'value' => \Drupal::VERSION,
- 'severity' => REQUIREMENT_INFO,
+ 'severity' => RequirementSeverity::Info,
'weight' => -10,
];
@@ -99,7 +100,7 @@ function system_requirements($phase): array {
'%profile' => $profile,
'%version' => !empty($info['version']) ? '-' . $info['version'] : '',
]),
- 'severity' => REQUIREMENT_INFO,
+ 'severity' => RequirementSeverity::Info,
'weight' => -9,
];
}
@@ -129,7 +130,7 @@ function system_requirements($phase): array {
$requirements['experimental_modules'] = [
'title' => t('Experimental modules installed'),
'value' => t('Experimental modules found: %module_list. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', ['%module_list' => implode(', ', $experimental_modules), ':url' => 'https://www.drupal.org/core/experimental']),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
// Warn if any deprecated modules are installed.
@@ -142,7 +143,7 @@ function system_requirements($phase): array {
'value' => t('Deprecated modules found: %module_list.', [
'%module_list' => Markup::create(implode(', ', $deprecated_modules_link_list)),
]),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
@@ -170,7 +171,7 @@ function system_requirements($phase): array {
$requirements['experimental_themes'] = [
'title' => t('Experimental themes installed'),
'value' => t('Experimental themes found: %theme_list. Experimental themes are provided for testing purposes only. Use at your own risk.', ['%theme_list' => implode(', ', $experimental_themes)]),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
@@ -185,7 +186,7 @@ function system_requirements($phase): array {
'value' => t('Deprecated themes found: %theme_list.', [
'%theme_list' => Markup::create(implode(', ', $deprecated_themes_link_list)),
]),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
@@ -200,7 +201,7 @@ function system_requirements($phase): array {
'%extensions' => Markup::create(implode(', ', $obsolete_extensions_link_list)),
':uninstall_url' => Url::fromRoute('system.modules_uninstall')->toString(),
]),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
_system_advisories_requirements($requirements);
@@ -264,7 +265,7 @@ function system_requirements($phase): array {
$requirements['apache_version'] = [
'title' => t('Apache version'),
'value' => $apache_version_string,
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
'description' => t('Due to the settings for ServerTokens in httpd.conf, it is impossible to accurately determine the version of Apache running on this server. The reported value is @reported, to run Drupal without mod_rewrite, a minimum version of 2.2.16 is needed.', ['@reported' => $apache_version_string]),
];
}
@@ -273,7 +274,7 @@ function system_requirements($phase): array {
$requirements['Apache version'] = [
'title' => t('Apache version'),
'value' => $apache_version_string,
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('The minimum version of Apache needed to run Drupal without mod_rewrite enabled is 2.2.16. See the <a href=":link">enabling clean URLs</a> page for more information on mod_rewrite.', [':link' => 'https://www.drupal.org/docs/8/clean-urls-in-drupal-8']),
];
}
@@ -282,7 +283,7 @@ function system_requirements($phase): array {
$requirements['rewrite_module'] = [
'title' => t('Clean URLs'),
'value' => t('Disabled'),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
'description' => t('Your server is capable of using clean URLs, but it is not enabled. Using clean URLs gives an improved user experience and is recommended. <a href=":link">Enable clean URLs</a>', [':link' => 'https://www.drupal.org/docs/8/clean-urls-in-drupal-8']),
];
}
@@ -319,19 +320,19 @@ function system_requirements($phase): array {
// safe to continue with the requirements check, and should always be an
// error.
if (version_compare($phpversion, \Drupal::MINIMUM_PHP) < 0) {
- $requirements['php']['severity'] = REQUIREMENT_ERROR;
+ $requirements['php']['severity'] = RequirementSeverity::Error;
return $requirements;
}
// Otherwise, the message should be an error at runtime, and a warning
// during installation or update.
- $requirements['php']['severity'] = ($phase === 'runtime') ? REQUIREMENT_ERROR : REQUIREMENT_WARNING;
+ $requirements['php']['severity'] = ($phase === 'runtime') ? RequirementSeverity::Error : RequirementSeverity::Warning;
}
// For PHP versions that are still supported but no longer recommended,
// inform users of what's recommended, allowing them to take action before it
// becomes urgent.
elseif ($phase === 'runtime' && version_compare($phpversion, \Drupal::RECOMMENDED_PHP) < 0) {
$requirements['php']['description'] = t('It is recommended to upgrade to PHP version %recommended or higher for the best ongoing support. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal PHP requirements</a> page for more information.', ['%recommended' => \Drupal::RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/system-requirements/php-requirements']);
- $requirements['php']['severity'] = REQUIREMENT_INFO;
+ $requirements['php']['severity'] = RequirementSeverity::Info;
}
// Test for PHP extensions.
@@ -381,7 +382,7 @@ function system_requirements($phase): array {
];
$requirements['php_extensions']['value'] = t('Disabled');
- $requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
+ $requirements['php_extensions']['severity'] = RequirementSeverity::Error;
$requirements['php_extensions']['description'] = $description;
}
else {
@@ -393,7 +394,7 @@ function system_requirements($phase): array {
if (!OpCodeCache::isEnabled()) {
$requirements['php_opcache'] = [
'value' => t('Not enabled'),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
'description' => t('PHP OPcode caching can improve your site\'s performance considerably. It is <strong>highly recommended</strong> to have <a href="http://php.net/manual/opcache.installation.php" target="_blank">OPcache</a> installed on your server.'),
];
}
@@ -413,7 +414,7 @@ function system_requirements($phase): array {
$apcu_recommended_size = '32 MB';
$requirements['php_apcu_enabled']['value'] = t('Enabled (@size)', ['@size' => $apcu_actual_size]);
if (Bytes::toNumber(ini_get('apc.shm_size')) * ini_get('apc.shm_segments') < Bytes::toNumber($apcu_recommended_size)) {
- $requirements['php_apcu_enabled']['severity'] = REQUIREMENT_WARNING;
+ $requirements['php_apcu_enabled']['severity'] = RequirementSeverity::Warning;
$requirements['php_apcu_enabled']['description'] = t('Depending on your configuration, Drupal can run with a @apcu_size APCu limit. However, a @apcu_default_size APCu limit (the default) or above is recommended, especially if your site uses additional custom or contributed modules.', [
'@apcu_size' => $apcu_actual_size,
'@apcu_default_size' => $apcu_recommended_size,
@@ -422,19 +423,19 @@ function system_requirements($phase): array {
else {
$memory_available = $memory_info['avail_mem'] / ($memory_info['seg_size'] * $memory_info['num_seg']);
if ($memory_available < 0.1) {
- $requirements['php_apcu_available']['severity'] = REQUIREMENT_ERROR;
+ $requirements['php_apcu_available']['severity'] = RequirementSeverity::Error;
$requirements['php_apcu_available']['description'] = t('APCu is using over 90% of its allotted memory (@apcu_actual_size). To improve APCu performance, consider increasing this limit.', [
'@apcu_actual_size' => $apcu_actual_size,
]);
}
elseif ($memory_available < 0.25) {
- $requirements['php_apcu_available']['severity'] = REQUIREMENT_WARNING;
+ $requirements['php_apcu_available']['severity'] = RequirementSeverity::Warning;
$requirements['php_apcu_available']['description'] = t('APCu is using over 75% of its allotted memory (@apcu_actual_size). To improve APCu performance, consider increasing this limit.', [
'@apcu_actual_size' => $apcu_actual_size,
]);
}
else {
- $requirements['php_apcu_available']['severity'] = REQUIREMENT_OK;
+ $requirements['php_apcu_available']['severity'] = RequirementSeverity::OK;
}
$requirements['php_apcu_available']['value'] = t('Memory available: @available.', [
'@available' => ByteSizeMarkup::create($memory_info['avail_mem']),
@@ -444,7 +445,7 @@ function system_requirements($phase): array {
else {
$requirements['php_apcu_enabled'] += [
'value' => t('Not enabled'),
- 'severity' => REQUIREMENT_INFO,
+ 'severity' => RequirementSeverity::Info,
'description' => t('PHP APCu caching can improve your site\'s performance considerably. It is <strong>highly recommended</strong> to have <a href="https://www.php.net/manual/apcu.installation.php" target="_blank">APCu</a> installed on your server.'),
];
}
@@ -484,7 +485,7 @@ function system_requirements($phase): array {
$requirements['php_random_bytes']['description'] = t('Drupal is unable to generate highly randomized numbers, which means certain security features like password reset URLs are not as secure as they should be. Instead, only a slow, less-secure fallback generator is available. See the <a href=":drupal-php">system requirements</a> page for more information. %exception_message', $args);
}
$requirements['php_random_bytes']['value'] = t('Less secure');
- $requirements['php_random_bytes']['severity'] = REQUIREMENT_ERROR;
+ $requirements['php_random_bytes']['severity'] = RequirementSeverity::Error;
}
}
@@ -493,7 +494,7 @@ function system_requirements($phase): array {
$requirements['output_buffering'] = [
'title' => t('Output Buffering'),
'error_value' => t('Not enabled'),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
'description' => t('<a href="https://www.php.net/manual/en/function.ob-start.php">Output buffering</a> is not enabled. This may degrade Drupal\'s performance. You can enable output buffering by default <a href="https://www.php.net/manual/en/outcontrol.configuration.php#ini.output-buffering">in your PHP settings</a>.'),
];
}
@@ -532,7 +533,7 @@ function system_requirements($phase): array {
if (!$database_ok) {
$requirements['database_extensions']['value'] = t('Disabled');
- $requirements['database_extensions']['severity'] = REQUIREMENT_ERROR;
+ $requirements['database_extensions']['severity'] = RequirementSeverity::Error;
$requirements['database_extensions']['description'] = $pdo_message;
}
else {
@@ -563,7 +564,7 @@ function system_requirements($phase): array {
// Use the comma-list style to display a single error without bullets.
'#context' => ['list_style' => $error_count === 1 ? 'comma-list' : ''],
];
- $requirements['database_system_version']['severity'] = REQUIREMENT_ERROR;
+ $requirements['database_system_version']['severity'] = RequirementSeverity::Error;
$requirements['database_system_version']['description'] = $error_message;
}
}
@@ -572,14 +573,14 @@ function system_requirements($phase): array {
// Test database JSON support.
$requirements['database_support_json'] = [
'title' => t('Database support for JSON'),
- 'severity' => REQUIREMENT_OK,
+ 'severity' => RequirementSeverity::OK,
'value' => t('Available'),
'description' => t('Drupal requires databases that support JSON storage.'),
];
if (!Database::getConnection()->hasJson()) {
$requirements['database_support_json']['value'] = t('Not available');
- $requirements['database_support_json']['severity'] = REQUIREMENT_ERROR;
+ $requirements['database_support_json']['severity'] = RequirementSeverity::Error;
}
}
@@ -623,7 +624,7 @@ function system_requirements($phase): array {
];
$requirements['php_memory_limit']['description'] = $description;
- $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
+ $requirements['php_memory_limit']['severity'] = RequirementSeverity::Warning;
}
}
@@ -645,12 +646,12 @@ function system_requirements($phase): array {
$error_value = t('Protection disabled');
// If permissions hardening is disabled, then only show a warning for a
// writable file, as a reminder, rather than an error.
- $file_protection_severity = REQUIREMENT_WARNING;
+ $file_protection_severity = RequirementSeverity::Warning;
}
else {
$error_value = t('Not protected');
// In normal operation, writable files or directories are an error.
- $file_protection_severity = REQUIREMENT_ERROR;
+ $file_protection_severity = RequirementSeverity::Error;
if (!drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')) {
$conf_errors[] = t("The directory %file is not protected from modifications and poses a security risk. You must change the directory's permissions to be non-writable.", ['%file' => $site_path]);
}
@@ -709,7 +710,7 @@ function system_requirements($phase): array {
// phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
'title' => new TranslatableMarkup($protected_dir->getTitle()),
'value' => t('Not fully protected'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('See <a href=":url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', [':url' => $url, '@url' => $url, '%directory' => $protected_dir->getPath()]),
];
}
@@ -731,13 +732,13 @@ function system_requirements($phase): array {
}
// Determine severity based on time since cron last ran.
- $severity = REQUIREMENT_INFO;
+ $severity = RequirementSeverity::Info;
$request_time = \Drupal::time()->getRequestTime();
if ($request_time - $cron_last > $threshold_error) {
- $severity = REQUIREMENT_ERROR;
+ $severity = RequirementSeverity::Error;
}
elseif ($request_time - $cron_last > $threshold_warning) {
- $severity = REQUIREMENT_WARNING;
+ $severity = RequirementSeverity::Warning;
}
// Set summary and description based on values determined above.
@@ -748,7 +749,7 @@ function system_requirements($phase): array {
'severity' => $severity,
'value' => $summary,
];
- if ($severity != REQUIREMENT_INFO) {
+ if ($severity != RequirementSeverity::Info) {
$requirements['cron']['description'][] = [
[
'#markup' => t('Cron has not run recently.'),
@@ -833,7 +834,7 @@ function system_requirements($phase): array {
$requirements['config sync directory'] = [
'title' => t('Configuration sync directory'),
'description' => $description,
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
}
@@ -842,7 +843,7 @@ function system_requirements($phase): array {
'title' => t('Configuration sync directory'),
'value' => t('Not present'),
'description' => t("Your %file file must define the %setting setting as a string containing the directory in which configuration files can be found.", ['%file' => $site_path . '/settings.php', '%setting' => "\$settings['config_sync_directory']"]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
@@ -891,7 +892,7 @@ function system_requirements($phase): array {
],
];
$requirements['file system']['description'] = $description;
- $requirements['file system']['severity'] = REQUIREMENT_ERROR;
+ $requirements['file system']['severity'] = RequirementSeverity::Error;
}
}
else {
@@ -937,7 +938,7 @@ function system_requirements($phase): array {
}
if ($has_pending_updates) {
- $requirements['update']['severity'] = REQUIREMENT_ERROR;
+ $requirements['update']['severity'] = RequirementSeverity::Error;
$requirements['update']['value'] = t('Out of date');
$requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [':update' => Url::fromRoute('system.db_update')->toString()]);
}
@@ -959,7 +960,7 @@ function system_requirements($phase): array {
}
$entity_update_issues = \Drupal::service('renderer')->renderInIsolation($build);
- $requirements['entity_update']['severity'] = REQUIREMENT_ERROR;
+ $requirements['entity_update']['severity'] = RequirementSeverity::Error;
$requirements['entity_update']['value'] = t('Mismatched entity and/or field definitions');
$requirements['entity_update']['description'] = t('The following changes were detected in the entity type and field definitions. @updates', ['@updates' => $entity_update_issues]);
}
@@ -971,7 +972,7 @@ function system_requirements($phase): array {
$requirements['deployment identifier'] = [
'title' => t('Deployment identifier'),
'value' => $deployment_identifier,
- 'severity' => REQUIREMENT_INFO,
+ 'severity' => RequirementSeverity::Info,
];
}
}
@@ -981,7 +982,7 @@ function system_requirements($phase): array {
if (Settings::get('update_free_access')) {
$requirements['update access'] = [
'value' => t('Not protected'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the @settings_name value in your settings.php back to FALSE.', ['@settings_name' => '$settings[\'update_free_access\']']),
];
}
@@ -1023,7 +1024,7 @@ function system_requirements($phase): array {
'#markup' => $message,
],
],
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
};
$profile = \Drupal::installProfile();
@@ -1058,7 +1059,7 @@ function system_requirements($phase): array {
'title' => t('Unresolved dependency'),
'description' => t('@name requires this module.', ['@name' => $name]),
'value' => t('@required_name (Missing)', ['@required_name' => $required_module]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
continue;
}
@@ -1072,7 +1073,7 @@ function system_requirements($phase): array {
'title' => t('Unresolved dependency'),
'description' => t('@name requires this module and version. Currently using @required_name version @version', ['@name' => $name, '@required_name' => $required_name, '@version' => $version]),
'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $requirement->getConstraintString()]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
continue;
}
@@ -1272,9 +1273,9 @@ function system_requirements($phase): array {
Unicode::STATUS_ERROR => t('Error'),
];
$severities = [
- Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING,
+ Unicode::STATUS_SINGLEBYTE => RequirementSeverity::Warning,
Unicode::STATUS_MULTIBYTE => NULL,
- Unicode::STATUS_ERROR => REQUIREMENT_ERROR,
+ Unicode::STATUS_ERROR => RequirementSeverity::Error,
];
$failed_check = Unicode::check();
$library = Unicode::getStatus();
@@ -1299,7 +1300,7 @@ function system_requirements($phase): array {
if (!\Drupal::moduleHandler()->moduleExists('update')) {
$requirements['update status'] = [
'value' => t('Not enabled'),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
'description' => t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you install the Update Status module from the <a href=":module">module administration page</a> in order to stay up-to-date on new releases. For more information, <a href=":update">Update status handbook page</a>.', [
':update' => 'https://www.drupal.org/documentation/modules/update',
':module' => Url::fromRoute('system.modules_list')->toString(),
@@ -1317,7 +1318,7 @@ function system_requirements($phase): array {
$requirements['rebuild access'] = [
'title' => t('Rebuild access'),
'value' => t('Enabled'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('The rebuild_access setting is enabled in settings.php. It is recommended to have this setting disabled unless you are performing a rebuild.'),
];
}
@@ -1338,7 +1339,7 @@ function system_requirements($phase): array {
$requirements['php_session_samesite'] = [
'title' => t('SameSite cookie attribute'),
'value' => $samesite,
- 'severity' => $valid ? REQUIREMENT_OK : REQUIREMENT_WARNING,
+ 'severity' => $valid ? RequirementSeverity::OK : RequirementSeverity::Warning,
'description' => t('This attribute should be explicitly set to Lax, Strict or None. If set to None then the request must be made via HTTPS. See <a href=":url" target="_blank">PHP documentation</a>', [
':url' => 'https://www.php.net/manual/en/session.configuration.php#ini.session.cookie-samesite',
]),
@@ -1354,7 +1355,7 @@ function system_requirements($phase): array {
'title' => t('Trusted Host Settings'),
'value' => t('Not enabled'),
'description' => t('The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is <strong>highly recommended</strong> that you configure this. See <a href=":url">Protecting against HTTP HOST Header attacks</a> for more information.', [':url' => 'https://www.drupal.org/docs/installing-drupal/trusted-host-settings']),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
else {
@@ -1383,7 +1384,7 @@ function system_requirements($phase): array {
'title' => t('Database driver provided by module'),
'value' => t('Not installed'),
'description' => t('The current database driver is provided by the module: %module. The module is currently not installed. You should immediately <a href=":install">install</a> the module.', ['%module' => $provider, ':install' => Url::fromRoute('system.modules_list')->toString()]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
}
@@ -1403,7 +1404,7 @@ function system_requirements($phase): array {
'title' => t('Xdebug settings'),
'value' => t('xdebug.max_nesting_level is set to %value.', ['%value' => $current_nesting_level]),
'description' => t('Set <code>xdebug.max_nesting_level=@level</code> in your PHP configuration as some pages in your Drupal site will not work when this setting is too low.', ['@level' => $minimum_nesting_level]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
}
@@ -1420,7 +1421,7 @@ function system_requirements($phase): array {
$requirements['max_path_on_windows'] = [
'title' => t('Windows installation depth'),
'description' => t('The public files directory path is %depth characters. Paths longer than 120 characters will cause problems on Windows.', ['%depth' => $depth]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
}
@@ -1430,7 +1431,7 @@ function system_requirements($phase): array {
'title' => t('Limited date range'),
'value' => t('Your PHP installation has a limited date range.'),
'description' => t('You are running on a system where PHP is compiled or limited to using 32-bit integers. This will limit the range of dates and timestamps to the years 1901-2038. Read about the <a href=":url">limitations of 32-bit PHP</a>.', [':url' => 'https://www.drupal.org/docs/system-requirements/limitations-of-32-bit-php']),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
@@ -1443,7 +1444,7 @@ function system_requirements($phase): array {
'title' => t('Configuration install'),
'value' => $install_state['parameters']['profile'],
'description' => t('The selected profile has a hook_install() implementation and therefore can not be installed from configuration.'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
}
@@ -1457,7 +1458,7 @@ function system_requirements($phase): array {
$requirements['install_profile_in_settings'] = [
'title' => t('Install profile in settings'),
'value' => t("Drupal 9 no longer uses the \$settings['install_profile'] value in settings.php and it should be removed."),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
}
@@ -1501,7 +1502,7 @@ function system_requirements($phase): array {
'@previous_major' => 9,
':url' => 'https://www.drupal.org/docs/upgrading-drupal/drupal-8-and-higher',
]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
else {
@@ -1513,7 +1514,7 @@ function system_requirements($phase): array {
'@last_removed_version' => $data['last_removed'],
'@installed_version' => $data['installed_version'],
]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
}
@@ -1541,7 +1542,7 @@ function system_requirements($phase): array {
$requirements[$module . '_post_update_removed'] = [
'title' => t('Missing updates for: @module', ['@module' => $module_info->info['name']]),
'description' => $description,
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
}
}
@@ -1575,7 +1576,7 @@ function system_requirements($phase): array {
'@future_update' => $future_update,
'@future_version_string' => $future_version_string,
]),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
break;
}
@@ -1598,7 +1599,7 @@ function system_requirements($phase): array {
'system.development_settings',
)->toString(),
]),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
$render_cache_disabled = $development_settings->get('disable_rendered_output_cache_bins', FALSE);
@@ -1611,7 +1612,7 @@ function system_requirements($phase): array {
'system.development_settings',
)->toString(),
]),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
}
@@ -1702,7 +1703,7 @@ function _system_advisories_requirements(array &$requirements): void {
}
catch (ClientExceptionInterface $exception) {
$requirements['system_advisories']['title'] = t('Critical security announcements');
- $requirements['system_advisories']['severity'] = REQUIREMENT_WARNING;
+ $requirements['system_advisories']['severity'] = RequirementSeverity::Warning;
$requirements['system_advisories']['description'] = ['#theme' => 'system_security_advisories_fetch_error_message'];
Error::logException(\Drupal::logger('system'), $exception, 'Failed to retrieve security advisory data.');
return;
@@ -1710,10 +1711,10 @@ function _system_advisories_requirements(array &$requirements): void {
if (!empty($advisories)) {
$advisory_links = [];
- $severity = REQUIREMENT_WARNING;
+ $severity = RequirementSeverity::Warning;
foreach ($advisories as $advisory) {
if (!$advisory->isPsa()) {
- $severity = REQUIREMENT_ERROR;
+ $severity = RequirementSeverity::Error;
}
$advisory_links[] = new Link($advisory->getTitle(), Url::fromUri($advisory->getUrl()));
}
diff --git a/core/modules/system/system.libraries.yml b/core/modules/system/system.libraries.yml
index 03baf83d3bb..af0eeea05d2 100644
--- a/core/modules/system/system.libraries.yml
+++ b/core/modules/system/system.libraries.yml
@@ -9,7 +9,6 @@ base:
css/components/hidden.module.css: { weight: -10 }
css/components/item-list.module.css: { weight: -10 }
css/components/js.module.css: { weight: -10 }
- css/components/position-container.module.css: { weight: -10 }
css/components/reset-appearance.module.css: { weight: -10 }
admin:
diff --git a/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz b/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz
index 5d8c9974469..077d0645ddc 100644
--- a/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz
+++ b/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz
Binary files differ
diff --git a/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz b/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz
index 423f49a1d40..5db0b3a5aae 100644
--- a/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz
+++ b/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz
Binary files differ
diff --git a/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install
index beaa3cd15b7..483a1d01717 100644
--- a/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install
+++ b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install
@@ -7,6 +7,8 @@
declare(strict_types=1);
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
+
/**
* Implements hook_requirements().
*/
@@ -14,7 +16,7 @@ function experimental_module_requirements_test_requirements(): array {
$requirements = [];
if (\Drupal::state()->get('experimental_module_requirements_test_requirements', FALSE)) {
$requirements['experimental_module_requirements_test_requirements'] = [
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('The Experimental Test Requirements module can not be installed.'),
];
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
index 542c4e162e2..78328f9f8e4 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
@@ -35,32 +35,28 @@ class FormTestClickedButtonForm extends FormBase {
'#type' => 'textfield',
];
+ // Get button configurations, filter out NULL values.
+ $args = array_filter([$first, $second, $third]);
+
+ // Define button types for each argument.
+ $button_types = [
+ 's' => 'submit',
+ 'i' => 'image_button',
+ 'b' => 'button',
+ ];
+
// Loop through each path argument, adding buttons based on the information
// in the argument. For example, if the path is
// form-test/clicked-button/s/i/rb, then 3 buttons are added: a 'submit', an
// 'image_button', and a 'button' with #access=FALSE. This enables form.test
// to test a variety of combinations.
- $i = 0;
- $args = [$first, $second, $third];
- foreach ($args as $arg) {
- $name = 'button' . ++$i;
- // 's', 'b', or 'i' in the argument define the button type wanted.
- if (!is_string($arg)) {
- $type = NULL;
- }
- elseif (str_contains($arg, 's')) {
- $type = 'submit';
- }
- elseif (str_contains($arg, 'b')) {
- $type = 'button';
- }
- elseif (str_contains($arg, 'i')) {
- $type = 'image_button';
- }
- else {
- $type = NULL;
- }
- if (isset($type)) {
+ foreach ($args as $index => $arg) {
+ // Get the button type based on the index of the argument.
+ $type = $button_types[$arg] ?? NULL;
+ $name = 'button' . ($index + 1);
+
+ if ($type) {
+ // Define the button.
$form[$name] = [
'#type' => $type,
'#name' => $name,
diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
index 908d0d8d454..09dbf982cf7 100644
--- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
+++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
@@ -253,7 +253,11 @@ class TestToolkit extends ImageToolkitBase {
* IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
*/
protected static function supportedTypes() {
- return [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
+ $types = [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
+ if (\Drupal::keyValue('image_test')->get('avif_enabled', FALSE)) {
+ $types[] = IMAGETYPE_AVIF;
+ }
+ return $types;
}
/**
diff --git a/core/modules/system/tests/modules/module_install_unmet_requirements/src/Install/Requirements/ModuleInstallUnmetRequirementsRequirements.php b/core/modules/system/tests/modules/module_install_unmet_requirements/src/Install/Requirements/ModuleInstallUnmetRequirementsRequirements.php
index 4d7367ff414..b6a532a1802 100644
--- a/core/modules/system/tests/modules/module_install_unmet_requirements/src/Install/Requirements/ModuleInstallUnmetRequirementsRequirements.php
+++ b/core/modules/system/tests/modules/module_install_unmet_requirements/src/Install/Requirements/ModuleInstallUnmetRequirementsRequirements.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\module_install_unmet_requirements\Install\Requirements;
use Drupal\Core\Extension\InstallRequirementsInterface;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
/**
* Provides method for checking requirements during install time.
@@ -17,7 +18,7 @@ class ModuleInstallUnmetRequirementsRequirements implements InstallRequirementsI
public static function getRequirements(): array {
$requirements['testing_requirements'] = [
'title' => t('Testing requirements'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('Testing requirements failed requirements.'),
];
diff --git a/core/modules/system/tests/modules/module_runtime_requirements/src/Hook/ModuleRuntimeRequirementsHooks.php b/core/modules/system/tests/modules/module_runtime_requirements/src/Hook/ModuleRuntimeRequirementsHooks.php
index 0fa4b2f6f80..31358a595d7 100644
--- a/core/modules/system/tests/modules/module_runtime_requirements/src/Hook/ModuleRuntimeRequirementsHooks.php
+++ b/core/modules/system/tests/modules/module_runtime_requirements/src/Hook/ModuleRuntimeRequirementsHooks.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\module_runtime_requirements\Hook;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -24,13 +25,13 @@ class ModuleRuntimeRequirementsHooks {
'title' => $this->t('RuntimeError'),
'value' => $this->t('None'),
'description' => $this->t('Runtime Error.'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
],
'test.runtime.error.alter' => [
'title' => $this->t('RuntimeError'),
'value' => $this->t('None'),
'description' => $this->t('Runtime Error.'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
],
];
}
@@ -44,7 +45,7 @@ class ModuleRuntimeRequirementsHooks {
'title' => $this->t('RuntimeWarning'),
'value' => $this->t('None'),
'description' => $this->t('Runtime Warning.'),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
diff --git a/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php b/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
index 1cbb9e6b422..db923382a21 100644
--- a/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
+++ b/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
@@ -4,19 +4,19 @@ declare(strict_types=1);
namespace Drupal\module_test_oop_preprocess\Hook;
-use Drupal\Core\Hook\Attribute\Preprocess;
+use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for module_test_oop_preprocess.
*/
class ModuleTestOopPreprocessThemeHooks {
- #[Preprocess]
+ #[Hook('preprocess')]
public function rootPreprocess($arg): mixed {
return $arg;
}
- #[Preprocess('test')]
+ #[Hook('preprocess_test')]
public function preprocessTest($arg): mixed {
return $arg;
}
diff --git a/core/modules/system/tests/modules/module_update_requirements/src/Hook/ModuleUpdateRequirementsHooks.php b/core/modules/system/tests/modules/module_update_requirements/src/Hook/ModuleUpdateRequirementsHooks.php
index f0666222f14..073baba95c9 100644
--- a/core/modules/system/tests/modules/module_update_requirements/src/Hook/ModuleUpdateRequirementsHooks.php
+++ b/core/modules/system/tests/modules/module_update_requirements/src/Hook/ModuleUpdateRequirementsHooks.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\module_update_requirements\Hook;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -24,13 +25,13 @@ class ModuleUpdateRequirementsHooks {
'title' => $this->t('UpdateError'),
'value' => $this->t('None'),
'description' => $this->t('Update Error.'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
],
'test.update.error.alter' => [
'title' => $this->t('UpdateError'),
'value' => $this->t('None'),
'description' => $this->t('Update Error.'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
],
];
}
@@ -44,7 +45,7 @@ class ModuleUpdateRequirementsHooks {
'title' => $this->t('UpdateWarning'),
'value' => $this->t('None'),
'description' => $this->t('Update Warning.'),
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
}
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 fb84be133cd..a93f726fafd 100644
--- a/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
+++ b/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
@@ -7,6 +7,8 @@
declare(strict_types=1);
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
+
/**
* Implements hook_requirements().
*
@@ -19,20 +21,20 @@ function requirements1_test_requirements($phase): array {
if ('install' == $phase) {
$requirements['requirements1_test'] = [
'title' => t('Requirements 1 Test'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('Requirements 1 Test failed requirements.'),
];
}
$requirements['requirements1_test_alterable'] = [
'title' => t('Requirements 1 Test Alterable'),
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
'description' => t('A requirement that will be altered.'),
];
$requirements['requirements1_test_deletable'] = [
'title' => t('Requirements 1 Test Deletable'),
- 'severity' => REQUIREMENT_INFO,
+ 'severity' => RequirementSeverity::Info,
'description' => t('A requirement that will be deleted.'),
];
diff --git a/core/modules/system/tests/modules/requirements1_test/src/Hook/Requirements1TestHooks.php b/core/modules/system/tests/modules/requirements1_test/src/Hook/Requirements1TestHooks.php
index c766f6f423a..ce3eebfb35b 100644
--- a/core/modules/system/tests/modules/requirements1_test/src/Hook/Requirements1TestHooks.php
+++ b/core/modules/system/tests/modules/requirements1_test/src/Hook/Requirements1TestHooks.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\requirements1_test\Hook;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -22,7 +23,7 @@ class Requirements1TestHooks {
// Change the title.
$requirements['requirements1_test_alterable']['title'] = $this->t('Requirements 1 Test - Changed');
// Decrease the severity.
- $requirements['requirements1_test_alterable']['severity'] = REQUIREMENT_WARNING;
+ $requirements['requirements1_test_alterable']['severity'] = RequirementSeverity::Warning;
// Delete 'requirements1_test_deletable',
unset($requirements['requirements1_test_deletable']);
}
diff --git a/core/modules/system/tests/modules/session_test/session_test.routing.yml b/core/modules/system/tests/modules/session_test/session_test.routing.yml
index fe85de11032..f11bd86b4d7 100644
--- a/core/modules/system/tests/modules/session_test/session_test.routing.yml
+++ b/core/modules/system/tests/modules/session_test/session_test.routing.yml
@@ -179,3 +179,25 @@ session_test.trigger_write_exception:
no_cache: TRUE
requirements:
_access: 'TRUE'
+
+session_test.legacy_get:
+ path: '/session-test/legacy-get'
+ defaults:
+ _title: 'Legacy session value'
+ _controller: '\Drupal\session_test\Controller\LegacySessionTestController::get'
+ options:
+ no_cache: TRUE
+ requirements:
+ _access: 'TRUE'
+
+session_test.legacy_set:
+ path: '/session-test/legacy-set/{test_value}'
+ defaults:
+ _title: 'Set legacy session value'
+ _controller: '\Drupal\session_test\Controller\LegacySessionTestController::set'
+ options:
+ no_cache: TRUE
+ converters:
+ test_value: '\s+'
+ requirements:
+ _access: 'TRUE'
diff --git a/core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php b/core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php
new file mode 100644
index 00000000000..a1438a0108e
--- /dev/null
+++ b/core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\session_test\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+
+/**
+ * Controller providing page callbacks for legacy session tests.
+ */
+class LegacySessionTestController extends ControllerBase {
+
+ /**
+ * Prints the stored session value to the screen.
+ */
+ public function get(): array {
+ return empty($_SESSION['legacy_test_value'])
+ ? []
+ : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $_SESSION['legacy_test_value']])];
+ }
+
+ /**
+ * Stores a value in $_SESSION['legacy_test_value'].
+ *
+ * @param string $test_value
+ * A session value.
+ */
+ public function set(string $test_value): array {
+ $_SESSION['legacy_test_value'] = $test_value;
+
+ return ['#markup' => $this->t('The current value of the stored session variable has been set to %val', ['%val' => $test_value])];
+ }
+
+}
diff --git a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
index 9c7bb97e24b..461581abaa7 100644
--- a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
+++ b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
@@ -11,20 +11,21 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
- * Controller providing page callbacks for the action admin interface.
+ * Controller providing page callbacks for session tests.
*/
class SessionTestController extends ControllerBase {
/**
* Prints the stored session value to the screen.
*
- * @return string
- * A notification message.
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The incoming request.
*/
- public function get() {
- return empty($_SESSION['session_test_value'])
+ public function get(Request $request): array {
+ $value = $request->getSession()->get('session_test_value');
+ return empty($value)
? []
- : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $_SESSION['session_test_value']])];
+ : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $value])];
}
/**
@@ -32,11 +33,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
- *
- * @return string
- * A notification message.
*/
- public function getFromSessionObject(Request $request) {
+ public function getFromSessionObject(Request $request): array {
$value = $request->getSession()->get("session_test_key");
return empty($value)
? []
@@ -48,16 +46,13 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
- *
- * @return string
- * A notification message with session ID.
*/
- public function getId(Request $request) {
- // Set a value in $_SESSION, so that SessionManager::save() will start
+ public function getId(Request $request): array {
+ // Set a value in session, so that SessionManager::save() will start
// a session.
- $_SESSION['test'] = 'test';
-
- $request->getSession()->save();
+ $session = $request->getSession();
+ $session->set('test', 'test');
+ $session->save();
return ['#markup' => 'session_id:' . session_id() . "\n"];
}
@@ -67,11 +62,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return string
- * A notification message with session ID.
*/
- public function getIdFromCookie(Request $request) {
+ public function getIdFromCookie(Request $request): array {
return [
'#markup' => 'session_id:' . $request->cookies->get(session_name()) . "\n",
'#cache' => ['contexts' => ['cookies:' . session_name()]],
@@ -79,16 +71,15 @@ class SessionTestController extends ControllerBase {
}
/**
- * Stores a value in $_SESSION['session_test_value'].
+ * Stores a value in 'session_test_value' session attribute.
*
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The request object.
* @param string $test_value
* A session value.
- *
- * @return string
- * A notification message.
*/
- public function set($test_value) {
- $_SESSION['session_test_value'] = $test_value;
+ public function set(Request $request, $test_value): array {
+ $request->getSession()->set('session_test_value', $test_value);
return ['#markup' => $this->t('The current value of the stored session variable has been set to %val', ['%val' => $test_value])];
}
@@ -96,25 +87,21 @@ class SessionTestController extends ControllerBase {
/**
* Turns off session saving and then tries to save a value anyway.
*
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The request object.
* @param string $test_value
* A session value.
- *
- * @return string
- * A notification message.
*/
- public function noSet($test_value) {
+ public function noSet(Request $request, $test_value): array {
\Drupal::service('session_handler.write_safe')->setSessionWritable(FALSE);
- $this->set($test_value);
+ $this->set($request, $test_value);
return ['#markup' => $this->t('session saving was disabled, and then %val was set', ['%val' => $test_value])];
}
/**
* Sets a message to me displayed on the following page.
- *
- * @return string
- * A notification message.
*/
- public function setMessage() {
+ public function setMessage(): Response {
$this->messenger()->addStatus($this->t('This is a dummy message.'));
return new Response((string) $this->t('A message was set.'));
// Do not return anything, so the current request does not result in a
@@ -124,11 +111,8 @@ class SessionTestController extends ControllerBase {
/**
* Sets a message but call drupal_save_session(FALSE).
- *
- * @return string
- * A notification message.
*/
- public function setMessageButDoNotSave() {
+ public function setMessageButDoNotSave(): array {
\Drupal::service('session_handler.write_safe')->setSessionWritable(FALSE);
$this->setMessage();
return ['#markup' => ''];
@@ -136,11 +120,8 @@ class SessionTestController extends ControllerBase {
/**
* Only available if current user is logged in.
- *
- * @return string
- * A notification message.
*/
- public function isLoggedIn() {
+ public function isLoggedIn(): array {
return ['#markup' => $this->t('User is logged in.')];
}
@@ -149,20 +130,13 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
- *
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * The response.
*/
- public function traceHandler(Request $request) {
- // Start a session if necessary, set a value and then save and close it.
- $request->getSession()->start();
- if (empty($_SESSION['trace-handler'])) {
- $_SESSION['trace-handler'] = 1;
- }
- else {
- $_SESSION['trace-handler']++;
- }
- $request->getSession()->save();
+ public function traceHandler(Request $request): Response {
+ // Increment trace-handler counter and save the session.
+ $session = $request->getSession();
+ $counter = $session->get('trace-handler', 0);
+ $session->set('trace-handler', $counter + 1);
+ $session->save();
// Collect traces and return them in JSON format.
$trace = \Drupal::service('session_test.session_handler_proxy_trace')->getArrayCopy();
@@ -182,15 +156,13 @@ class SessionTestController extends ControllerBase {
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
*
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * The response.
- *
* @throws \AssertionError
*/
- public function traceHandlerRewriteUnmodified(Request $request) {
+ public function traceHandlerRewriteUnmodified(Request $request): Response {
// Assert that there is an existing session with stacked handler trace data.
+ $session = $request->getSession();
assert(
- is_int($_SESSION['trace-handler']) && $_SESSION['trace-handler'] > 0,
+ is_int($session->get('trace-handler')) && $session->get('trace-handler') > 0,
'Existing stacked session handler trace not found'
);
@@ -199,7 +171,7 @@ class SessionTestController extends ControllerBase {
ini_get('session.lazy_write'),
'session.lazy_write must be enabled to invoke updateTimestamp()'
);
- $request->getSession()->save();
+ $session->save();
// Collect traces and return them in JSON format.
$trace = \Drupal::service('session_test.session_handler_proxy_trace')->getArrayCopy();
@@ -212,11 +184,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * A response object containing the session values and the user ID.
*/
- public function getSession(Request $request) {
+ public function getSession(Request $request): Response {
return new JsonResponse(['session' => $request->getSession()->all(), 'user' => $this->currentUser()->id()]);
}
@@ -227,11 +196,8 @@ class SessionTestController extends ControllerBase {
* The request object.
* @param string $test_value
* A value to set on the session.
- *
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * A response object containing the session values and the user ID.
*/
- public function setSession(Request $request, $test_value) {
+ public function setSession(Request $request, $test_value): Response {
$session = $request->getSession();
$session->set('test_value', $test_value);
return new JsonResponse(['session' => $session->all(), 'user' => $this->currentUser()->id()]);
@@ -242,11 +208,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\Response
- * The response object.
*/
- public function setSessionBagFlag(Request $request) {
+ public function setSessionBagFlag(Request $request): Response {
/** @var \Drupal\session_test\Session\TestSessionBag */
$bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
$bag->setFlag();
@@ -258,11 +221,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\Response
- * The response object.
*/
- public function clearSessionBagFlag(Request $request) {
+ public function clearSessionBagFlag(Request $request): Response {
/** @var \Drupal\session_test\Session\TestSessionBag */
$bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
$bag->clearFlag();
@@ -274,11 +234,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\Response
- * The response object.
*/
- public function hasSessionBagFlag(Request $request) {
+ public function hasSessionBagFlag(Request $request): Response {
/** @var \Drupal\session_test\Session\TestSessionBag */
$bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
return new Response(empty($bag->hasFlag())
@@ -293,7 +250,7 @@ class SessionTestController extends ControllerBase {
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*/
- public function triggerWriteException(Request $request) {
+ public function triggerWriteException(Request $request): Response {
$session = $request->getSession();
$session->set('test_value', 'Ensure session contains some data');
diff --git a/core/modules/system/tests/modules/test_htmx/css/style.css b/core/modules/system/tests/modules/test_htmx/css/style.css
new file mode 100644
index 00000000000..75b757dbe3c
--- /dev/null
+++ b/core/modules/system/tests/modules/test_htmx/css/style.css
@@ -0,0 +1,3 @@
+.ajax-content {
+ background-color: red;
+}
diff --git a/core/modules/system/tests/modules/test_htmx/js/behavior.js b/core/modules/system/tests/modules/test_htmx/js/behavior.js
new file mode 100644
index 00000000000..5ca13501cee
--- /dev/null
+++ b/core/modules/system/tests/modules/test_htmx/js/behavior.js
@@ -0,0 +1,14 @@
+((Drupal, once) => {
+ Drupal.behaviors.htmx_test = {
+ attach(context, settings) {
+ once('htmx-init', '.ajax-content', context).forEach((el) => {
+ el.innerText = 'initialized';
+ });
+ },
+ detach(context, settings, trigger) {
+ once.remove('htmx-init', '.ajax-content', context).forEach((el) => {
+ el.remove();
+ });
+ },
+ };
+})(Drupal, once);
diff --git a/core/modules/system/tests/modules/test_htmx/src/Controller/HtmxTestAttachmentsController.php b/core/modules/system/tests/modules/test_htmx/src/Controller/HtmxTestAttachmentsController.php
new file mode 100644
index 00000000000..9045a4c8b9c
--- /dev/null
+++ b/core/modules/system/tests/modules/test_htmx/src/Controller/HtmxTestAttachmentsController.php
@@ -0,0 +1,83 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\test_htmx\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Url;
+
+/**
+ * Returns responses for HTMX Test Attachments routes.
+ */
+final class HtmxTestAttachmentsController extends ControllerBase {
+
+ /**
+ * Builds the response.
+ *
+ * @return mixed[]
+ * A render array.
+ */
+ public function page(): array {
+ return self::generateHtmxButton();
+ }
+
+ /**
+ * Builds the HTMX response.
+ *
+ * @return mixed[]
+ * A render array.
+ */
+ public function replace(): array {
+ $build['content'] = [
+ '#type' => 'container',
+ '#attached' => [
+ 'library' => ['test_htmx/assets'],
+ ],
+ '#attributes' => [
+ 'class' => ['ajax-content'],
+ ],
+ 'example' => ['#markup' => 'Initial Content'],
+ ];
+
+ return $build;
+ }
+
+ /**
+ * Static helper to for reusable render array.
+ *
+ * @return array
+ * The render array.
+ */
+ public static function generateHtmxButton(): array {
+ $url = Url::fromRoute('test_htmx.attachments.replace');
+ $build['replace'] = [
+ '#type' => 'html_tag',
+ '#tag' => 'button',
+ '#attributes' => [
+ 'type' => 'button',
+ 'name' => 'replace',
+ 'data-hx-get' => $url->toString(),
+ 'data-hx-select' => 'div.ajax-content',
+ 'data-hx-target' => '[data-drupal-htmx-target]',
+ ],
+ '#value' => 'Click this',
+ '#attached' => [
+ 'library' => [
+ 'core/drupal.htmx',
+ ],
+ ],
+ ];
+
+ $build['content'] = [
+ '#type' => 'container',
+ '#attributes' => [
+ 'data-drupal-htmx-target' => TRUE,
+ 'class' => ['htmx-test-container'],
+ ],
+ ];
+
+ return $build;
+ }
+
+}
diff --git a/core/modules/system/tests/modules/test_htmx/src/Form/HtmxTestAjaxForm.php b/core/modules/system/tests/modules/test_htmx/src/Form/HtmxTestAjaxForm.php
new file mode 100644
index 00000000000..8fffbbc5f40
--- /dev/null
+++ b/core/modules/system/tests/modules/test_htmx/src/Form/HtmxTestAjaxForm.php
@@ -0,0 +1,51 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\test_htmx\Form;
+
+use Drupal\Core\Form\FormBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\test_htmx\Controller\HtmxTestAttachmentsController;
+
+/**
+ * A small form used to insert an HTMX powered element using ajax API.
+ */
+class HtmxTestAjaxForm extends FormBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormId(): string {
+ return 'htmx_test_ajax_form';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildForm(array $form, FormStateInterface $form_state): array {
+ $build = [
+ 'ajax-button' => [
+ '#type' => 'button',
+ '#value' => 'Trigger Ajax',
+ '#submit_button' => FALSE,
+ '#ajax' => [
+ 'callback' => [
+ HtmxTestAttachmentsController::class,
+ 'generateHtmxButton',
+ ],
+ 'wrapper' => 'ajax-test-container',
+ ],
+ ],
+ '#suffix' => '<div id="ajax-test-container"></div>',
+ ];
+
+ return $build;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, FormStateInterface $form_state): void {}
+
+}
diff --git a/core/modules/system/tests/modules/test_htmx/test_htmx.info.yml b/core/modules/system/tests/modules/test_htmx/test_htmx.info.yml
new file mode 100644
index 00000000000..c713e0624d9
--- /dev/null
+++ b/core/modules/system/tests/modules/test_htmx/test_htmx.info.yml
@@ -0,0 +1,4 @@
+name: 'HTMX Test Fixtures'
+type: module
+description: 'Test fixtures for HTMX integration'
+package: Testing
diff --git a/core/modules/system/tests/modules/test_htmx/test_htmx.libraries.yml b/core/modules/system/tests/modules/test_htmx/test_htmx.libraries.yml
new file mode 100644
index 00000000000..31ac1d2b8ab
--- /dev/null
+++ b/core/modules/system/tests/modules/test_htmx/test_htmx.libraries.yml
@@ -0,0 +1,10 @@
+assets:
+ version: VERSION
+ js:
+ js/behavior.js: {}
+ css:
+ theme:
+ css/style.css: {}
+ dependencies:
+ - core/drupal
+ - core/once
diff --git a/core/modules/system/tests/modules/test_htmx/test_htmx.routing.yml b/core/modules/system/tests/modules/test_htmx/test_htmx.routing.yml
new file mode 100644
index 00000000000..406c3027f3b
--- /dev/null
+++ b/core/modules/system/tests/modules/test_htmx/test_htmx.routing.yml
@@ -0,0 +1,23 @@
+test_htmx.attachments.page:
+ path: '/htmx-test-attachments/page'
+ defaults:
+ _title: 'Page'
+ _controller: '\Drupal\test_htmx\Controller\HtmxTestAttachmentsController::page'
+ requirements:
+ _permission: 'access content'
+
+test_htmx.attachments.replace:
+ path: '/htmx-test-attachments/replace'
+ defaults:
+ _title: 'Ajax Content'
+ _controller: '\Drupal\test_htmx\Controller\HtmxTestAttachmentsController::replace'
+ requirements:
+ _permission: 'access content'
+
+test_htmx.attachments.ajax:
+ path: '/htmx-test-attachments/ajax'
+ defaults:
+ _title: 'Ajax'
+ _form: '\Drupal\test_htmx\Form\HtmxTestAjaxForm'
+ requirements:
+ _permission: 'access content'
diff --git a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
index fc48756de51..7bfc10ef0ef 100644
--- a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
+++ b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Drupal\theme_test\Hook;
-use Drupal\Core\Hook\Attribute\Preprocess;
+use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for theme_test.
@@ -14,7 +14,7 @@ class ThemeTestThemeHooks {
/**
* Implements hook_preprocess_HOOK().
*/
- #[Preprocess('theme_test_preprocess_suggestions__monkey')]
+ #[Hook('preprocess_theme_test_preprocess_suggestions__monkey')]
public function preprocessTestSuggestions(&$variables): void {
$variables['foo'] = 'Monkey';
}
diff --git a/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php b/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
index 272ad65eff3..f5d0c150118 100644
--- a/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
+++ b/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
@@ -24,7 +24,7 @@ class TestLoader implements LoaderInterface {
/**
* {@inheritdoc}
*/
- public function exists(string $name) {
+ public function exists(string $name): bool {
return TRUE;
}
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
index 5927e31e460..e93fe8bb80f 100644
--- 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
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\update_script_test\Hook;
use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Hook\Attribute\Hook;
/**
@@ -25,21 +26,21 @@ class UpdateScriptTestRequirements {
// 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:
+ case RequirementSeverity::Warning->value:
$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,
+ 'severity' => RequirementSeverity::Warning,
];
break;
- case REQUIREMENT_ERROR:
+ case RequirementSeverity::Error->value:
$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,
+ 'severity' => RequirementSeverity::Error,
];
break;
}
@@ -51,7 +52,7 @@ class UpdateScriptTestRequirements {
*/
#[Hook('update_requirements_alter')]
public function updateAlter(array &$requirements): void {
- if (isset($requirements['update_script_test']) && $requirements['update_script_test']['severity'] === REQUIREMENT_ERROR) {
+ if (isset($requirements['update_script_test']) && $requirements['update_script_test']['severity'] === RequirementSeverity::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_test_schema/src/Hook/UpdateTestSchemaRequirements.php b/core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php
index de96ce3e36a..3199527bd05 100644
--- 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
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\update_test_schema\Hook;
use Drupal\Component\Render\FormattableMarkup;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\Url;
@@ -22,7 +23,7 @@ class UpdateTestSchemaRequirements {
$requirements['path_alias_test'] = [
'title' => 'Path alias test',
'value' => 'Check a path alias for the admin page',
- 'severity' => REQUIREMENT_INFO,
+ 'severity' => RequirementSeverity::Info,
'description' => new FormattableMarkup('Visit <a href=":link">the structure page</a> to do many useful things.', [
':link' => Url::fromRoute('system.admin_structure')->toString(),
]),
diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php
index 6812903dccc..f45e45e6159 100644
--- a/core/modules/system/tests/src/Functional/Form/FormTest.php
+++ b/core/modules/system/tests/src/Functional/Form/FormTest.php
@@ -6,7 +6,6 @@ namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Html;
-use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Form\FormState;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
@@ -199,7 +198,7 @@ class FormTest extends BrowserTestBase {
$expected_key = array_search($error->getText(), $expected);
// If the error message is not one of the expected messages, fail.
if ($expected_key === FALSE) {
- $this->fail(new FormattableMarkup("Unexpected error message: @error", ['@error' => $error[0]]));
+ $this->fail("Unexpected error message: " . $error[0]);
}
// Remove the expected message from the list once it is found.
else {
@@ -209,7 +208,7 @@ class FormTest extends BrowserTestBase {
// Fail if any expected messages were not found.
foreach ($expected as $not_found) {
- $this->fail(new FormattableMarkup("Found error message: @error", ['@error' => $not_found]));
+ $this->fail("Found error message: " . $not_found);
}
// Verify that input elements are still empty.
@@ -610,14 +609,6 @@ class FormTest extends BrowserTestBase {
public function testNumber(): void {
$form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestNumberForm');
- // Array with all the error messages to be checked.
- $error_messages = [
- 'no_number' => '%name must be a number.',
- 'too_low' => '%name must be higher than or equal to %min.',
- 'too_high' => '%name must be lower than or equal to %max.',
- 'step_mismatch' => '%name is not a valid number.',
- ];
-
// The expected errors.
$expected = [
'integer_no_number' => 'no_number',
@@ -648,21 +639,26 @@ class FormTest extends BrowserTestBase {
$this->submitForm([], 'Submit');
foreach ($expected as $element => $error) {
- // Create placeholder array.
- $placeholders = [
- '%name' => $form[$element]['#title'],
- '%min' => $form[$element]['#min'] ?? '0',
- '%max' => $form[$element]['#max'] ?? '0',
+ // Array with all the error messages to be checked.
+ $name = $form[$element]['#title'];
+ $min = $form[$element]['#min'] ?? '0';
+ $max = $form[$element]['#max'] ?? '0';
+
+ $error_messages = [
+ 'no_number' => "<em class=\"placeholder\">$name</em> must be a number.",
+ 'too_low' => "<em class=\"placeholder\">$name</em> must be higher than or equal to <em class=\"placeholder\">$min</em>.",
+ 'too_high' => "<em class=\"placeholder\">$name</em> must be lower than or equal to <em class=\"placeholder\">$max</em>.",
+ 'step_mismatch' => "<em class=\"placeholder\">$name</em> is not a valid number.",
];
foreach ($error_messages as $id => $message) {
// Check if the error exists on the page, if the current message ID is
// expected. Otherwise ensure that the error message is not present.
if ($id === $error) {
- $this->assertSession()->responseContains(new FormattableMarkup($message, $placeholders));
+ $this->assertSession()->responseContains($message);
}
else {
- $this->assertSession()->responseNotContains(new FormattableMarkup($message, $placeholders));
+ $this->assertSession()->responseNotContains($message);
}
}
}
diff --git a/core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php b/core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php
index 388e83f6fcc..b297647194a 100644
--- a/core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php
+++ b/core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\Tests\system\Functional\SecurityAdvisories;
use Drupal\advisory_feed_test\AdvisoryTestClientMiddleware;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\CronRunTrait;
@@ -140,10 +141,10 @@ class SecurityAdvisoryTest extends BrowserTestBase {
// If both PSA and non-PSA advisories are displayed they should be displayed
// as errors.
- $this->assertStatusReportLinks($mixed_advisory_links, REQUIREMENT_ERROR);
+ $this->assertStatusReportLinks($mixed_advisory_links, RequirementSeverity::Error);
// The advisories will be displayed on admin pages if the response was
// stored from the status report request.
- $this->assertAdminPageLinks($mixed_advisory_links, REQUIREMENT_ERROR);
+ $this->assertAdminPageLinks($mixed_advisory_links, RequirementSeverity::Error);
// Confirm that a user without the correct permission will not see the
// advisories on admin pages.
@@ -159,8 +160,8 @@ class SecurityAdvisoryTest extends BrowserTestBase {
$this->drupalLogin($this->user);
// Test cache.
AdvisoryTestClientMiddleware::setTestEndpoint($this->nonWorkingEndpoint);
- $this->assertAdminPageLinks($mixed_advisory_links, REQUIREMENT_ERROR);
- $this->assertStatusReportLinks($mixed_advisory_links, REQUIREMENT_ERROR);
+ $this->assertAdminPageLinks($mixed_advisory_links, RequirementSeverity::Error);
+ $this->assertStatusReportLinks($mixed_advisory_links, RequirementSeverity::Error);
// Tests transmit errors with a JSON endpoint.
$this->tempStore->delete('advisories_response');
@@ -195,8 +196,8 @@ class SecurityAdvisoryTest extends BrowserTestBase {
$this->assertAdvisoriesNotDisplayed($psa_advisory_links, ['system.admin']);
// If only PSA advisories are displayed they should be displayed as
// warnings.
- $this->assertStatusReportLinks($psa_advisory_links, REQUIREMENT_WARNING);
- $this->assertAdminPageLinks($psa_advisory_links, REQUIREMENT_WARNING);
+ $this->assertStatusReportLinks($psa_advisory_links, RequirementSeverity::Warning);
+ $this->assertAdminPageLinks($psa_advisory_links, RequirementSeverity::Warning);
AdvisoryTestClientMiddleware::setTestEndpoint($this->workingEndpointNonPsaOnly, TRUE);
$non_psa_advisory_links = [
@@ -205,8 +206,8 @@ class SecurityAdvisoryTest extends BrowserTestBase {
];
// If only non-PSA advisories are displayed they should be displayed as
// errors.
- $this->assertStatusReportLinks($non_psa_advisory_links, REQUIREMENT_ERROR);
- $this->assertAdminPageLinks($non_psa_advisory_links, REQUIREMENT_ERROR);
+ $this->assertStatusReportLinks($non_psa_advisory_links, RequirementSeverity::Error);
+ $this->assertAdminPageLinks($non_psa_advisory_links, RequirementSeverity::Error);
// Confirm that advisory fetching can be disabled after enabled.
$this->config('system.advisories')->set('enabled', FALSE)->save();
@@ -220,16 +221,15 @@ class SecurityAdvisoryTest extends BrowserTestBase {
*
* @param string[] $expected_link_texts
* The expected links' text.
- * @param int $error_or_warning
- * Whether the links are a warning or an error. Should be one of the
- * REQUIREMENT_* constants.
+ * @param \Drupal\Core\Extension\Requirement\RequirementSeverity $error_or_warning
+ * Whether the links are a warning or an error.
*
* @internal
*/
- private function assertAdminPageLinks(array $expected_link_texts, int $error_or_warning): void {
+ private function assertAdminPageLinks(array $expected_link_texts, RequirementSeverity $error_or_warning): void {
$assert = $this->assertSession();
$this->drupalGet(Url::fromRoute('system.admin'));
- if ($error_or_warning === REQUIREMENT_ERROR) {
+ if ($error_or_warning === RequirementSeverity::Error) {
$assert->pageTextContainsOnce('Error message');
$assert->pageTextNotContains('Warning message');
}
@@ -247,16 +247,15 @@ class SecurityAdvisoryTest extends BrowserTestBase {
*
* @param string[] $expected_link_texts
* The expected links' text.
- * @param int $error_or_warning
- * Whether the links are a warning or an error. Should be one of the
- * REQUIREMENT_* constants.
+ * @param \Drupal\Core\Extension\Requirement\RequirementSeverity::Error|\Drupal\Core\Extension\Requirement\RequirementSeverity::Warning $error_or_warning
+ * Whether the links are a warning or an error.
*
* @internal
*/
- private function assertStatusReportLinks(array $expected_link_texts, int $error_or_warning): void {
+ private function assertStatusReportLinks(array $expected_link_texts, RequirementSeverity $error_or_warning): void {
$this->drupalGet(Url::fromRoute('system.status'));
$assert = $this->assertSession();
- $selector = 'h3#' . ($error_or_warning === REQUIREMENT_ERROR ? 'error' : 'warning')
+ $selector = 'h3#' . $error_or_warning->status()
. ' ~ details.system-status-report__entry:contains("Critical security announcements")';
$assert->elementExists('css', $selector);
foreach ($expected_link_texts as $expected_link_text) {
diff --git a/core/modules/system/tests/src/Functional/Session/LegacySessionTest.php b/core/modules/system/tests/src/Functional/Session/LegacySessionTest.php
new file mode 100644
index 00000000000..84ab1ed9d5b
--- /dev/null
+++ b/core/modules/system/tests/src/Functional/Session/LegacySessionTest.php
@@ -0,0 +1,44 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\Tests\system\Functional\Session;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Drupal legacy session handling tests.
+ *
+ * @group legacy
+ * @group Session
+ */
+class LegacySessionTest extends BrowserTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ protected static $modules = ['session_test'];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected $defaultTheme = 'stark';
+
+ /**
+ * Tests data persistence via the session_test module callbacks.
+ */
+ public function testLegacyDataPersistence(): void {
+ $this->expectDeprecation('Storing values directly in $_SESSION is deprecated in drupal:11.2.0 and will become unsupported in drupal:12.0.0. Use $request-&gt;getSession()-&gt;set() instead. Affected keys: legacy_test_value. See https://www.drupal.org/node/3518527');
+ $value = $this->randomMachineName();
+
+ // Verify that the session value is stored.
+ $this->drupalGet('session-test/legacy-set/' . $value);
+ $this->assertSession()->pageTextContains($value);
+
+ // Verify that the session correctly returned the stored data for an
+ // authenticated user.
+ $this->drupalGet('session-test/legacy-get');
+ $this->assertSession()->pageTextContains($value);
+ }
+
+}
diff --git a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
index 41d60b8a42a..6e47278edad 100644
--- a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
+++ b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\system\Functional\System;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Site\Settings;
use Drupal\Tests\BrowserTestBase;
@@ -58,7 +59,7 @@ class SitesDirectoryHardeningTest extends BrowserTestBase {
// Manually trigger the requirements check.
$requirements = $this->checkSystemRequirements();
- $this->assertEquals(REQUIREMENT_WARNING, $requirements['configuration_files']['severity'], 'Warning severity is properly set.');
+ $this->assertEquals(RequirementSeverity::Warning, $requirements['configuration_files']['severity'], 'Warning severity is properly set.');
$this->assertEquals('Protection disabled', (string) $requirements['configuration_files']['value']);
$description = strip_tags((string) \Drupal::service('renderer')->renderInIsolation($requirements['configuration_files']['description']));
$this->assertStringContainsString('settings.php is not protected from modifications and poses a security risk.', $description);
diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
index f0f78b23c99..5be7e48289f 100644
--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
+++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\Tests\system\Functional\UpdateSystem;
use Drupal\Component\Serialization\Yaml;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
@@ -149,7 +150,7 @@ class UpdateScriptTest extends BrowserTestBase {
// First, run this test with pending updates to make sure they can be run
// successfully.
$this->drupalLogin($this->updateUser);
- $update_script_test_config->set('requirement_type', REQUIREMENT_WARNING)->save();
+ $update_script_test_config->set('requirement_type', RequirementSeverity::Warning->value)->save();
/** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
$update_registry = \Drupal::service('update.update_hook_registry');
$update_registry->setInstalledVersion('update_script_test', $update_registry->getInstalledVersion('update_script_test') - 1);
@@ -177,7 +178,7 @@ class UpdateScriptTest extends BrowserTestBase {
// If there is a requirements error, it should be displayed even after
// clicking the link to proceed (since the problem that triggered the error
// has not been fixed).
- $update_script_test_config->set('requirement_type', REQUIREMENT_ERROR)->save();
+ $update_script_test_config->set('requirement_type', RequirementSeverity::Error->value)->save();
$this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertSession()->pageTextContains('This is a requirements error provided by the update_script_test module.');
$this->clickLink('try again');
@@ -185,7 +186,7 @@ class UpdateScriptTest extends BrowserTestBase {
// Ensure that changes to a module's requirements that would cause errors
// are displayed correctly.
- $update_script_test_config->set('requirement_type', REQUIREMENT_OK)->save();
+ $update_script_test_config->set('requirement_type', RequirementSeverity::OK->value)->save();
\Drupal::state()->set('update_script_test.system_info_alter', ['dependencies' => ['a_module_that_does_not_exist']]);
$this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertSession()->responseContains('a_module_that_does_not_exist (Missing)');
diff --git a/core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php b/core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php
index 6c8c42da59e..82d866e985e 100644
--- a/core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php
+++ b/core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php
@@ -77,6 +77,8 @@ class DateFormatAccessControlHandlerTest extends KernelTestBase {
* An array of test cases.
*/
public static function providerTestAccess(): array {
+ $originalContainer = \Drupal::hasContainer() ? \Drupal::getContainer() : NULL;
+
$c = new ContainerBuilder();
$cache_contexts_manager = (new Prophet())->prophesize(CacheContextsManager::class);
$cache_contexts_manager->assertValidTokens()->willReturn(TRUE);
@@ -84,7 +86,7 @@ class DateFormatAccessControlHandlerTest extends KernelTestBase {
$c->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($c);
- return [
+ $data = [
'No permission + unlocked' => [
[],
'unlocked',
@@ -122,6 +124,13 @@ class DateFormatAccessControlHandlerTest extends KernelTestBase {
AccessResult::allowed()->addCacheContexts(['user.permissions']),
],
];
+
+ // Restore the original container if needed.
+ if ($originalContainer) {
+ \Drupal::setContainer($originalContainer);
+ }
+
+ return $data;
}
}
diff --git a/core/modules/system/tests/src/Kernel/Element/StatusReportPageTest.php b/core/modules/system/tests/src/Kernel/Element/StatusReportPageTest.php
new file mode 100644
index 00000000000..630a3a997dd
--- /dev/null
+++ b/core/modules/system/tests/src/Kernel/Element/StatusReportPageTest.php
@@ -0,0 +1,58 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\Tests\system\Kernel\Element;
+
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\system\Element\StatusReportPage;
+
+include_once \DRUPAL_ROOT . '/core/includes/install.inc';
+
+/**
+ * Tests the status report page element.
+ *
+ * @group system
+ * @group legacy
+ */
+class StatusReportPageTest extends KernelTestBase {
+
+ /**
+ * Tests the status report page element.
+ */
+ public function testPeRenderCounters(): void {
+ $element = [
+ '#requirements' => [
+ 'foo' => [
+ 'title' => 'Foo',
+ 'severity' => \REQUIREMENT_INFO,
+ ],
+ 'baz' => [
+ 'title' => 'Baz',
+ 'severity' => RequirementSeverity::Warning,
+ ],
+ 'wiz' => [
+ 'title' => 'Wiz',
+ 'severity' => RequirementSeverity::Error,
+ ],
+ ],
+ ];
+ $this->expectDeprecation('Calling Drupal\system\Element\StatusReportPage::preRenderCounters() with an array of $requirements with \'severity\' with values not of type Drupal\Core\Extension\Requirement\RequirementSeverity enums is deprecated in drupal:11.2.0 and is required in drupal:12.0.0. See https://www.drupal.org/node/3410939');
+ $element = StatusReportPage::preRenderCounters($element);
+
+ $error = $element['#counters']['error'];
+ $this->assertEquals(1, $error['#amount']);
+ $this->assertEquals('error', $error['#severity']);
+
+ $warning = $element['#counters']['warning'];
+ $this->assertEquals(1, $warning['#amount']);
+ $this->assertEquals('warning', $warning['#severity']);
+
+ $checked = $element['#counters']['checked'];
+ $this->assertEquals(1, $checked['#amount']);
+ $this->assertEquals('checked', $checked['#severity']);
+
+ }
+
+}
diff --git a/core/modules/system/tests/src/Kernel/Module/RequirementsTest.php b/core/modules/system/tests/src/Kernel/Module/RequirementsTest.php
index 2258b08bc49..c22529a72db 100644
--- a/core/modules/system/tests/src/Kernel/Module/RequirementsTest.php
+++ b/core/modules/system/tests/src/Kernel/Module/RequirementsTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\system\Kernel\Module;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\KernelTests\KernelTestBase;
/**
@@ -28,7 +29,7 @@ class RequirementsTest extends KernelTestBase {
$requirements = $this->container->get('system.manager')->listRequirements();
// @see requirements1_test_requirements_alter()
$this->assertEquals('Requirements 1 Test - Changed', $requirements['requirements1_test_alterable']['title']);
- $this->assertEquals(REQUIREMENT_WARNING, $requirements['requirements1_test_alterable']['severity']);
+ $this->assertEquals(RequirementSeverity::Warning, $requirements['requirements1_test_alterable']['severity']);
$this->assertArrayNotHasKey('requirements1_test_deletable', $requirements);
}
diff --git a/core/modules/system/tests/src/Kernel/System/RunTimeRequirementsTest.php b/core/modules/system/tests/src/Kernel/System/RunTimeRequirementsTest.php
index af027b48051..e39e509cb14 100644
--- a/core/modules/system/tests/src/Kernel/System/RunTimeRequirementsTest.php
+++ b/core/modules/system/tests/src/Kernel/System/RunTimeRequirementsTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\system\Kernel\System;
+use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\KernelTests\KernelTestBase;
@@ -31,7 +32,7 @@ class RunTimeRequirementsTest extends KernelTestBase {
'title' => 'RuntimeError',
'value' => 'None',
'description' => 'Runtime Error.',
- 'severity' => REQUIREMENT_ERROR,
+ 'severity' => RequirementSeverity::Error,
];
$requirements = \Drupal::service('system.manager')->listRequirements()['test.runtime.error'];
$this->assertEquals($testRequirements, $requirements);
@@ -40,7 +41,7 @@ class RunTimeRequirementsTest extends KernelTestBase {
'title' => 'RuntimeWarning',
'value' => 'None',
'description' => 'Runtime Warning.',
- 'severity' => REQUIREMENT_WARNING,
+ 'severity' => RequirementSeverity::Warning,
];
$requirementsAlter = \Drupal::service('system.manager')->listRequirements()['test.runtime.error.alter'];
$this->assertEquals($testRequirementsAlter, $requirementsAlter);