diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 6d7826e123eaf7f701756405739b3f3958983f12..311967e400208c65745759db4e1080e6b1681ada 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -6,7 +6,6 @@ */ use Drupal\Component\Utility\Crypt; -use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Test\TestDatabase; use Drupal\Core\Utility\Error; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -104,51 +103,6 @@ function t($string, array $args = [], array $options = []) { return new TranslatableMarkup($string, $args, $options); } -/** - * Logs an exception. - * - * This is a wrapper logging function which automatically decodes an exception. - * - * @param $type - * The category to which this message belongs. - * @param $exception - * The exception that is going to be logged. - * @param $message - * The message to store in the log. If empty, a text that contains all useful - * information about the passed-in exception is used. - * @param $variables - * Array of variables to replace in the message on display or - * NULL if message is already translated or not possible to - * translate. - * @param $severity - * The severity of the message, as per RFC 3164. - * @param $link - * A link to associate with the message. - * - * @see \Drupal\Core\Utility\Error::decodeException() - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * Use \Drupal\Core\Utility\Error::logException() instead. - * - * @see https://www.drupal.org/node/2932520 - */ -function watchdog_exception($type, Exception $exception, $message = NULL, $variables = [], $severity = RfcLogLevel::ERROR, $link = NULL) { - @trigger_error('watchdog_exception() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Utility\Error::logException() instead. See https://www.drupal.org/node/2932520', E_USER_DEPRECATED); - - // Use a default value if $message is not set. - if (empty($message)) { - $message = Error::DEFAULT_ERROR_MESSAGE; - } - - if ($link) { - $variables['link'] = $link; - } - - $variables += Error::decodeException($exception); - - \Drupal::logger($type)->log($severity, $message, $variables); -} - /** * Provides custom PHP error handling. * diff --git a/core/includes/common.inc b/core/includes/common.inc index cabd3ceeb8f410bf63cda91f2e7746af87cba381..cf9a8b1ad13188dd876cffc5ee945c7334a68034 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -11,7 +11,6 @@ use Drupal\Component\Utility\SortArray; use Drupal\Core\Cache\Cache; use Drupal\Core\DrupalKernel; -use Drupal\Core\StringTranslation\ByteSizeMarkup; /** * @defgroup php_wrappers PHP wrapper functions @@ -114,39 +113,6 @@ */ const JS_THEME = 100; -/** - * @defgroup format Formatting - * @{ - * Functions to format numbers, strings, dates, etc. - */ - -/** - * Generates a string representation for the given byte count. - * - * @param $size - * A size in bytes. - * @param $langcode - * Optional language code to translate to a language other than what is used - * to display the page. - * - * @return \Drupal\Core\StringTranslation\TranslatableMarkup - * A translated string representation of the size. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * \Drupal\Core\StringTranslation\ByteSizeMarkup::create($size, $langcode) - * instead. - * - * @see https://www.drupal.org/node/2999981 - */ -function format_size($size, $langcode = NULL) { - @trigger_error('format_size() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\StringTranslation\ByteSizeMarkup::create($size, $langcode) instead. See https://www.drupal.org/node/2999981', E_USER_DEPRECATED); - return ByteSizeMarkup::create($size ?? 0, $langcode); -} - -/** - * @} End of "defgroup format". - */ - /** * Returns the base URL path (i.e., directory) of the Drupal installation. * @@ -493,22 +459,6 @@ function drupal_flush_all_caches($kernel = NULL) { } } -/** - * Changes the dummy query string added to all CSS and JavaScript files. - * - * Changing the dummy query string appended to CSS and JavaScript files forces - * all browsers to reload fresh files. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * Use \Drupal\Core\Asset\AssetQueryStringInterface::reset() instead. - * - * @see https://www.drupal.org/node/3358337 - */ -function _drupal_flush_css_js() { - @trigger_error('_drupal_flush_css_js is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Asset\AssetQueryStringInterface::reset() instead. See https://www.drupal.org/node/3358337', E_USER_DEPRECATED); - \Drupal::service('asset.query_string')->reset(); -} - /** * Assembles the Drupal Updater registry. * diff --git a/core/includes/install.inc b/core/includes/install.inc index 62aa02ef5af8df571b84a2c5769e8d165761b3c4..8eb0630b7b9cff09ddd6ff345a5c0257d59bf035 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -11,7 +11,6 @@ use Drupal\Core\Extension\Dependency; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Installer\InstallerKernel; -use Drupal\Core\Site\SettingsEditor; use Symfony\Component\HttpFoundation\RedirectResponse; /** @@ -140,200 +139,6 @@ function drupal_install_profile_distribution_version() { } } -/** - * Replaces values in settings.php with values in the submitted array. - * - * This function replaces values in place if possible, even for - * multidimensional arrays. This way the old settings do not linger, - * overridden and also the doxygen on a value remains where it should be. - * - * @param $settings - * An array of settings that need to be updated. Multidimensional arrays - * are dumped up to a stdClass object. The object can have value, required - * and comment properties. - * @code - * $settings['settings']['config_sync_directory'] = (object) array( - * 'value' => 'config_hash/sync', - * 'required' => TRUE, - * ); - * @endcode - * gets dumped as: - * @code - * $settings['config_sync_directory'] = 'config_hash/sync' - * @endcode - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * SettingsEditor::rewrite() instead. Note $settings_file argument becomes - * required and the first argument of the method. - * - * @see https://www.drupal.org/node/3244583 - * @see \Drupal\Core\Site\SettingsEditor::rewrite() - */ -function drupal_rewrite_settings($settings = [], $settings_file = NULL) { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. The order of the arguments has also changed: $settings_file is now required and is the first argument of the method. See https://www.drupal.org/node/3244583', E_USER_DEPRECATED); - SettingsEditor::rewrite( - $settings_file ?? \Drupal::getContainer()->getParameter('site.path') . '/settings.php', - $settings - ); -} - -/** - * Helper for drupal_rewrite_settings(). - * - * Checks whether this token represents a scalar or NULL. - * - * @param int $type - * The token type. - * @param string $value - * The value of the token. - * - * @return bool - * TRUE if this token represents a scalar or NULL. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * SettingsEditor::rewrite() instead. As internal API, - * _drupal_rewrite_settings_is_simple() may also be removed in a minor - * release. - * - * @see https://www.drupal.org/node/3244583 - * @see token_name() - */ -function _drupal_rewrite_settings_is_simple($type, $value) { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. As internal API, ' . __FUNCTION__ . '() may also be removed in a minor release. See https://www.drupal.org/node/3244583', E_USER_DEPRECATED); - $is_integer = $type == T_LNUMBER; - $is_float = $type == T_DNUMBER; - $is_string = $type == T_CONSTANT_ENCAPSED_STRING; - $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), ['TRUE', 'FALSE', 'NULL']); - return $is_integer || $is_float || $is_string || $is_boolean_or_null; -} - -/** - * Helper for drupal_rewrite_settings(). - * - * Checks whether this token represents a valid array index: a number or a - * string. - * - * @param int $type - * The token type. - * - * @return bool - * TRUE if this token represents a number or a string. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * SettingsEditor::rewrite() instead. As internal API, - * _drupal_rewrite_settings_is_array_index() may also be removed in a minor - * release. - * - * @see https://www.drupal.org/node/3244583 - * @see token_name() - */ -function _drupal_rewrite_settings_is_array_index($type) { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. As internal API, ' . __FUNCTION__ . '() may also be removed in a minor release. See https://www.drupal.org/node/3244583', E_USER_DEPRECATED); - $is_integer = $type == T_LNUMBER; - $is_float = $type == T_DNUMBER; - $is_string = $type == T_CONSTANT_ENCAPSED_STRING; - return $is_integer || $is_float || $is_string; -} - -/** - * Helper for drupal_rewrite_settings(). - * - * Makes the new settings global. - * - * @param array|null $ref - * A reference to a nested index in $GLOBALS. - * @param array|object $variable - * The nested value of the setting being copied. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * SettingsEditor::rewrite() instead. As internal API, - * _drupal_rewrite_settings_global() may also be removed in a minor - * release. - * - * @see https://www.drupal.org/node/3244583 - */ -function _drupal_rewrite_settings_global(&$ref, $variable) { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. As internal API, ' . __FUNCTION__ . '() may also be removed in a minor release. See https://www.drupal.org/node/3244583', E_USER_DEPRECATED); - if (is_object($variable)) { - $ref = $variable->value; - } - else { - foreach ($variable as $k => $v) { - _drupal_rewrite_settings_global($ref[$k], $v); - } - } -} - -/** - * Helper for drupal_rewrite_settings(). - * - * Dump the relevant value properties. - * - * @param array|object $variable - * The container for variable values. - * @param string $variable_name - * Name of variable. - * - * @return string - * A string containing valid PHP code of the variable suitable for placing - * into settings.php. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * SettingsEditor::rewrite() instead. As internal API, - * _drupal_rewrite_settings_dump() may also be removed in a minor - * release. - * - * @see https://www.drupal.org/node/3244583 - */ -function _drupal_rewrite_settings_dump($variable, $variable_name) { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. As internal API, ' . __FUNCTION__ . '() may also be removed in a minor release. See https://www.drupal.org/node/3244583', E_USER_DEPRECATED); - $return = ''; - if (is_object($variable)) { - if (!empty($variable->required)) { - $return .= _drupal_rewrite_settings_dump_one($variable, "$variable_name = ", "\n"); - } - } - else { - foreach ($variable as $k => $v) { - $return .= _drupal_rewrite_settings_dump($v, $variable_name . "['" . $k . "']"); - } - } - return $return; -} - -/** - * Helper for drupal_rewrite_settings(). - * - * Dump the value of a value property and adds the comment if it exists. - * - * @param object $variable - * A stdClass object with at least a value property. - * @param string $prefix - * A string to prepend to the variable's value. - * @param string $suffix - * A string to append to the variable's value. - * - * @return string - * A string containing valid PHP code of the variable suitable for placing - * into settings.php. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * SettingsEditor::rewrite() instead. As internal API, - * _drupal_rewrite_settings_dump_one() may also be removed in a minor - * release. - * - * @see https://www.drupal.org/node/3244583 - */ -function _drupal_rewrite_settings_dump_one(\stdClass $variable, $prefix = '', $suffix = '') { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. As internal API, ' . __FUNCTION__ . '() may also be removed in a minor release. See https://www.drupal.org/node/3244583', E_USER_DEPRECATED); - $return = $prefix . var_export($variable->value, TRUE) . ';'; - if (!empty($variable->comment)) { - $return .= ' // ' . $variable->comment; - } - $return .= $suffix; - return $return; -} - /** * Verifies that all dependencies are met for a given installation profile. * diff --git a/core/includes/module.inc b/core/includes/module.inc index 02a4f5d41f3e65098e07f17bbf859db9f10f51ea..0bf495c2e257cb862649315ea2fac51c4fe9b5ba 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -5,58 +5,6 @@ * API for loading and interacting with Drupal modules. */ -/** - * Loads a module include file. - * - * Examples: - * @code - * // Load node.admin.inc from the node module. - * module_load_include('inc', 'node', 'node.admin'); - * // Load content_types.inc from the node module. - * module_load_include('inc', 'node', 'content_types'); - * @endcode - * - * Do not use this function to load an install file, use module_load_install() - * instead. Do not use this function in a global context since it requires - * Drupal to be fully bootstrapped, use require_once DRUPAL_ROOT . '/path/file' - * instead. - * - * @param $type - * The include file's type (file extension). - * @param $module - * The module to which the include file belongs. - * @param $name - * (optional) The base file name (without the $type extension). If omitted, - * $module is used; i.e., resulting in "$module.$type" by default. - * - * @return bool|string - * The name of the included file, if successful; FALSE otherwise. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. - * Use \Drupal::moduleHandler()->loadInclude($module, $type, $name = NULL). - * Note that including code from uninstalled extensions is no longer - * supported. - * - * @see https://www.drupal.org/node/2948698 - */ -function module_load_include($type, $module, $name = NULL) { - @trigger_error("module_load_include() is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. Instead, you should use \Drupal::moduleHandler()->loadInclude(). Note that including code from uninstalled extensions is no longer supported. See https://www.drupal.org/node/2948698", E_USER_DEPRECATED); - if (!isset($name)) { - $name = $module; - } - - if (\Drupal::hasService('extension.list.module')) { - /** @var \Drupal\Core\Extension\ModuleExtensionList $module_list */ - $module_list = \Drupal::service('extension.list.module'); - $file = DRUPAL_ROOT . '/' . $module_list->getPath($module) . "/$name.$type"; - if (is_file($file)) { - require_once $file; - return $file; - } - } - return FALSE; -} - /** * Sets weight of a particular module. * diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f9a6f37adeb77cb358e94f96e8ac41289d7d7fbc..14cf4b0ce8ffe531261e45c616858e7fd2a74bbb 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -12,13 +12,8 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Html; -use Drupal\Component\Render\MarkupInterface; -use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Config\Config; use Drupal\Core\Config\StorageException; -use Drupal\Core\Render\AttachmentsInterface; -use Drupal\Core\Render\BubbleableMetadata; -use Drupal\Core\Render\RenderableInterface; use Drupal\Core\Template\Attribute; use Drupal\Core\Template\AttributeHelper; use Drupal\Core\Theme\ThemeSettings; @@ -71,40 +66,6 @@ * @} End of "defgroup content_flags". */ -/** - * Gets the theme registry. - * - * @param bool $complete - * Optional boolean to indicate whether to return the complete theme registry - * array or an instance of the Drupal\Core\Utility\ThemeRegistry class. - * If TRUE, the complete theme registry array will be returned. This is useful - * if you want to foreach over the whole registry, use array_* functions or - * inspect it in a debugger. If FALSE, an instance of the - * Drupal\Core\Utility\ThemeRegistry class will be returned, this provides an - * ArrayObject which allows it to be accessed with array syntax and isset(), - * and should be more lightweight than the full registry. Defaults to TRUE. - * - * @return array|\Drupal\Core\Utility\ThemeRegistry - * The complete theme registry array, or an instance of the - * Drupal\Core\Utility\ThemeRegistry class. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * theme.registry service methods get() or getRuntime() instead. - * - * @see https://www.drupal.org/node/3348850 - */ -function theme_get_registry($complete = TRUE) { - $theme_registry = \Drupal::service('theme.registry'); - if ($complete) { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method get() instead. See https://www.drupal.org/node/3348850', E_USER_DEPRECATED); - return $theme_registry->get(); - } - else { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method getRuntime() instead. See https://www.drupal.org/node/3348850', E_USER_DEPRECATED); - return $theme_registry->getRuntime(); - } -} - /** * Returns an array of default theme features. * @@ -120,22 +81,6 @@ function _system_default_theme_features() { ]; } -/** - * Forces the system to rebuild the theme registry. - * - * This function should be called when modules are added to the system, or when - * a dynamic system needs to add more theme hooks. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * theme.registry service reset() method instead. - * - * @see https://www.drupal.org/node/3348853 - */ -function drupal_theme_rebuild() { - @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service reset() method instead. See https://www.drupal.org/node/3348853', E_USER_DEPRECATED); - \Drupal::service('theme.registry')->reset(); -} - /** * Allows themes and/or theme engines to easily discover overridden templates. * @@ -337,87 +282,6 @@ function theme_get_setting($setting_name, $theme = NULL) { return $cache[$theme]->get($setting_name); } -/** - * Escapes and renders variables for theme functions. - * - * This method is used in theme functions to ensure that the result is safe for - * output inside HTML fragments. This mimics the behavior of the auto-escape - * functionality in Twig. - * - * Note: This function should be kept in sync with - * \Drupal\Core\Template\TwigExtension::escapeFilter(). - * - * @param mixed $arg - * The string, object, or render array to escape if needed. - * - * @return string - * The rendered string, safe for use in HTML. The string is not safe when used - * as any part of an HTML attribute name or value. - * - * @throws \Exception - * Thrown when an object is passed in which cannot be printed. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no - * replacement. Theme engines must handle escaping by themselves. - * - * @see https://www.drupal.org/node/3336253 - */ -function theme_render_and_autoescape($arg) { - @trigger_error('theme_render_and_autoescape() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. Theme engines must handle escaping by themselves. See https://www.drupal.org/node/3336253', E_USER_DEPRECATED); - - // If it's a renderable, then it'll be up to the generated render array it - // returns to contain the necessary cacheability & attachment metadata. If - // it doesn't implement CacheableDependencyInterface or AttachmentsInterface - // then there is nothing to do here. - if (!($arg instanceof RenderableInterface) && ($arg instanceof CacheableDependencyInterface || $arg instanceof AttachmentsInterface)) { - $arg_bubbleable = []; - BubbleableMetadata::createFromObject($arg) - ->applyTo($arg_bubbleable); - \Drupal::service('renderer')->render($arg_bubbleable); - } - - if ($arg instanceof MarkupInterface) { - return (string) $arg; - } - $return = NULL; - - if (is_scalar($arg)) { - $return = (string) $arg; - } - elseif (is_object($arg)) { - if ($arg instanceof RenderableInterface) { - $arg = $arg->toRenderable(); - } - elseif (method_exists($arg, '__toString')) { - $return = (string) $arg; - } - // You can't throw exceptions in the magic PHP __toString methods, see - // http://php.net/manual/language.oop5.magic.php#object.tostring so - // we also support a toString method. - elseif (method_exists($arg, 'toString')) { - $return = $arg->toString(); - } - else { - throw new \Exception('Object of type ' . get_class($arg) . ' cannot be printed.'); - } - } - - // We have a string or an object converted to a string: Escape it! - if (isset($return)) { - return $return instanceof MarkupInterface ? $return : Html::escape($return); - } - - // This is a normal render array, which is safe by definition, with special - // simple cases already handled. - - // Early return if this element was pre-rendered (no need to re-render). - if (isset($arg['#printed']) && $arg['#printed'] == TRUE && isset($arg['#markup']) && strlen($arg['#markup']) > 0) { - return (string) $arg['#markup']; - } - $arg['#printed'] = FALSE; - return (string) \Drupal::service('renderer')->render($arg); -} - /** * Converts theme settings to configuration. * diff --git a/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php index 92fa49541754635c737d15f4f3a87268ad23c225..5c4d87536d7128187da69aed9a229f68e74d9bec 100644 --- a/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php +++ b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php @@ -146,22 +146,6 @@ protected function getFormAjaxException(\Throwable $e) { return $exception; } - /** - * Wraps format_size() - * - * @return string - * The formatted size. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * \Drupal\Core\StringTranslation\ByteSizeMarkup::create() instead. - * - * @see https://www.drupal.org/node/2999981 - */ - protected function formatSize($size) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\StringTranslation\ByteSizeMarkup::create() instead. See https://www.drupal.org/node/2999981', E_USER_DEPRECATED); - return format_size($size); - } - /** * {@inheritdoc} */ diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc deleted file mode 100644 index 3917276fc6c763fa5b8bd43e947dba765e73961b..0000000000000000000000000000000000000000 --- a/core/modules/file/file.field.inc +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -/** - * @file - * Field module functionality for the File module. - */ - -@trigger_error(__FILE__ . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Functions have been moved to file.module. See https://www.drupal.org/node/3369330', E_USER_DEPRECATED); diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index 47b887f3762925afed6ca913351e838f300e9150..f4e026f0bbb8be21d8938e231b0f37ac1572ce78 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -620,24 +620,4 @@ protected function attemptMemoryReclaim() { return memory_get_usage(); } - /** - * Generates a string representation for the given byte count. - * - * @param int $size - * A size in bytes. - * - * @return string - * A translated string representation of the size. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * \Drupal\Core\StringTranslation\ByteSizeMarkup::create($size, $langcode) - * instead. - * - * @see https://www.drupal.org/node/2999981 - */ - protected function formatSize($size) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\StringTranslation\ByteSizeMarkup::create($size, $langcode) instead. See https://www.drupal.org/node/2999981', E_USER_DEPRECATED); - return format_size($size); - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Asset/LegacyAssetTest.php b/core/tests/Drupal/KernelTests/Core/Asset/LegacyAssetTest.php deleted file mode 100644 index 63865a69e767f79037cea43352ff66e12f9feeba..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Asset/LegacyAssetTest.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Asset; - -use Drupal\KernelTests\KernelTestBase; - -/** - * Tests deprecated asset functions. - * - * @group Asset - * @group legacy - */ -class LegacyAssetTest extends KernelTestBase { - - /** - * Tests the deprecation. - */ - public function testDeprecatedDrupalFlushCssJs(): void { - $this->expectDeprecation('_drupal_flush_css_js is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Asset\AssetQueryStringInterface::reset() instead. See https://www.drupal.org/node/3358337'); - _drupal_flush_css_js(); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Bootstrap/LegacyBootstrapTest.php b/core/tests/Drupal/KernelTests/Core/Bootstrap/LegacyBootstrapTest.php deleted file mode 100644 index a9f506bad28f20c1aaa9754726dfa8d70dd6dcbd..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Bootstrap/LegacyBootstrapTest.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Bootstrap; - -use ColinODell\PsrTestLogger\TestLogger; -use Drupal\Core\Logger\RfcLogLevel; -use Drupal\Core\Utility\Error; -use Drupal\KernelTests\KernelTestBase; - -/** - * Tests legacy bootstrap functions. - * - * @group Bootstrap - * @group legacy - */ -class LegacyBootstrapTest extends KernelTestBase { - - /** - * {@inheritdoc} - */ - protected static $modules = ['system']; - - /** - * Tests watchdog_exception() deprecation. - */ - public function testWatchdogException(): void { - $logger = new TestLogger(); - /** @var \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory */ - $loggerFactory = \Drupal::service('logger.factory'); - $loggerFactory->addLogger($logger); - $this->expectDeprecation('watchdog_exception() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Utility\Error::logException() instead. See https://www.drupal.org/node/2932520'); - $e = new \RuntimeException("foo"); - watchdog_exception('test', $e); - $this->assertTrue($logger->hasRecordThatContains(Error::DEFAULT_ERROR_MESSAGE, RfcLogLevel::ERROR)); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Common/LegacyCommonTest.php b/core/tests/Drupal/KernelTests/Core/Common/LegacyCommonTest.php deleted file mode 100644 index b4ca440472426cb9ab671b9c1dbe40359bf26cab..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Common/LegacyCommonTest.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Common; - -use Drupal\KernelTests\KernelTestBase; - -/** - * Tests deprecated legacy functions in common.inc. - * - * @group Common - * @group legacy - */ -class LegacyCommonTest extends KernelTestBase { - - /** - * Tests deprecation of the format_size() function. - */ - public function testFormatSizeDeprecation(): void { - $this->expectDeprecation('format_size() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\StringTranslation\ByteSizeMarkup::create($size, $langcode) instead. See https://www.drupal.org/node/2999981'); - $size = format_size(4053371676); - $this->assertEquals('3.77 GB', $size); - $this->assertEquals('@size GB', $size->getUntranslatedString()); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php deleted file mode 100644 index 58c89fcd028ea4c7223b20129952499b736c4667..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Extension; - -use Drupal\KernelTests\KernelTestBase; - -/** - * Tests deprecations from module.inc file. - * - * @group legacy - */ -class ModuleLegacyTest extends KernelTestBase { - - /** - * Test deprecation of module_load_include() function. - */ - public function testModuleLoadInclude() { - $this->assertFalse($this->container->get('module_handler')->moduleExists('module_test'), 'Ensure module is uninstalled so we test the ability to include uninstalled code.'); - $this->expectDeprecation('module_load_include() is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. Instead, you should use \Drupal::moduleHandler()->loadInclude(). Note that including code from uninstalled extensions is no longer supported. See https://www.drupal.org/node/2948698'); - $filename = module_load_include('inc', 'module_test', 'module_test.file'); - $this->assertStringEndsWith("module_test.file.inc", $filename); - - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Site/LegacySettingsRewriteTest.php b/core/tests/Drupal/KernelTests/Core/Site/LegacySettingsRewriteTest.php deleted file mode 100644 index f1e6e40844f0eb566f2fcdc7bdd273e005f28c3c..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Site/LegacySettingsRewriteTest.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Site; - -use Drupal\Core\Site\Settings; -use Drupal\KernelTests\KernelTestBase; - -/** - * Tests the drupal_rewrite_settings() function. - * - * @group system - * @group legacy - * @covers drupal_rewrite_settings - */ -class LegacySettingsRewriteTest extends KernelTestBase { - - /** - * Tests the drupal_rewrite_settings() function. - */ - public function testDrupalRewriteSettings() { - include_once $this->root . '/core/includes/install.inc'; - $site_path = $this->container->getParameter('site.path'); - $tests = [ - [ - 'original' => '$no_index_value_scalar = TRUE;', - 'settings' => [ - 'no_index_value_scalar' => (object) [ - 'value' => FALSE, - 'comment' => 'comment', - ], - ], - 'expected' => '$no_index_value_scalar = false; // comment', - ], - [ - 'original' => '$no_index_value_scalar = TRUE;', - 'settings' => [ - 'no_index_value_foo' => [ - 'foo' => [ - 'value' => (object) [ - 'value' => NULL, - 'required' => TRUE, - 'comment' => 'comment', - ], - ], - ], - ], - 'expected' => <<<'EXPECTED' -$no_index_value_scalar = TRUE; -$no_index_value_foo['foo']['value'] = NULL; // comment -EXPECTED - ], - [ - 'original' => '$no_index_value_array = array("old" => "value");', - 'settings' => [ - 'no_index_value_array' => (object) [ - 'value' => FALSE, - 'required' => TRUE, - 'comment' => 'comment', - ], - ], - 'expected' => '$no_index_value_array = array("old" => "value"); -$no_index_value_array = false; // comment', - ], - [ - 'original' => '$has_index_value_scalar["foo"]["bar"] = NULL;', - 'settings' => [ - 'has_index_value_scalar' => [ - 'foo' => [ - 'bar' => (object) [ - 'value' => FALSE, - 'required' => TRUE, - 'comment' => 'comment', - ], - ], - ], - ], - 'expected' => '$has_index_value_scalar["foo"]["bar"] = false; // comment', - ], - [ - 'original' => '$has_index_value_scalar["foo"]["bar"] = "foo";', - 'settings' => [ - 'has_index_value_scalar' => [ - 'foo' => [ - 'value' => (object) [ - 'value' => ['value' => 2], - 'required' => TRUE, - 'comment' => 'comment', - ], - ], - ], - ], - 'expected' => <<<'EXPECTED' -$has_index_value_scalar["foo"]["bar"] = "foo"; -$has_index_value_scalar['foo']['value'] = array ( - 'value' => 2, -); // comment -EXPECTED - ], - ]; - foreach ($tests as $test) { - $filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php'; - file_put_contents($filename, "<?php\n" . $test['original'] . "\n"); - $this->expectDeprecation('drupal_rewrite_settings() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. The order of the arguments has also changed: $settings_file is now required and is the first argument of the method. See https://www.drupal.org/node/3244583'); - drupal_rewrite_settings($test['settings'], $filename); - $this->assertEquals("<?php\n" . $test['expected'] . "\n", file_get_contents($filename)); - } - - // Test that <?php gets added to the start of an empty settings file. - // Set the array of settings that will be written to the file. - $test = [ - 'settings' => [ - 'no_index' => (object) [ - 'value' => TRUE, - 'required' => TRUE, - ], - ], - 'expected' => '$no_index = true;', - ]; - // Make an empty file. - $filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php'; - file_put_contents($filename, ""); - - $this->expectDeprecation('drupal_rewrite_settings() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. The order of the arguments has also changed: $settings_file is now required and is the first argument of the method. See https://www.drupal.org/node/3244583'); - // Write the setting to the file. - drupal_rewrite_settings($test['settings'], $filename); - - // Check that the result is just the php opening tag and the settings. - $this->assertEquals("<?php\n" . $test['expected'] . "\n", file_get_contents($filename)); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php index d5f74801f7cd0f13c159ed88cfcde9c24e046d08..8fa5c578372f25a4206d8c5cbb2be6e2b24aa672 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php @@ -275,34 +275,4 @@ public function testThemeTemplatesRegisteredByModules() { $this->assertEquals($expected, array_values($registry['theme_test_registered_by_module']['preprocess functions'])); } - /** - * Tests deprecated drupal_theme_rebuild() function. - * - * @see drupal_theme_rebuild() - * @group legacy - */ - public function testLegacyThemeRegistryRebuild() { - $registry = \Drupal::service('theme.registry'); - $runtime = $registry->getRuntime(); - $hooks = $registry->get(); - $this->expectDeprecation('drupal_theme_rebuild() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service reset() method instead. See https://www.drupal.org/node/3348853'); - drupal_theme_rebuild(); - $this->assertNotSame($runtime, $registry->getRuntime()); - $this->assertSame($hooks, $registry->get()); - } - - /** - * Tests deprecated theme_get_registry function. - * - * @see theme_get_registry() - * @group legacy - */ - public function testLegacyThemeGetRegistry() { - $registry = \Drupal::service('theme.registry'); - $this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method get() instead. See https://www.drupal.org/node/3348850'); - $this->assertEquals($registry->get(), theme_get_registry()); - $this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method getRuntime() instead. See https://www.drupal.org/node/3348850'); - $this->assertEquals($registry->getRuntime(), theme_get_registry(FALSE)); - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php deleted file mode 100644 index 901be11a72f1b71e5236ecb2023f95735e5ae375..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeRenderAndAutoescapeTest.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Theme; - -use Drupal\Component\Utility\Html; -use Drupal\Core\GeneratedLink; -use Drupal\Core\Link; -use Drupal\Core\Render\RenderContext; -use Drupal\Core\Render\Markup; -use Drupal\Core\Url; -use Drupal\KernelTests\KernelTestBase; - -/** - * Tests the theme_render_and_autoescape() function. - * - * @group Theme - * @group legacy - * @group #slow - */ -class ThemeRenderAndAutoescapeTest extends KernelTestBase { - - /** - * {@inheritdoc} - */ - protected static $modules = ['system']; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - $this->expectDeprecation('theme_render_and_autoescape() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. Theme engines must handle escaping by themselves. See https://www.drupal.org/node/3336253'); - } - - /** - * @dataProvider providerTestThemeRenderAndAutoescape - */ - public function testThemeRenderAndAutoescape($arg, $expected) { - if (is_array($arg) && isset($arg['#type']) && $arg['#type'] === 'link') { - $arg = Link::createFromRoute($arg['#title'], $arg['#url']); - } - - $context = new RenderContext(); - // Use a closure here since we need to render with a render context. - $theme_render_and_autoescape = function () use ($arg) { - return theme_render_and_autoescape($arg); - }; - /** @var \Drupal\Core\Render\RendererInterface $renderer */ - $renderer = \Drupal::service('renderer'); - $output = $renderer->executeInRenderContext($context, $theme_render_and_autoescape); - $this->assertEquals($expected, $output); - $this->assertIsString($output); - } - - /** - * Provide test examples. - */ - public static function providerTestThemeRenderAndAutoescape() { - return [ - 'empty string unchanged' => ['', ''], - 'simple string unchanged' => ['ab', 'ab'], - 'int (scalar) cast to string' => [111, '111'], - 'float (scalar) cast to string' => [2.10, '2.1'], - '> is escaped' => ['>', '>'], - 'Markup EM tag is unchanged' => [Markup::create('<em>hi</em>'), '<em>hi</em>'], - 'Markup SCRIPT tag is unchanged' => [Markup::create('<script>alert("hi");</script>'), '<script>alert("hi");</script>'], - 'EM tag in string is escaped' => ['<em>hi</em>', Html::escape('<em>hi</em>')], - 'type link render array is rendered' => [['#type' => 'link', '#title' => 'Text', '#url' => '<none>'], '<a href="">Text</a>'], - 'type markup with EM tags is rendered' => [['#markup' => '<em>hi</em>'], '<em>hi</em>'], - 'SCRIPT tag in string is escaped' => [ - '<script>alert(123)</script>', - Html::escape('<script>alert(123)</script>'), - ], - 'type plain_text render array EM tag is escaped' => [['#plain_text' => '<em>hi</em>'], Html::escape('<em>hi</em>')], - 'type hidden render array is rendered' => [['#type' => 'hidden', '#name' => 'foo', '#value' => 'bar'], "<input type=\"hidden\" name=\"foo\" value=\"bar\" />\n"], - ]; - } - - /** - * Ensures invalid content is handled correctly. - */ - public function testThemeEscapeAndRenderNotPrintable() { - $this->expectException(\Exception::class); - theme_render_and_autoescape(new NonPrintable()); - } - - /** - * Ensure cache metadata is bubbled when using theme_render_and_autoescape(). - */ - public function testBubblingMetadata() { - $link = new GeneratedLink(); - $link->setGeneratedLink('<a href="http://example.com"></a>'); - $link->addCacheTags(['foo']); - $link->addAttachments(['library' => ['system/base']]); - - $context = new RenderContext(); - // Use a closure here since we need to render with a render context. - $theme_render_and_autoescape = function () use ($link) { - return theme_render_and_autoescape($link); - }; - /** @var \Drupal\Core\Render\RendererInterface $renderer */ - $renderer = \Drupal::service('renderer'); - $output = $renderer->executeInRenderContext($context, $theme_render_and_autoescape); - $this->assertEquals('<a href="http://example.com"></a>', $output); - /** @var \Drupal\Core\Render\BubbleableMetadata $metadata */ - $metadata = $context->pop(); - $this->assertEquals(['foo'], $metadata->getCacheTags()); - $this->assertEquals(['library' => ['system/base']], $metadata->getAttachments()); - } - - /** - * Ensure cache metadata is bubbled when using theme_render_and_autoescape(). - */ - public function testBubblingMetadataWithRenderable() { - $link = new Link('', Url::fromRoute('<current>')); - - $context = new RenderContext(); - // Use a closure here since we need to render with a render context. - $theme_render_and_autoescape = function () use ($link) { - return theme_render_and_autoescape($link); - }; - /** @var \Drupal\Core\Render\RendererInterface $renderer */ - $renderer = \Drupal::service('renderer'); - $output = $renderer->executeInRenderContext($context, $theme_render_and_autoescape); - $this->assertEquals('<a href="/' . urlencode('<none>') . '"></a>', $output); - /** @var \Drupal\Core\Render\BubbleableMetadata $metadata */ - $metadata = $context->pop(); - $this->assertEquals(['route'], $metadata->getCacheContexts()); - } - -} - -class NonPrintable {}