Unverified Commit 144c05e1 authored by alexpott's avatar alexpott

Issue #3062757 by voleger, Berdir, andypost: Remove deprecated legacy include files from Drupal 9

parent 7403764a
......@@ -6,15 +6,8 @@
*/
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Html;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\BootstrapConfigStorageFactory;
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Test\TestDatabase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Utility\Error;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
......@@ -94,28 +87,6 @@
*/
const ERROR_REPORTING_DISPLAY_VERBOSE = 'verbose';
/**
* Role ID for anonymous users; should match what's in the "role" table.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
* \Drupal\user\RoleInterface::ANONYMOUS_ID instead.
*
* @see https://www.drupal.org/node/1619504
*/
const DRUPAL_ANONYMOUS_RID = AccountInterface::ANONYMOUS_ROLE;
/**
* Role ID for authenticated users; should match what's in the "role" table.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use Drupal\Core\Session\AccountInterface::AUTHENTICATED_ROLE or
* \Drupal\user\RoleInterface::AUTHENTICATED_ID instead.
*
* @see https://www.drupal.org/node/1619504
*/
const DRUPAL_AUTHENTICATED_RID = AccountInterface::AUTHENTICATED_ROLE;
/**
* The maximum number of characters in a module or theme name.
*/
......@@ -145,41 +116,6 @@
*/
const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
/**
* $config_directories key for active directory.
*
* @see config_get_config_directory()
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Drupal core no
* longer creates an active directory.
*
* @see https://www.drupal.org/node/2501187
*/
const CONFIG_ACTIVE_DIRECTORY = 'active';
/**
* $config_directories key for sync directory.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Site\Settings::get('config_sync_directory') instead.
*
* @see https://www.drupal.org/node/3018145
*/
const CONFIG_SYNC_DIRECTORY = 'sync';
/**
* $config_directories key for staging directory.
*
* @see config_get_config_directory()
* @see CONFIG_SYNC_DIRECTORY
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. The staging
* directory was renamed to sync.
*
* @see https://www.drupal.org/node/2574957
*/
const CONFIG_STAGING_DIRECTORY = 'staging';
/**
* Defines the root directory of the Drupal installation.
*
......@@ -187,45 +123,6 @@
*/
define('DRUPAL_ROOT', dirname(dirname(__DIR__)));
/**
* Returns the path of a configuration directory.
*
* Configuration directories are configured using $config_directories in
* settings.php.
*
* @param string $type
* The type of config directory to return. Drupal core provides the
* CONFIG_SYNC_DIRECTORY constant to access the sync directory.
*
* @return string
* The configuration directory path.
*
* @throws \Exception
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Site\Settings::get('config_sync_directory') instead.
*
* @see https://www.drupal.org/node/3018145
*/
function config_get_config_directory($type) {
global $config_directories;
@trigger_error('config_get_config_directory() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Site\Settings::get(\'config_sync_directory\') instead. See https://www.drupal.org/node/3018145', E_USER_DEPRECATED);
$config_sync_directory = Settings::get('config_sync_directory', FALSE);
if ($config_sync_directory) {
$config_directories[CONFIG_SYNC_DIRECTORY] = $config_sync_directory;
}
// @todo Remove fallback in Drupal 9. https://www.drupal.org/node/2574943
if ($type == CONFIG_SYNC_DIRECTORY && !isset($config_directories[CONFIG_SYNC_DIRECTORY]) && isset($config_directories[CONFIG_STAGING_DIRECTORY])) {
$type = CONFIG_STAGING_DIRECTORY;
}
if (!empty($config_directories[$type])) {
return $config_directories[$type];
}
// @todo https://www.drupal.org/node/2696103 Throw a more specific exception.
throw new \Exception("The configuration directory type '$type' does not exist");
}
/**
* Returns and optionally sets the filename for a system resource.
*
......@@ -352,58 +249,6 @@ function t($string, array $args = [], array $options = []) {
return new TranslatableMarkup($string, $args, $options);
}
/**
* Formats a string for HTML display by replacing variable placeholders.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use \Drupal\Component\Render\FormattableMarkup instead.
*
* @see https://www.drupal.org/node/2302363
* @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat()
* @see \Drupal\Component\Render\FormattableMarkup
* @see t()
* @ingroup sanitization
*/
function format_string($string, array $args) {
@trigger_error("format_string() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Component\Render\FormattableMarkup instead. See https://www.drupal.org/node/2302363", E_USER_DEPRECATED);
return new FormattableMarkup($string, $args);
}
/**
* Checks whether a string is valid UTF-8.
*
* All functions designed to filter input should use drupal_validate_utf8
* to ensure they operate on valid UTF-8 strings to prevent bypass of the
* filter.
*
* When text containing an invalid UTF-8 lead byte (0xC0 - 0xFF) is presented
* as UTF-8 to Internet Explorer 6, the program may misinterpret subsequent
* bytes. When these subsequent bytes are HTML control characters such as
* quotes or angle brackets, parts of the text that were deemed safe by filters
* end up in locations that are potentially unsafe; An onerror attribute that
* is outside of a tag, and thus deemed safe by a filter, can be interpreted
* by the browser as if it were inside the tag.
*
* The function does not return FALSE for strings containing character codes
* above U+10FFFF, even though these are prohibited by RFC 3629.
*
* @param $text
* The text to check.
*
* @return bool
* TRUE if the text is valid UTF-8, FALSE if not.
*
* @see \Drupal\Component\Utility\Unicode::validateUtf8()
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use \Drupal\Component\Utility\Unicode::validateUtf8().
*
* @see https://www.drupal.org/node/1992584
*/
function drupal_validate_utf8($text) {
return Unicode::validateUtf8($text);
}
/**
* Logs an exception.
*
......@@ -443,22 +288,6 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
\Drupal::logger($type)->log($severity, $message, $variables);
}
/**
* Returns the time zone of the current user.
*
* @return string
* The name of the current user's timezone or the name of the default timezone.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* date_default_timezone_get() instead.
*
* @see https://www.drupal.org/node/3009387
*/
function drupal_get_user_timezone() {
@trigger_error('drupal_get_user_timezone() is deprecated in drupal:8.8.0. It will be removed from drupal:9.0.0. Use date_default_timezone_get() instead. See https://www.drupal.org/node/3009387', E_USER_DEPRECATED);
return date_default_timezone_get();
}
/**
* Provides custom PHP error handling.
*
......@@ -632,95 +461,6 @@ function drupal_maintenance_theme() {
_drupal_maintenance_theme();
}
/**
* Returns TRUE if a Drupal installation is currently being attempted.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\Core\Installer\InstallerKernel::installationAttempted()
* instead.
*
* @see https://www.drupal.org/node/3035275
*/
function drupal_installation_attempted() {
@trigger_error('drupal_installation_attempted() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Installer\InstallerKernel::installationAttempted() instead. See https://www.drupal.org/node/3035275', E_USER_DEPRECATED);
return InstallerKernel::installationAttempted();
}
/**
* Gets the name of the currently active installation profile.
*
* When this function is called during Drupal's initial installation process,
* the name of the profile that's about to be installed is stored in the global
* installation state. At all other times, the "install_profile" setting will be
* available in container as a parameter.
*
* @return string|null
* The name of the installation profile or NULL if no installation profile is
* currently active. This is the case for example during the first steps of
* the installer or during unit tests.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use the install_profile container parameter or \Drupal::installProfile()
* instead. If you are accessing the value before it is written to
* configuration during the installer use the $install_state global. If you
* need to access the value before container is available you can use
* BootstrapConfigStorageFactory to load the value directly from
* configuration.
*
* @see https://www.drupal.org/node/2538996
*/
function drupal_get_profile() {
global $install_state;
@trigger_error('drupal_get_profile() is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use the install_profile container parameter or \Drupal::installProfile() instead. If you are accessing the value before it is written to configuration during the installer use the $install_state global. If you need to access the value before container is available you can use BootstrapConfigStorageFactory to load the value directly from configuration. See https://www.drupal.org/node/2538996', E_USER_DEPRECATED);
if (InstallerKernel::installationAttempted()) {
// If the profile has been selected return it.
if (isset($install_state['parameters']['profile'])) {
$profile = $install_state['parameters']['profile'];
}
else {
$profile = NULL;
}
}
else {
if (\Drupal::hasContainer()) {
$profile = \Drupal::installProfile();
}
else {
$profile = BootstrapConfigStorageFactory::getDatabaseStorage()->read('core.extension')['profile'];
}
}
return $profile;
}
/**
* Registers an additional namespace.
*
* @param string $name
* The namespace component to register; e.g., 'node'.
* @param string $path
* The relative path to the Drupal component in the filesystem.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the
* class loader as injected service instance to register the namespace:
* @code
* $this->classLoader->addPsr4('Drupal\\' . $name . '\\', \Drupal::root() . '/' . $path . '/src');
* @endcode
* or the following code if the service cannot be injected:
* @code
* \Drupal::service('class_loader')->addPsr4('Drupal\\' . $name . '\\', \Drupal::root() . '/' . $path . '/src');
* @endcode
*
* @see https://www.drupal.org/node/3035275
*/
function drupal_classloader_register($name, $path) {
@trigger_error('drupal_classloader_register() is deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Use the method ::addPsr4() of the class_loader service to register the namespace. See https://www.drupal.org/node/3035275.', E_USER_DEPRECATED);
$loader = \Drupal::service('class_loader');
$loader->addPsr4('Drupal\\' . $name . '\\', \Drupal::root() . '/' . $path . '/src');
}
/**
* Provides central static variable storage.
*
......@@ -878,21 +618,6 @@ function drupal_static_reset($name = NULL) {
drupal_static($name, NULL, TRUE);
}
/**
* Formats text for emphasized display in a placeholder inside a sentence.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
* \Drupal\Component\Render\FormattableMarkup or Twig's "placeholder" filter
* instead. Note this method should not be used to simply emphasize a string
* and therefore has few valid use-cases. Note also, that this method does not
* mark the string as safe.
*
* @see https://www.drupal.org/node/2302363
*/
function drupal_placeholder($text) {
return '<em class="placeholder">' . Html::escape($text) . '</em>';
}
/**
* Registers a function for execution on shutdown.
*
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -344,7 +344,6 @@ function install_begin_request($class_loader, &$install_state) {
require_once __DIR__ . '/file.inc';
require_once __DIR__ . '/install.inc';
require_once __DIR__ . '/schema.inc';
require_once __DIR__ . '/database.inc';
require_once __DIR__ . '/form.inc';
require_once __DIR__ . '/batch.inc';
......@@ -795,7 +794,6 @@ function install_tasks($install_state) {
'run' => $install_state['settings_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
'function' => 'Drupal\Core\Installer\Form\SiteSettingsForm',
],
'install_write_profile' => [],
'install_verify_database_ready' => [
'run' => $install_state['database_ready'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
],
......@@ -2279,33 +2277,6 @@ function install_display_requirements($install_state, $requirements) {
}
}
/**
* Installation task; writes profile to settings.php if possible.
*
* @param array $install_state
* An array of information about the current installation state.
*
* @see _install_select_profile()
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. The
* install profile is written to core.extension.
*/
function install_write_profile($install_state) {
// Only write the install profile to settings.php if it already exists. The
// value from settings.php is never used but drupal_rewrite_settings() does
// not support removing a setting. If the value is present in settings.php
// there will be an informational notice on the status report.
$settings_path = \Drupal::service('site.path') . '/settings.php';
if (is_writable($settings_path) && array_key_exists('install_profile', Settings::getAll())) {
// Remember the profile which was used.
$settings['settings']['install_profile'] = (object) [
'value' => $install_state['parameters']['profile'],
'required' => TRUE,
];
drupal_rewrite_settings($settings);
}
}
/**
* Creates a batch for the config importer to process.
*
......
......@@ -5,13 +5,11 @@
* API functions for installing modules and themes.
*/
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\OpCodeCache;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Extension\Dependency;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\RedirectResponse;
......@@ -477,91 +475,6 @@ function _drupal_rewrite_settings_dump_one(\stdClass $variable, $prefix = '', $s
return $return;
}
/**
* Creates the config directory and ensures it is operational.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. There is no
* replacement.
*
* @see https://www.drupal.org/node/3018145
*/
function drupal_install_config_directories() {
@trigger_error('drupal_install_config_directories() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. There is no replacement. See https://www.drupal.org/node/3018145.', E_USER_DEPRECATED);
global $config_directories, $install_state;
// If settings.php does not contain a config sync directory name we need to
// configure one.
if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
if (empty($install_state['config_install_path'])) {
// Add a randomized config directory name to settings.php
$config_directories[CONFIG_SYNC_DIRECTORY] = \Drupal::service('site.path') . '/files/config_' . Crypt::randomBytesBase64(55) . '/sync';
}
else {
// Install profiles can contain a config sync directory. If they do,
// 'config_install_path' is a path to the directory.
$config_directories[CONFIG_SYNC_DIRECTORY] = $install_state['config_install_path'];
}
$settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
'value' => $config_directories[CONFIG_SYNC_DIRECTORY],
'required' => TRUE,
];
// Rewrite settings.php, which also sets the value as global variable.
drupal_rewrite_settings($settings);
}
// This should never fail, since if the config directory was specified in
// settings.php it will have already been created and verified earlier, and
// if it wasn't specified in settings.php, it is created here inside the
// public files directory, which has already been verified to be writable
// itself. But if it somehow fails anyway, the installation cannot proceed.
// Bail out using a similar error message as in system_requirements().
if (!\Drupal::service('file_system')->prepareDirectory($config_directories[CONFIG_SYNC_DIRECTORY], FileSystemInterface::CREATE_DIRECTORY)
&& !file_exists($config_directories[CONFIG_SYNC_DIRECTORY])) {
throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', [
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
':handbook_url' => 'https://www.drupal.org/server-permissions',
]));
}
elseif (is_writable($config_directories[CONFIG_SYNC_DIRECTORY])) {
// Put a README.txt into the sync config directory. This is required so that
// they can later be added to git. Since this directory is auto-created, we
// have to write out the README rather than just adding it to the drupal core
// repo.
$text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.' . ' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
file_put_contents(config_get_config_directory(CONFIG_SYNC_DIRECTORY) . '/README.txt', "$text\n");
}
}
/**
* Ensures that the config directory exists and is writable, or can be made so.
*
* @param string $type
* Type of config directory to return. Drupal core provides 'sync'.
*
* @return bool
* TRUE if the config directory exists and is writable.
*
* @deprecated in drupal:8.1.0 and is removed from drupal:9.0.0. Use
* config_get_config_directory() and
* \Drupal\Core\File\FileSystemInterface::prepareDirectory() instead.
*
* @see https://www.drupal.org/node/2501187
*/
function install_ensure_config_directory($type) {
@trigger_error('install_ensure_config_directory() is deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. Use config_get_config_directory() and \Drupal\Core\File\FileSystemInterface::prepareDirectory() instead. See https://www.drupal.org/node/2501187.', E_USER_DEPRECATED);
// The config directory must be defined in settings.php.
global $config_directories;
if (!isset($config_directories[$type])) {
return FALSE;
}
// The logic here is similar to that used by system_requirements() for other
// directories that the installer creates.
else {
$config_directory = config_get_config_directory($type);
return \Drupal::service('file_system')->prepareDirectory($config_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
}
/**
* Verifies that all dependencies are met for a given installation profile.
*
......
......@@ -11,7 +11,6 @@
*/
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Render\Element;
/**
* Prepares variables for single local task link templates.
......@@ -91,97 +90,6 @@ function menu_list_system_menus() {
];
}
/**
* Collects the local tasks (tabs) for the current route.
*
* @param int $level
* The level of tasks you ask for. Primary tasks are 0, secondary are 1.
*
* @return array
* An array containing
* - tabs: Local tasks for the requested level.
* - route_name: The route name for the current page used to collect the local
* tasks.
*
* @see hook_menu_local_tasks_alter()
* @see https://www.drupal.org/node/2544940
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
*/
function menu_local_tasks($level = 0) {
/** @var \Drupal\Core\Menu\LocalTaskManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.menu.local_task');
return $manager->getLocalTasks(\Drupal::routeMatch()->getRouteName(), $level);
}
/**
* Returns the rendered local tasks at the top level.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Menu\LocalTaskManagerInterface::getLocalTasks() instead.
*
* @see https://www.drupal.org/node/2874695
*/
function menu_primary_local_tasks() {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Menu\LocalTaskManagerInterface::getLocalTasks() instead. See https://www.drupal.org/node/2874695', E_USER_DEPRECATED);
/** @var \Drupal\Core\Menu\LocalTaskManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.menu.local_task');
$links = $manager->getLocalTasks(\Drupal::routeMatch()->getRouteName(), 0);
// Do not display single tabs.
return count(Element::getVisibleChildren($links['tabs'])) > 1 ? $links['tabs'] : '';
}
/**
* Returns the rendered local tasks at the second level.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Menu\LocalTaskManagerInterface::getLocalTasks() instead.
*
* @see https://www.drupal.org/node/2874695
*/
function menu_secondary_local_tasks() {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Menu\LocalTaskManagerInterface::getLocalTasks() instead. See https://www.drupal.org/node/2874695', E_USER_DEPRECATED);
/** @var \Drupal\Core\Menu\LocalTaskManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.menu.local_task');
$links = $manager->getLocalTasks(\Drupal::routeMatch()->getRouteName(), 1);
// Do not display single tabs.
return count(Element::getVisibleChildren($links['tabs'])) > 1 ? $links['tabs'] : '';
}
/**
* Returns a renderable element for the primary and secondary tabs.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* local_tasks_block block or inline theming instead.
*
* @see https://www.drupal.org/node/2874695
*/
function menu_local_tabs() {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use local_tasks_block block or inline theming instead. See https://www.drupal.org/node/2874695', E_USER_DEPRECATED);
$build = [
'#theme' => 'menu_local_tasks',
'#primary' => menu_primary_local_tasks(),
'#secondary' => menu_secondary_local_tasks(),
];
return !empty($build['#primary']) || !empty($build['#secondary']) ? $build : [];
}
/**
* Clears all cached menu data.
*
* This should be called any time broad changes
* might have been made to the router items or menu links.
*
* @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use
* \Drupal::cache('menu')->invalidateAll() instead.
*
* @see https://www.drupal.org/node/2989138
*/
function menu_cache_clear_all() {
@trigger_error("menu_cache_clear_all() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use \Drupal::cache('menu')->invalidateAll() instead. See https://www.drupal.org/node/2989138", E_USER_DEPRECATED);
\Drupal::cache('menu')->invalidateAll();
}
/**
* @} End of "addtogroup menu".
*/
......@@ -7,82 +7,6 @@
use Drupal\Core\Extension\ExtensionDiscovery;
/**
* Builds a list of installed themes.
*
* @param $type
* The type of list to return:
* - theme: All installed themes.
*
* @return array
* An associative array of themes, keyed by name.
* For $type 'theme', the array values are objects representing the