diff options
Diffstat (limited to 'core/includes')
-rw-r--r-- | core/includes/common.inc | 12 | ||||
-rw-r--r-- | core/includes/errors.inc | 2 | ||||
-rw-r--r-- | core/includes/install.core.inc | 37 | ||||
-rw-r--r-- | core/includes/install.inc | 55 | ||||
-rw-r--r-- | core/includes/theme.inc | 731 | ||||
-rw-r--r-- | core/includes/theme.maintenance.inc | 6 | ||||
-rw-r--r-- | core/includes/update.inc | 3 |
7 files changed, 187 insertions, 659 deletions
diff --git a/core/includes/common.inc b/core/includes/common.inc index caf7d72f4d14..9c60a811ce30 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -10,6 +10,7 @@ use Drupal\Component\Utility\SortArray; use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheTagsPurgeInterface; use Drupal\Core\DrupalKernel; /** @@ -418,6 +419,13 @@ function drupal_flush_all_caches($kernel = NULL): void { $module_handler = \Drupal::moduleHandler(); // Flush all persistent caches. $module_handler->invokeAll('cache_flush'); + // Purge cache tags immediately before flushing cache bins. If a cache tag is + // invalidated between the tags being purged and cache bins are flushed, then + // it will be included in the checksum of any new cache items, but still valid + // because the tag was written before the creation of cache item. + if (($invalidator = \Drupal::service('cache_tags.invalidator')) && ($invalidator instanceof CacheTagsPurgeInterface)) { + $invalidator->purge(); + } foreach (Cache::getBins() as $cache_backend) { $cache_backend->deleteAll(); } @@ -488,7 +496,7 @@ function drupal_flush_all_caches($kernel = NULL): void { * @see hook_updater_info_alter() */ function drupal_get_updaters() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); $updaters = &drupal_static(__FUNCTION__); if (!isset($updaters)) { @@ -510,7 +518,7 @@ function drupal_get_updaters() { * @see hook_filetransfer_info_alter() */ function drupal_get_filetransfer_info() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED); $info = &drupal_static(__FUNCTION__); if (!isset($info)) { diff --git a/core/includes/errors.inc b/core/includes/errors.inc index d82ed9bdd165..2fd625802cf9 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -262,7 +262,7 @@ function _drupal_log_error($error, $fatal = FALSE): void { // We fallback to a maintenance page at this point, because the page // generation itself can generate errors. // Should not translate the string to avoid errors producing more errors. - $message = 'The website encountered an unexpected error. Try again later.' . '<br />' . $message; + $message = 'The website encountered an unexpected error. Try again later.<br />' . $message; if ($is_installer) { // install_display_output() prints the output and ends script execution. diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 7d1b4da8a986..35fa223c31de 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -17,6 +17,7 @@ use Drupal\Core\DrupalKernel; use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Extension\Exception\UnknownExtensionException; +use Drupal\Core\Extension\Requirement\RequirementSeverity; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormState; use Drupal\Core\Installer\Exception\AlreadyInstalledException; @@ -388,7 +389,7 @@ function install_begin_request($class_loader, &$install_state): void { } $install_state['database_verified'] = install_verify_database_settings($site_path); // A valid settings.php has database settings and a hash_salt value. Other - // settings will be checked by system_requirements(). + // settings will be checked by \Drupal\system\Install\SystemRequirements. $install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified'] && (bool) Settings::get('hash_salt', FALSE); if ($install_state['settings_verified']) { @@ -2018,7 +2019,7 @@ function install_check_translations($langcode, $server_pattern): array { $requirements['translations directory exists'] = [ 'title' => t('Translations directory'), 'value' => t('The translations directory does not exist.'), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', ['%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt']), ]; } @@ -2032,7 +2033,7 @@ function install_check_translations($langcode, $server_pattern): array { $requirements['translations directory readable'] = [ 'title' => t('Translations directory'), 'value' => t('The translations directory is not readable.'), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The installer requires read permissions to %translations_directory at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']), ]; } @@ -2041,7 +2042,7 @@ function install_check_translations($langcode, $server_pattern): array { $requirements['translations directory writable'] = [ 'title' => t('Translations directory'), 'value' => t('The translations directory is not writable.'), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The installer requires write permissions to %translations_directory during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']), ]; } @@ -2058,7 +2059,7 @@ function install_check_translations($langcode, $server_pattern): array { $requirements['online'] = [ 'title' => t('Internet'), 'value' => t('The translation server is offline.'), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href=":server_url">@server_url</a>.', [':server_url' => $server_url, '@server_url' => $server_url]), ]; } @@ -2073,7 +2074,7 @@ function install_check_translations($langcode, $server_pattern): array { $requirements['translation available'] = [ 'title' => t('Translation'), 'value' => t('The %language translation is not available.', ['%language' => $language]), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The %language translation file is not available at the translation server. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]), ]; } @@ -2092,7 +2093,7 @@ function install_check_translations($langcode, $server_pattern): array { $requirements['translation downloaded'] = [ 'title' => t('Translation'), 'value' => t('The %language translation could not be downloaded.', ['%language' => $language]), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The %language translation file could not be downloaded. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]), ]; } @@ -2152,7 +2153,7 @@ function install_check_requirements($install_state) { $requirements["default $file file exists"] = [ 'title' => $default_file_info['title_default'], 'value' => $default_file_info['description_default'], - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The @drupal installer requires that the %default-file file must not be deleted or modified from the original download.', [ '@drupal' => drupal_install_profile_distribution_name(), '%default-file' => $default_file, @@ -2211,7 +2212,7 @@ function install_check_requirements($install_state) { $requirements["$file file exists"] = [ 'title' => $default_file_info['title'], 'value' => t('The %file does not exist.', ['%file' => $default_file_info['title']]), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, @@ -2230,7 +2231,7 @@ function install_check_requirements($install_state) { $requirements["$file file readable"] = [ 'title' => $default_file_info['title'], 'value' => t('The %file is not readable.', ['%file' => $default_file_info['title']]), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('@drupal requires read permissions to %file at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, @@ -2243,7 +2244,7 @@ function install_check_requirements($install_state) { $requirements["$file file writable"] = [ 'title' => $default_file_info['title'], 'value' => t('The %file is not writable.', ['%file' => $default_file_info['title']]), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The @drupal installer requires write permissions to %file during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, @@ -2261,7 +2262,7 @@ function install_check_requirements($install_state) { $requirements["$file file ownership"] = [ 'title' => $default_file_info['title'], 'value' => t('The @file is owned by the web server.', ['@file' => $default_file_info['title']]), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, @@ -2287,7 +2288,7 @@ function install_check_requirements($install_state) { $requirements['database_install_errors'] = [ 'title' => t('Database settings'), 'description' => $error_message, - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, ]; } } @@ -2315,18 +2316,18 @@ function install_check_requirements($install_state) { */ function install_display_requirements($install_state, $requirements) { // Check the severity of the requirements reported. - $severity = drupal_requirements_severity($requirements); + $severity = RequirementSeverity::maxSeverityFromRequirements($requirements); // If there are errors, always display them. If there are only warnings, skip // them if the user has provided a URL parameter acknowledging the warnings // and indicating a desire to continue anyway. See drupal_requirements_url(). - if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) { + if ($severity === RequirementSeverity::Error || ($severity === RequirementSeverity::Warning && empty($install_state['parameters']['continue']))) { if ($install_state['interactive']) { $build['report']['#type'] = 'status_report'; $build['report']['#requirements'] = $requirements; - if ($severity == REQUIREMENT_WARNING) { + if ($severity == RequirementSeverity::Warning) { $build['#title'] = t('Requirements review'); - $build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', [':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)]); + $build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', [':retry' => drupal_requirements_url(RequirementSeverity::Error), ':cont' => drupal_requirements_url($severity)]); } else { $build['#title'] = t('Requirements problem'); @@ -2341,7 +2342,7 @@ function install_display_requirements($install_state, $requirements) { // Skip warnings altogether for non-interactive installations; these // proceed in a single request so there is no good opportunity (and no // good method) to warn the user anyway. - if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { + if (isset($requirement['severity']) && $requirement['severity'] === RequirementSeverity::Error) { $render_array = [ '#type' => 'inline_template', '#template' => '{{ title }}:{{ value }}<br /><br />{{ description }}', diff --git a/core/includes/install.inc b/core/includes/install.inc index d1e7e8656661..dc181b043815 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -12,26 +12,47 @@ use Drupal\Core\Extension\Dependency; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Extension\InstallRequirementsInterface; +use Drupal\Core\Extension\Requirement\RequirementSeverity; use Drupal\Core\Installer\InstallerKernel; use Symfony\Component\HttpFoundation\RedirectResponse; /** * Requirement severity -- Informational message only. + * + * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use + * \Drupal\Core\Extension\Requirement\RequirementSeverity::Info instead. + * + * @see https://www.drupal.org/node/3410939 */ const REQUIREMENT_INFO = -1; /** * 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; @@ -190,7 +211,7 @@ function drupal_verify_profile($install_state): array { $requirements['required_modules'] = [ 'title' => t('Required modules'), 'value' => t('Required modules not found.'), - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', ['@modules' => $modules_list]), ]; } @@ -560,7 +581,7 @@ function drupal_current_script_url($query = []) { * update.php) and returns a URL that can be used to attempt to proceed to the * next step of the script. * - * @param int $severity + * @param int|\Drupal\Core\Extension\Requirement\RequirementSeverity $severity * The severity of the requirements problem, as returned by * drupal_requirements_severity(). * @@ -573,11 +594,18 @@ function drupal_current_script_url($query = []) { * @see drupal_current_script_url() * @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol() */ -function drupal_requirements_url($severity) { +function drupal_requirements_url(/* int|RequirementSeverity */ $severity): string { + if (!$severity instanceof RequirementSeverity) { + @trigger_error('Passing a type other than ' . RequirementSeverity::class . ' to ' . __FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Pass a ' . RequirementSeverity::class . ' enum instead. See https://www.drupal.org/node/3410939', E_USER_DEPRECATED); + $severity = RequirementSeverity::from($severity); + } + if (is_null($severity)) { + $severity = RequirementSeverity::Info; + } $query = []; // If there are no errors, only warnings, append 'continue=1' to the URL so // the user can bypass this screen on the next page load. - if ($severity == REQUIREMENT_WARNING) { + if ($severity === RequirementSeverity::Warning) { $query['continue'] = 1; } return drupal_current_script_url($query); @@ -644,15 +672,16 @@ function drupal_check_profile($profile): array { * * @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 */ function drupal_requirements_severity(&$requirements) { - $severity = REQUIREMENT_OK; - foreach ($requirements as $requirement) { - if (isset($requirement['severity'])) { - $severity = max($severity, $requirement['severity']); - } - } - return $severity; + @trigger_error(__FUNCTION__ . '() 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; } /** @@ -676,10 +705,10 @@ function drupal_check_module($module) { $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', ['install']) ?? []; $requirements = array_merge($requirements, install_check_class_requirements($extension)); - if (!empty($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) { + if (!empty($requirements) && RequirementSeverity::maxSeverityFromRequirements($requirements) === RequirementSeverity::Error) { // Print any error messages foreach ($requirements as $requirement) { - if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { + if (isset($requirement['severity']) && $requirement['severity'] === RequirementSeverity::Error) { $message = $requirement['description']; if (isset($requirement['value']) && $requirement['value']) { $message = t('@requirements_message (Currently using @item version @version)', ['@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']]); diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 9e271ceaf8f0..587f9e70c200 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -9,18 +9,17 @@ */ use Drupal\Core\Datetime\DatePreprocess; +use Drupal\Core\Field\FieldPreprocess; +use Drupal\Core\Pager\PagerPreprocess; +use Drupal\Core\Breadcrumb\BreadcrumbPreprocess; +use Drupal\Core\Menu\MenuPreprocess; +use Drupal\Core\Theme\ImagePreprocess; use Drupal\Core\Theme\ThemePreprocess; -use Drupal\Core\Url; -use Drupal\Component\Utility\Html; use Drupal\Core\Config\Config; use Drupal\Core\Config\StorageException; -use Drupal\Core\Template\Attribute; use Drupal\Core\Template\AttributeHelper; use Drupal\Core\Theme\ThemeCommonElements; use Drupal\Core\Theme\ThemeSettings; -use Drupal\Core\Render\Element; -use Drupal\Core\Utility\TableSort; -use Drupal\Core\Installer\InstallerKernel; /** * @defgroup content_flags Content markers @@ -483,49 +482,15 @@ function template_preprocess_links(&$variables): void { * - sizes: The sizes attribute for viewport-based selection of images. * phpcs:ignore * - http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content.html#introduction-3:viewport-based-selection-2 + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_image(&$variables): void { - /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */ - $file_url_generator = \Drupal::service('file_url_generator'); - - if (!empty($variables['uri'])) { - $variables['attributes']['src'] = $file_url_generator->generateString($variables['uri']); - } - // Generate a srcset attribute conforming to the spec at - // https://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-srcset - if (!empty($variables['srcset'])) { - $srcset = []; - foreach ($variables['srcset'] as $src) { - // URI is mandatory. - $source = $file_url_generator->generateString($src['uri']); - if (isset($src['width']) && !empty($src['width'])) { - $source .= ' ' . $src['width']; - } - elseif (isset($src['multiplier']) && !empty($src['multiplier'])) { - $source .= ' ' . $src['multiplier']; - } - $srcset[] = $source; - } - $variables['attributes']['srcset'] = implode(', ', $srcset); - } - - foreach (['width', 'height', 'alt', 'title', 'sizes'] as $key) { - if (isset($variables[$key])) { - // If the property has already been defined in the attributes, - // do not override, including NULL. - if (AttributeHelper::attributeExists($key, $variables['attributes'])) { - continue; - } - $variables['attributes'][$key] = $variables[$key]; - } - } - - // Without dimensions specified, layout shifts can occur, - // which are more noticeable on pages that take some time to load. - // As a result, only mark images as lazy load that have dimensions. - if (isset($variables['width'], $variables['height']) && !isset($variables['attributes']['loading'])) { - $variables['attributes']['loading'] = 'lazy'; - } + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ImagePreprocess::class)->preprocessImage($variables); } /** @@ -619,167 +584,15 @@ function template_preprocess_image(&$variables): void { * - sticky: Use a "sticky" table header. * - empty: The message to display in an extra row if table does not have any * rows. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_table(&$variables): void { - // Format the table columns: - if (!empty($variables['colgroups'])) { - foreach ($variables['colgroups'] as &$colgroup) { - // Check if we're dealing with a simple or complex column - if (isset($colgroup['data'])) { - $cols = $colgroup['data']; - unset($colgroup['data']); - $colgroup_attributes = $colgroup; - } - else { - $cols = $colgroup; - $colgroup_attributes = []; - } - $colgroup = []; - $colgroup['attributes'] = new Attribute($colgroup_attributes); - $colgroup['cols'] = []; - - // Build columns. - if (is_array($cols) && !empty($cols)) { - foreach ($cols as $col_key => $col) { - $colgroup['cols'][$col_key]['attributes'] = new Attribute($col); - } - } - } - } - - // Build an associative array of responsive classes keyed by column. - $responsive_classes = []; - - // Format the table header: - $ts = []; - $header_columns = 0; - if (!empty($variables['header'])) { - $ts = TableSort::getContextFromRequest($variables['header'], \Drupal::request()); - - // Use a separate index with responsive classes as headers - // may be associative. - $responsive_index = -1; - foreach ($variables['header'] as $col_key => $cell) { - // Increase the responsive index. - $responsive_index++; - - if (!is_array($cell)) { - $header_columns++; - $cell_content = $cell; - $cell_attributes = new Attribute(); - $is_header = TRUE; - } - else { - if (isset($cell['colspan'])) { - $header_columns += $cell['colspan']; - } - else { - $header_columns++; - } - $cell_content = ''; - if (isset($cell['data'])) { - $cell_content = $cell['data']; - unset($cell['data']); - } - // Flag the cell as a header or not and remove the flag. - $is_header = $cell['header'] ?? TRUE; - unset($cell['header']); - - // Track responsive classes for each column as needed. Only the header - // cells for a column are marked up with the responsive classes by a - // module developer or themer. The responsive classes on the header - // cells must be transferred to the content cells. - if (!empty($cell['class']) && is_array($cell['class'])) { - if (in_array(RESPONSIVE_PRIORITY_MEDIUM, $cell['class'])) { - $responsive_classes[$responsive_index] = RESPONSIVE_PRIORITY_MEDIUM; - } - elseif (in_array(RESPONSIVE_PRIORITY_LOW, $cell['class'])) { - $responsive_classes[$responsive_index] = RESPONSIVE_PRIORITY_LOW; - } - } - - TableSort::header($cell_content, $cell, $variables['header'], $ts); - - // TableSort::header() removes the 'sort', 'initial_click_sort' and - // 'field' keys. - $cell_attributes = new Attribute($cell); - } - $variables['header'][$col_key] = []; - $variables['header'][$col_key]['tag'] = $is_header ? 'th' : 'td'; - $variables['header'][$col_key]['attributes'] = $cell_attributes; - $variables['header'][$col_key]['content'] = $cell_content; - } - } - $variables['header_columns'] = $header_columns; - - // Rows and footer have the same structure. - $sections = ['rows' , 'footer']; - foreach ($sections as $section) { - if (!empty($variables[$section])) { - foreach ($variables[$section] as $row_key => $row) { - $cells = $row; - $row_attributes = []; - - // Check if we're dealing with a simple or complex row - if (isset($row['data'])) { - $cells = $row['data']; - $variables['no_striping'] = $row['no_striping'] ?? FALSE; - - // Set the attributes array and exclude 'data' and 'no_striping'. - $row_attributes = $row; - unset($row_attributes['data']); - unset($row_attributes['no_striping']); - } - - // Build row. - $variables[$section][$row_key] = []; - $variables[$section][$row_key]['attributes'] = new Attribute($row_attributes); - $variables[$section][$row_key]['cells'] = []; - if (!empty($cells)) { - // Reset the responsive index. - $responsive_index = -1; - foreach ($cells as $col_key => $cell) { - // Increase the responsive index. - $responsive_index++; - - if (!is_array($cell)) { - $cell_content = $cell; - $cell_attributes = []; - $is_header = FALSE; - } - else { - $cell_content = ''; - if (isset($cell['data'])) { - $cell_content = $cell['data']; - unset($cell['data']); - } - - // Flag the cell as a header or not and remove the flag. - $is_header = !empty($cell['header']); - unset($cell['header']); - - $cell_attributes = $cell; - } - // Active table sort information. - if (isset($variables['header'][$col_key]['data']) && $variables['header'][$col_key]['data'] == $ts['name'] && !empty($variables['header'][$col_key]['field'])) { - $variables[$section][$row_key]['cells'][$col_key]['active_table_sort'] = TRUE; - } - // Copy RESPONSIVE_PRIORITY_LOW/RESPONSIVE_PRIORITY_MEDIUM - // class from header to cell as needed. - if (isset($responsive_classes[$responsive_index])) { - $cell_attributes['class'][] = $responsive_classes[$responsive_index]; - } - $variables[$section][$row_key]['cells'][$col_key]['tag'] = $is_header ? 'th' : 'td'; - $variables[$section][$row_key]['cells'][$col_key]['attributes'] = new Attribute($cell_attributes); - $variables[$section][$row_key]['cells'][$col_key]['content'] = $cell_content; - } - } - } - } - } - if (empty($variables['no_striping'])) { - $variables['attributes']['data-striping'] = 1; - } + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ThemePreprocess::class)->preprocessTable($variables); } /** @@ -799,55 +612,14 @@ function template_preprocess_table(&$variables): void { * - list_type: The type of list to return (e.g. "ul", "ol"). * - wrapper_attributes: HTML attributes to be applied to the list wrapper. * - * @see https://www.drupal.org/node/1842756 + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_item_list(&$variables): void { - $variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']); - foreach ($variables['items'] as &$item) { - $attributes = []; - // If the item value is an array, then it is a render array. - if (is_array($item)) { - // List items support attributes via the '#wrapper_attributes' property. - if (isset($item['#wrapper_attributes'])) { - $attributes = $item['#wrapper_attributes']; - } - // Determine whether there are any child elements in the item that are not - // fully-specified render arrays. If there are any, then the child - // elements present nested lists and we automatically inherit the render - // array properties of the current list to them. - foreach (Element::children($item) as $key) { - $child = &$item[$key]; - // If this child element does not specify how it can be rendered, then - // we need to inherit the render properties of the current list. - if (!isset($child['#type']) && !isset($child['#theme']) && !isset($child['#markup'])) { - // Since item-list.html.twig supports both strings and render arrays - // as items, the items of the nested list may have been specified as - // the child elements of the nested list, instead of #items. For - // convenience, we automatically move them into #items. - if (!isset($child['#items'])) { - // This is the same condition as in - // \Drupal\Core\Render\Element::children(), which cannot be used - // here, since it triggers an error on string values. - foreach ($child as $child_key => $child_value) { - if (is_int($child_key) || $child_key === '' || $child_key[0] !== '#') { - $child['#items'][$child_key] = $child_value; - unset($child[$child_key]); - } - } - } - // Lastly, inherit the original theme variables of the current list. - $child['#theme'] = $variables['theme_hook_original']; - $child['#list_type'] = $variables['list_type']; - } - } - } - - // Set the item's value and attributes for the template. - $item = [ - 'value' => $item, - 'attributes' => new Attribute($attributes), - ]; - } + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ThemePreprocess::class)->preprocessItemList($variables); } /** @@ -881,27 +653,15 @@ function template_preprocess_container(&$variables): void { * It's the caller's responsibility to ensure this array's items contain no * dangerous HTML such as <script> tags. * - active: The key for the currently active maintenance task. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_maintenance_task_list(&$variables): void { - $items = $variables['items']; - $active = $variables['active']; - - $done = isset($items[$active]) || $active == NULL; - foreach ($items as $k => $item) { - $variables['tasks'][$k]['item'] = $item; - $variables['tasks'][$k]['attributes'] = new Attribute(); - if ($active == $k) { - $variables['tasks'][$k]['attributes']->addClass('is-active'); - $variables['tasks'][$k]['status'] = t('active'); - $done = FALSE; - } - else { - if ($done) { - $variables['tasks'][$k]['attributes']->addClass('done'); - $variables['tasks'][$k]['status'] = t('done'); - } - } - } + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ThemePreprocess::class)->preprocessMaintenanceTaskList($variables); } /** @@ -1051,9 +811,15 @@ function theme_get_suggestions($args, $base, $delimiter = '__'): array { * Prepares variables for tablesort indicators. * * Default template: tablesort-indicator.html.twig. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_tablesort_indicator(&$variables): void { - $variables['#attached']['library'][] = 'core/drupal.tablesort'; + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ThemePreprocess::class)->preprocessTablesortIndicator($variables); } /** @@ -1065,25 +831,14 @@ function template_preprocess_tablesort_indicator(&$variables): void { * An associative array containing: * - content - An array of page content. * - * @see system_page_attachments() + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_maintenance_page(&$variables): void { - // @todo Rename the templates to page--maintenance + page--install. - \Drupal::service(ThemePreprocess::class)->preprocessPage($variables); - - // @see system_page_attachments() - $variables['#attached']['library'][] = 'system/maintenance'; - - // Maintenance page and install page need branding info in variables because - // there is no blocks. - $site_config = \Drupal::config('system.site'); - $variables['logo'] = theme_get_setting('logo.url'); - $variables['site_name'] = $site_config->get('name'); - $variables['site_slogan'] = $site_config->get('slogan'); - - // Maintenance page and install page need page title in variable because there - // are no blocks. - $variables['title'] = $variables['page']['#title']; + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ThemePreprocess::class)->preprocessMaintenancePage($variables); } /** @@ -1095,21 +850,14 @@ function template_preprocess_maintenance_page(&$variables): void { * An associative array containing: * - content - An array of page content. * - * @see template_preprocess_maintenance_page() + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_install_page(&$variables): void { - $installer_active_task = NULL; - if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE === 'install' && InstallerKernel::installationAttempted()) { - $installer_active_task = $GLOBALS['install_state']['active_task']; - } - - template_preprocess_maintenance_page($variables); - - // Override the site name that is displayed on the page, since Drupal is - // still in the process of being installed. - $distribution_name = drupal_install_profile_distribution_name(); - $variables['site_name'] = $distribution_name; - $variables['site_version'] = $installer_active_task ? drupal_install_profile_distribution_version() : ''; + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ThemePreprocess::class)->preprocessInstallPage($variables); } /** @@ -1124,11 +872,15 @@ function template_preprocess_install_page(&$variables): void { * @param array $variables * An associative array containing: * - elements: An associative array containing properties of the region. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_region(&$variables): void { - // Create the $content variable that templates expect. - $variables['content'] = $variables['elements']['#children']; - $variables['region'] = $variables['elements']['#region']; + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(ThemePreprocess::class)->preprocessRegion($variables); } /** @@ -1141,55 +893,15 @@ function template_preprocess_region(&$variables): void { * - element: A render element representing the field. * - attributes: A string containing the attributes for the wrapping div. * - title_attributes: A string containing the attributes for the title. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_field(&$variables, $hook): void { - $element = $variables['element']; - - // Creating variables for the template. - $variables['entity_type'] = $element['#entity_type']; - $variables['field_name'] = $element['#field_name']; - $variables['field_type'] = $element['#field_type']; - $variables['label_display'] = $element['#label_display']; - - $variables['label_hidden'] = ($element['#label_display'] == 'hidden'); - // Always set the field label - allow themes to decide whether to display it. - // In addition the label should be rendered but hidden to support screen - // readers. - $variables['label'] = $element['#title']; - - $variables['multiple'] = $element['#is_multiple']; - - static $default_attributes; - if (!isset($default_attributes)) { - $default_attributes = new Attribute(); - } - - // Merge attributes when a single-value field has a hidden label. - if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && !empty($element['#items'][0]->_attributes)) { - $variables['attributes'] = AttributeHelper::mergeCollections($variables['attributes'], (array) $element['#items'][0]->_attributes); - } - - // We want other preprocess functions and the theme implementation to have - // fast access to the field item render arrays. The item render array keys - // (deltas) should always be numerically indexed starting from 0, and looping - // on those keys is faster than calling Element::children() or looping on all - // keys within $element, since that requires traversal of all element - // properties. - $variables['items'] = []; - $delta = 0; - while (!empty($element[$delta])) { - $variables['items'][$delta]['content'] = $element[$delta]; - - // Modules can add field item attributes (to - // $item->_attributes) within hook_entity_prepare_view(). Some field - // formatters move those attributes into some nested formatter-specific - // element in order have them rendered on the desired HTML element (e.g., on - // the <a> element of a field item being rendered as a link). Other field - // formatters leave them within $element['#items'][$delta]['_attributes'] to - // be rendered on the item wrappers provided by field.html.twig. - $variables['items'][$delta]['attributes'] = !empty($element['#items'][$delta]->_attributes) ? new Attribute($element['#items'][$delta]->_attributes) : clone($default_attributes); - $delta++; - } + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(FieldPreprocess::class)->preprocessField($variables); } /** @@ -1202,112 +914,15 @@ function template_preprocess_field(&$variables, $hook): void { * @param array $variables * An associative array containing: * - element: A render element representing the form element. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_field_multiple_value_form(&$variables): void { - $element = $variables['element']; - $variables['multiple'] = $element['#cardinality_multiple']; - $variables['attributes'] = $element['#attributes']; - - if ($variables['multiple']) { - $table_id = Html::getUniqueId($element['#field_name'] . '_values'); - // Using table id allows handing nested content with the same field names. - $order_class = $table_id . '-delta-order'; - $header_attributes = new Attribute(['class' => ['label']]); - if (!empty($element['#required'])) { - $header_attributes['class'][] = 'js-form-required'; - $header_attributes['class'][] = 'form-required'; - } - $header = [ - [ - 'data' => [ - '#type' => 'html_tag', - '#tag' => 'h4', - '#value' => $element['#title'], - '#attributes' => $header_attributes, - ], - 'colspan' => 2, - 'class' => ['field-label'], - ], - [], - t('Order', [], ['context' => 'Sort order']), - ]; - $rows = []; - - // Sort items according to '_weight' (needed when the form comes back after - // preview or failed validation). - $items = []; - $variables['button'] = []; - foreach (Element::children($element) as $key) { - if ($key === 'add_more') { - $variables['button'] = &$element[$key]; - } - else { - $items[] = &$element[$key]; - } - } - usort($items, '_field_multiple_value_form_sort_helper'); - - // Add the items as table rows. - foreach ($items as $item) { - $item['_weight']['#attributes']['class'] = [$order_class]; - - // Remove weight form element from item render array so it can be rendered - // in a separate table column. - $delta_element = $item['_weight']; - unset($item['_weight']); - - // Render actions in a separate column. - $actions = []; - if (isset($item['_actions'])) { - $actions = $item['_actions']; - unset($item['_actions']); - } - - $cells = [ - ['data' => '', 'class' => ['field-multiple-drag']], - ['data' => $item], - ['data' => $actions], - ['data' => $delta_element, 'class' => ['delta-order']], - ]; - $rows[] = [ - 'data' => $cells, - 'class' => ['draggable'], - ]; - } - - $variables['table'] = [ - '#type' => 'table', - '#header' => $header, - '#rows' => $rows, - '#attributes' => [ - 'id' => $table_id, - 'class' => ['field-multiple-table'], - ], - '#tabledrag' => [ - [ - 'action' => 'order', - 'relationship' => 'sibling', - 'group' => $order_class, - ], - ], - ]; - - if (!empty($element['#description'])) { - $description_id = $element['#attributes']['aria-describedby']; - $description_attributes['id'] = $description_id; - $variables['description']['attributes'] = new Attribute($description_attributes); - $variables['description']['content'] = $element['#description']; - - // Add the description's id to the table aria attributes. - $variables['table']['#attributes']['aria-describedby'] = $element['#attributes']['aria-describedby']; - } - } - else { - $variables['elements'] = []; - foreach (Element::children($element) as $key) { - $variables['elements'][] = $element[$key]; - } - } + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(FieldPreprocess::class)->preprocessFieldMultipleValueForm($variables); } /** @@ -1318,13 +933,15 @@ function template_preprocess_field_multiple_value_form(&$variables): void { * @param array $variables * An associative array containing: * - links: A list of \Drupal\Core\Link objects which should be rendered. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_breadcrumb(&$variables): void { - $variables['breadcrumb'] = []; - /** @var \Drupal\Core\Link $link */ - foreach ($variables['links'] as $key => $link) { - $variables['breadcrumb'][$key] = ['text' => $link->getText(), 'url' => $link->getUrl()->toString()]; - } + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(BreadcrumbPreprocess::class)->preprocessBreadcrumb($variables); } /** @@ -1347,137 +964,15 @@ function template_preprocess_breadcrumb(&$variables): void { * to the pager links. * - #route_parameters: An associative array of the route parameters. * - #quantity: The number of pages in the list. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_pager(&$variables): void { - $element = $variables['pager']['#element']; - $parameters = $variables['pager']['#parameters']; - $quantity = empty($variables['pager']['#quantity']) ? 0 : $variables['pager']['#quantity']; - $route_name = $variables['pager']['#route_name']; - $route_parameters = $variables['pager']['#route_parameters'] ?? []; - - /** @var \Drupal\Core\Pager\PagerManagerInterface $pager_manager */ - $pager_manager = \Drupal::service('pager.manager'); - - $pager = $pager_manager->getPager($element); - - // Nothing to do if there is no pager. - if (!isset($pager)) { - return; - } - - $pager_max = $pager->getTotalPages(); - - // Nothing to do if there is only one page. - if ($pager_max <= 1) { - return; - } - - $tags = $variables['pager']['#tags']; - - // Calculate various markers within this pager piece: - // Middle is used to "center" pages around the current page. - $pager_middle = ceil($quantity / 2); - $current_page = $pager->getCurrentPage(); - // The current pager is the page we are currently paged to. - $pager_current = $current_page + 1; - // The first pager is the first page listed by this pager piece (re quantity). - $pager_first = $pager_current - $pager_middle + 1; - // The last is the last page listed by this pager piece (re quantity). - $pager_last = $pager_current + $quantity - $pager_middle; - // End of marker calculations. - - // Prepare for generation loop. - $i = $pager_first; - if ($pager_last > $pager_max) { - // Adjust "center" if at end of query. - $i = $i + ($pager_max - $pager_last); - $pager_last = $pager_max; - } - if ($i <= 0) { - // Adjust "center" if at start of query. - $pager_last = $pager_last + (1 - $i); - $i = 1; - } - // End of generation loop preparation. - - // Create the "first" and "previous" links if we are not on the first page. - if ($current_page > 0) { - $items['first'] = []; - $items['first']['attributes'] = new Attribute(); - $options = [ - 'query' => $pager_manager->getUpdatedParameters($parameters, $element, 0), - ]; - $items['first']['href'] = Url::fromRoute($route_name, $route_parameters, $options)->toString(); - if (isset($tags[0])) { - $items['first']['text'] = $tags[0]; - } - - $items['previous'] = []; - $items['previous']['attributes'] = new Attribute(); - $options = [ - 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $current_page - 1), - ]; - $items['previous']['href'] = Url::fromRoute($route_name, $route_parameters, $options)->toString(); - if (isset($tags[1])) { - $items['previous']['text'] = $tags[1]; - } - } - - // Add an ellipsis if there are further previous pages. - if ($i > 1) { - $variables['ellipses']['previous'] = TRUE; - } - // Now generate the actual pager piece. - for (; $i <= $pager_last && $i <= $pager_max; $i++) { - $options = [ - 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $i - 1), - ]; - $items['pages'][$i]['href'] = Url::fromRoute($route_name, $route_parameters, $options)->toString(); - $items['pages'][$i]['attributes'] = new Attribute(); - if ($i == $pager_current) { - $variables['current'] = $i; - $items['pages'][$i]['attributes']->setAttribute('aria-current', 'page'); - } - } - // Add an ellipsis if there are further next pages. - if ($i < $pager_max + 1) { - $variables['ellipses']['next'] = TRUE; - } - - // Create the "next" and "last" links if we are not on the last page. - if ($current_page < ($pager_max - 1)) { - $items['next'] = []; - $items['next']['attributes'] = new Attribute(); - $options = [ - 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $current_page + 1), - ]; - $items['next']['href'] = Url::fromRoute($route_name, $route_parameters, $options)->toString(); - if (isset($tags[3])) { - $items['next']['text'] = $tags[3]; - } - - $items['last'] = []; - $items['last']['attributes'] = new Attribute(); - $options = [ - 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $pager_max - 1), - ]; - $items['last']['href'] = Url::fromRoute($route_name, $route_parameters, $options)->toString(); - if (isset($tags[4])) { - $items['last']['text'] = $tags[4]; - } - } - - $variables['items'] = $items; - $variables['heading_id'] = Html::getUniqueId('pagination-heading'); - $variables['pagination_heading_level'] = $variables['pager']['#pagination_heading_level'] ?? 'h4'; - if (!preg_match('/^h[1-6]$/', $variables['pagination_heading_level'])) { - $variables['pagination_heading_level'] = 'h4'; - } - - // The rendered link needs to play well with any other query parameter used - // on the page, like exposed filters, so for the cacheability all query - // parameters matter. - $variables['#cache']['contexts'][] = 'url.query_args'; + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(PagerPreprocess::class)->preprocessPager($variables); } /** @@ -1491,26 +986,15 @@ function template_preprocess_pager(&$variables): void { * - #link: A menu link array with 'title', 'url', and (optionally) * 'localized_options' keys. * - #active: A boolean indicating whether the local task is active. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_menu_local_task(&$variables): void { - $link = $variables['element']['#link']; - $link += [ - 'localized_options' => [], - ]; - $link_text = $link['title']; - - if (!empty($variables['element']['#active'])) { - $variables['is_active'] = TRUE; - } - - $link['localized_options']['set_active_class'] = TRUE; - - $variables['link'] = [ - '#type' => 'link', - '#title' => $link_text, - '#url' => $link['url'], - '#options' => $link['localized_options'], - ]; + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(MenuPreprocess::class)->preprocessMenuLocalTask($variables); } /** @@ -1523,30 +1007,29 @@ function template_preprocess_menu_local_task(&$variables): void { * - element: A render element containing: * - #link: A menu link array with 'title', 'url', and (optionally) * 'localized_options' keys. + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial + * template_preprocess functions are registered directly in hook_theme(). + * + * @see https://www.drupal.org/node/3504125 */ function template_preprocess_menu_local_action(&$variables): void { - $link = $variables['element']['#link']; - $link += [ - 'localized_options' => [], - ]; - $link['localized_options']['attributes']['class'][] = 'button'; - $link['localized_options']['attributes']['class'][] = 'button-action'; - $link['localized_options']['set_active_class'] = TRUE; - - $variables['link'] = [ - '#type' => 'link', - '#title' => $link['title'], - '#options' => $link['localized_options'], - '#url' => $link['url'], - ]; + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); + \Drupal::service(MenuPreprocess::class)->preprocessMenuLocalAction($variables); } /** - * Callback for usort() within template_preprocess_field_multiple_value_form(). + * Callback for usort() of field item form elements. * * Sorts using ['_weight']['#value'] + * + * @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no + * replacement. + * + * @see https://www.drupal.org/node/3504125 */ function _field_multiple_value_form_sort_helper($a, $b) { + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED); $a_weight = (is_array($a) && isset($a['_weight']['#value']) ? $a['_weight']['#value'] : 0); $b_weight = (is_array($b) && isset($b['_weight']['#value']) ? $b['_weight']['#value'] : 0); return $a_weight - $b_weight; diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index 2a37fbc9ffdc..4438d058499b 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -108,8 +108,14 @@ function _drupal_maintenance_theme(): void { * @param array $variables * An associative array containing: * - messages: An array of result messages. + * + * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no + * replacement. Use composer to manage the code for your site. + * + * @see https://www.drupal.org/node/3522119 */ function template_preprocess_authorize_report(&$variables): void { + @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3522119', E_USER_DEPRECATED); $messages = []; if (!empty($variables['messages'])) { foreach ($variables['messages'] as $heading => $logs) { diff --git a/core/includes/update.inc b/core/includes/update.inc index b4ccf9f0ad02..67f6fd9c95d6 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -10,6 +10,7 @@ use Drupal\Component\Graph\Graph; use Drupal\Core\Extension\Exception\UnknownExtensionException; +use Drupal\Core\Extension\Requirement\RequirementSeverity; use Drupal\Core\Utility\Error; use Drupal\Core\Update\EquivalentUpdate; @@ -34,7 +35,7 @@ function update_system_schema_requirements(): array { else { $requirements['minimum schema'] += [ 'value' => 'The installed schema version does not meet the minimum.', - 'severity' => REQUIREMENT_ERROR, + 'severity' => RequirementSeverity::Error, 'description' => 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must upgrade your site to Drupal 8 first, see https://www.drupal.org/docs/8/upgrade.', ]; } |