diff options
-rw-r--r-- | core/MAINTAINERS.txt | 4 | ||||
-rw-r--r-- | core/lib/Drupal/Core/Render/Renderer.php | 8 | ||||
-rw-r--r-- | core/lib/Drupal/Core/Render/RendererInterface.php | 2 | ||||
-rw-r--r-- | core/modules/mysqli/mysqli.install | 78 | ||||
-rw-r--r-- | core/modules/mysqli/src/Hook/MysqliHooks.php | 70 | ||||
-rw-r--r-- | core/modules/node/node.module | 9 | ||||
-rw-r--r-- | core/modules/system/tests/src/Functional/System/StatusTest.php | 2 |
7 files changed, 87 insertions, 86 deletions
diff --git a/core/MAINTAINERS.txt b/core/MAINTAINERS.txt index 09256dab56e1..8fe671891f7b 100644 --- a/core/MAINTAINERS.txt +++ b/core/MAINTAINERS.txt @@ -152,7 +152,7 @@ Contact - Andrey Postnikov 'andypost' https://www.drupal.org/u/andypost Content Moderation -- Sam Becker 'Sam152' https://www.drupal.org/u/sam152 +- ? Content Translation - ? @@ -451,7 +451,7 @@ Views - Len Swaneveld 'Lendude' https://www.drupal.org/u/lendude Workflows -- Sam Becker 'Sam152' https://www.drupal.org/u/sam152 +- ? Workspaces - Andrei Mateescu 'amateescu' https://www.drupal.org/u/amateescu diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index 0a28501ae71c..6bb9fb6b1886 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -209,7 +209,13 @@ class Renderer implements RendererInterface { /** * {@inheritdoc} */ - public function render(&$elements, $is_root_call = FALSE) { + public function render(/* array */&$elements, $is_root_call = FALSE) { + + if (!is_array($elements)) { + trigger_error('Calling ' . __METHOD__ . ' with NULL is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Either pass an array or skip the call. See https://www.drupal.org/node/3534020.'); + return ''; + } + $context = $this->getCurrentRenderContext(); if (!isset($context)) { throw new \LogicException("Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead."); diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php index 020e594755fb..081545bd79dd 100644 --- a/core/lib/Drupal/Core/Render/RendererInterface.php +++ b/core/lib/Drupal/Core/Render/RendererInterface.php @@ -340,7 +340,7 @@ interface RendererInterface { * @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments() * @see \Drupal\Core\Render\RendererInterface::renderRoot() */ - public function render(&$elements, $is_root_call = FALSE); + public function render(/* array */&$elements, $is_root_call = FALSE); /** * Checks whether a render context is active. diff --git a/core/modules/mysqli/mysqli.install b/core/modules/mysqli/mysqli.install deleted file mode 100644 index 7f1147d63adb..000000000000 --- a/core/modules/mysqli/mysqli.install +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -/** - * @file - * Install, update and uninstall functions for the mysqli module. - */ - -use Drupal\Core\Database\Database; -use Drupal\Core\Extension\Requirement\RequirementSeverity; -use Drupal\Core\Render\Markup; - -/** - * Implements hook_requirements(). - */ -function mysqli_requirements($phase): array { - $requirements = []; - - if ($phase === 'runtime') { - // Test with MySql databases. - if (Database::isActiveConnection()) { - $connection = Database::getConnection(); - // Only show requirements when MySQLi is the default database connection. - if (!($connection->driver() === 'mysqli' && $connection->getProvider() === 'mysqli')) { - return []; - } - - $query = $connection->isMariaDb() ? 'SELECT @@SESSION.tx_isolation' : 'SELECT @@SESSION.transaction_isolation'; - - $isolation_level = $connection->query($query)->fetchField(); - - $tables_missing_primary_key = []; - $tables = $connection->schema()->findTables('%'); - foreach ($tables as $table) { - $primary_key_column = Database::getConnection()->query("SHOW KEYS FROM {" . $table . "} WHERE Key_name = 'PRIMARY'")->fetchAllAssoc('Column_name'); - if (empty($primary_key_column)) { - $tables_missing_primary_key[] = $table; - } - } - - $description = []; - if ($isolation_level == 'READ-COMMITTED') { - if (empty($tables_missing_primary_key)) { - $severity_level = RequirementSeverity::OK; - } - else { - $severity_level = RequirementSeverity::Error; - } - } - else { - if ($isolation_level == 'REPEATABLE-READ') { - $severity_level = RequirementSeverity::Warning; - } - else { - $severity_level = RequirementSeverity::Error; - $description[] = t('This is not supported by Drupal.'); - } - $description[] = t('The recommended level for Drupal is "READ COMMITTED".'); - } - - if (!empty($tables_missing_primary_key)) { - $description[] = t('For this to work correctly, all tables must have a primary key. The following table(s) do not have a primary key: @tables.', ['@tables' => implode(', ', $tables_missing_primary_key)]); - } - - $description[] = t('See the <a href=":performance_doc">setting MySQL transaction isolation level</a> page for more information.', [ - ':performance_doc' => 'https://www.drupal.org/docs/system-requirements/setting-the-mysql-transaction-isolation-level', - ]); - - $requirements['mysql_transaction_level'] = [ - 'title' => t('Transaction isolation level'), - 'severity' => $severity_level, - 'value' => $isolation_level, - 'description' => Markup::create(implode(' ', $description)), - ]; - } - } - - return $requirements; -} diff --git a/core/modules/mysqli/src/Hook/MysqliHooks.php b/core/modules/mysqli/src/Hook/MysqliHooks.php index 5fae187d16c7..340b17373a12 100644 --- a/core/modules/mysqli/src/Hook/MysqliHooks.php +++ b/core/modules/mysqli/src/Hook/MysqliHooks.php @@ -2,7 +2,10 @@ namespace Drupal\mysqli\Hook; +use Drupal\Core\Database\Database; +use Drupal\Core\Extension\Requirement\RequirementSeverity; use Drupal\Core\Hook\Attribute\Hook; +use Drupal\Core\Render\Markup; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -29,4 +32,71 @@ class MysqliHooks { return NULL; } + /** + * Implements hook_runtime_requirements(). + */ + #[Hook('runtime_requirements')] + public function runtimeRequirements(): array { + $requirements = []; + + // Test with MySql databases. + if (Database::isActiveConnection()) { + $connection = Database::getConnection(); + // Only show requirements when MySQLi is the default database connection. + if (!($connection->driver() === 'mysqli' && $connection->getProvider() === 'mysqli')) { + return []; + } + + $query = $connection->isMariaDb() ? 'SELECT @@SESSION.tx_isolation' : 'SELECT @@SESSION.transaction_isolation'; + + $isolation_level = $connection->query($query)->fetchField(); + + $tables_missing_primary_key = []; + $tables = $connection->schema()->findTables('%'); + foreach ($tables as $table) { + $primary_key_column = Database::getConnection()->query("SHOW KEYS FROM {" . $table . "} WHERE Key_name = 'PRIMARY'")->fetchAllAssoc('Column_name'); + if (empty($primary_key_column)) { + $tables_missing_primary_key[] = $table; + } + } + + $description = []; + if ($isolation_level == 'READ-COMMITTED') { + if (empty($tables_missing_primary_key)) { + $severity_level = RequirementSeverity::OK; + } + else { + $severity_level = RequirementSeverity::Error; + } + } + else { + if ($isolation_level == 'REPEATABLE-READ') { + $severity_level = RequirementSeverity::Warning; + } + else { + $severity_level = RequirementSeverity::Error; + $description[] = $this->t('This is not supported by Drupal.'); + } + $description[] = $this->t('The recommended level for Drupal is "READ COMMITTED".'); + } + + if (!empty($tables_missing_primary_key)) { + $description[] = $this->t('For this to work correctly, all tables must have a primary key. The following table(s) do not have a primary key: @tables.', ['@tables' => implode(', ', $tables_missing_primary_key)]); + } + + $description[] = $this->t('See the <a href=":performance_doc">setting MySQL transaction isolation level</a> page for more information.', [ + ':performance_doc' => 'https://www.drupal.org/docs/system-requirements/setting-the-mysql-transaction-isolation-level', + ]); + + $requirements['mysql_transaction_level'] = [ + 'title' => $this->t('Transaction isolation level'), + 'severity' => $severity_level, + 'value' => $isolation_level, + 'description' => Markup::create(implode(' ', $description)), + ]; + } + + return $requirements; + } + } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d68a04fcbc8a..6841f24b96b1 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -333,10 +333,11 @@ function template_preprocess_node(&$variables): void { // $variables['content'] is more flexible and consistent. $submitted_configurable = $node->getFieldDefinition('created')->isDisplayConfigurable('view') || $node->getFieldDefinition('uid')->isDisplayConfigurable('view'); if (!$skip_custom_preprocessing || !$submitted_configurable) { - $variables['date'] = \Drupal::service('renderer')->render($variables['elements']['created']); - unset($variables['elements']['created']); - $variables['author_name'] = \Drupal::service('renderer')->render($variables['elements']['uid']); - unset($variables['elements']['uid']); + /** @var \Drupal\Core\Render\RendererInterface $renderer */ + $renderer = \Drupal::service('renderer'); + $variables['date'] = !empty($variables['elements']['created']) ? $renderer->render($variables['elements']['created']) : ''; + $variables['author_name'] = !empty($variables['elements']['uid']) ? $renderer->render($variables['elements']['uid']) : ''; + unset($variables['elements']['created'], $variables['elements']['uid']); } if (isset($variables['elements']['title']) && (!$skip_custom_preprocessing || !$node->getFieldDefinition('title')->isDisplayConfigurable('view'))) { diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php index 972ac14fb2cb..b5e32759a73a 100644 --- a/core/modules/system/tests/src/Functional/System/StatusTest.php +++ b/core/modules/system/tests/src/Functional/System/StatusTest.php @@ -97,6 +97,8 @@ class StatusTest extends BrowserTestBase { $this->drupalGet('admin/reports/status/php'); $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->pageTextContains('PHP'); + $this->assertSession()->pageTextNotContains('$_COOKIE'); $settings['settings']['sa_core_2023_004_phpinfo_flags'] = (object) [ 'value' => INFO_ALL, |