Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -42,13 +42,27 @@ function _batch_page(Request $request) {
|
|||
if (!$batch) {
|
||||
$batch = \Drupal::service('batch.storage')->load($request_id);
|
||||
if (!$batch) {
|
||||
drupal_set_message(t('No active batch.'), 'error');
|
||||
\Drupal::messenger()->addError(t('No active batch.'));
|
||||
return new RedirectResponse(\Drupal::url('<front>', [], ['absolute' => TRUE]));
|
||||
}
|
||||
}
|
||||
|
||||
// Register database update for the end of processing.
|
||||
// We need to store the updated batch information in the batch storage after
|
||||
// processing the batch. In order for the error page to work correctly this
|
||||
// needs to be done even in case of a PHP fatal error in which case the end of
|
||||
// this function is never reached. Therefore we register a shutdown function
|
||||
// to handle this case. Because with FastCGI and fastcgi_finish_request()
|
||||
// shutdown functions are called after the HTTP connection is closed, updating
|
||||
// the batch information in a shutdown function would lead to race conditions
|
||||
// between consecutive requests if the batch processing continues. In case of
|
||||
// a fatal error the processing stops anyway, so it works even with FastCGI.
|
||||
// However, we must ensure to only update in the shutdown phase in this
|
||||
// particular case we track whether the batch information still needs to be
|
||||
// updated.
|
||||
// @see _batch_shutdown()
|
||||
// @see \Symfony\Component\HttpFoundation\Response::send()
|
||||
drupal_register_shutdown_function('_batch_shutdown');
|
||||
_batch_needs_update(TRUE);
|
||||
|
||||
$build = [];
|
||||
|
||||
|
@ -70,18 +84,46 @@ function _batch_page(Request $request) {
|
|||
$current_set = _batch_current_set();
|
||||
$build['#title'] = $current_set['title'];
|
||||
$build['content'] = _batch_progress_page();
|
||||
|
||||
$response = $build;
|
||||
break;
|
||||
|
||||
case 'do':
|
||||
// JavaScript-based progress page callback.
|
||||
return _batch_do();
|
||||
$response = _batch_do();
|
||||
break;
|
||||
|
||||
case 'finished':
|
||||
// _batch_finished() returns a RedirectResponse.
|
||||
return _batch_finished();
|
||||
$response = _batch_finished();
|
||||
break;
|
||||
}
|
||||
|
||||
return $build;
|
||||
if ($batch) {
|
||||
\Drupal::service('batch.storage')->update($batch);
|
||||
}
|
||||
_batch_needs_update(FALSE);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the batch information needs to be updated in the storage.
|
||||
*
|
||||
* @param bool $new_value
|
||||
* (optional) A new value to set.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the batch information needs to be updated; FALSE otherwise.
|
||||
*/
|
||||
function _batch_needs_update($new_value = NULL) {
|
||||
$needs_update = &drupal_static(__FUNCTION__, FALSE);
|
||||
|
||||
if (isset($new_value)) {
|
||||
$needs_update = $new_value;
|
||||
}
|
||||
|
||||
return $needs_update;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,7 +551,7 @@ function _batch_finished() {
|
|||
* @see drupal_register_shutdown_function()
|
||||
*/
|
||||
function _batch_shutdown() {
|
||||
if ($batch = batch_get()) {
|
||||
if (($batch = batch_get()) && _batch_needs_update()) {
|
||||
\Drupal::service('batch.storage')->update($batch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,29 +7,47 @@
|
|||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Config\BootstrapConfigStorageFactory;
|
||||
use Drupal\Core\Extension\Exception\UnknownExtensionException;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Minimum supported version of PHP.
|
||||
*
|
||||
* Drupal cannot be installed on versions of PHP older than this version.
|
||||
*
|
||||
* @todo Move this to an appropriate autoloadable class. See
|
||||
* https://www.drupal.org/project/drupal/issues/2908079
|
||||
*/
|
||||
const DRUPAL_MINIMUM_PHP = '5.5.9';
|
||||
|
||||
/**
|
||||
* Minimum recommended version of PHP.
|
||||
*
|
||||
* Sites installing Drupal on PHP versions lower than this will see a warning
|
||||
* message, but Drupal can still be installed. Used for (e.g.) PHP versions
|
||||
* that have reached their EOL or will in the near future.
|
||||
*
|
||||
* @todo Move this to an appropriate autoloadable class. See
|
||||
* https://www.drupal.org/project/drupal/issues/2908079
|
||||
*/
|
||||
const DRUPAL_RECOMMENDED_PHP = '7.1';
|
||||
|
||||
/**
|
||||
* Minimum recommended value of PHP memory_limit.
|
||||
*
|
||||
* 64M was chosen as a minimum requirement in order to allow for additional
|
||||
* contributed modules to be installed prior to hitting the limit. However,
|
||||
* 40M is the target for the Standard installation profile.
|
||||
*
|
||||
* @todo Move this to an appropriate autoloadable class. See
|
||||
* https://www.drupal.org/project/drupal/issues/2908079
|
||||
*/
|
||||
const DRUPAL_MINIMUM_PHP_MEMORY_LIMIT = '64M';
|
||||
|
||||
|
@ -201,7 +219,7 @@ function config_get_config_directory($type) {
|
|||
* The filename of the item if it is to be set explicitly rather
|
||||
* than by consulting the database.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The filename of the requested item or NULL if the item is not found.
|
||||
*/
|
||||
function drupal_get_filename($type, $name, $filename = NULL) {
|
||||
|
@ -217,43 +235,45 @@ function drupal_get_filename($type, $name, $filename = NULL) {
|
|||
return 'core/core.info.yml';
|
||||
}
|
||||
|
||||
// Profiles are converted into modules in system_rebuild_module_data().
|
||||
// @todo Remove false-exposure of profiles as modules.
|
||||
if ($type == 'profile') {
|
||||
$type = 'module';
|
||||
}
|
||||
if (!isset($files[$type])) {
|
||||
$files[$type] = [];
|
||||
if ($type === 'module' || $type === 'profile') {
|
||||
$service_id = 'extension.list.' . $type;
|
||||
/** @var \Drupal\Core\Extension\ExtensionList $extension_list */
|
||||
$extension_list = \Drupal::service($service_id);
|
||||
if (isset($filename)) {
|
||||
// Manually add the info file path of an extension.
|
||||
$extension_list->setPathname($name, $filename);
|
||||
}
|
||||
try {
|
||||
return $extension_list->getPathname($name);
|
||||
}
|
||||
catch (UnknownExtensionException $e) {
|
||||
// Catch the exception. This will result in triggering an error.
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (isset($filename)) {
|
||||
$files[$type][$name] = $filename;
|
||||
}
|
||||
elseif (!isset($files[$type][$name])) {
|
||||
// If the pathname of the requested extension is not known, try to retrieve
|
||||
// the list of extension pathnames from various providers, checking faster
|
||||
// providers first.
|
||||
// Retrieve the current module list (derived from the service container).
|
||||
if ($type == 'module' && \Drupal::hasService('module_handler')) {
|
||||
foreach (\Drupal::moduleHandler()->getModuleList() as $module_name => $module) {
|
||||
$files[$type][$module_name] = $module->getPathname();
|
||||
if (!isset($files[$type])) {
|
||||
$files[$type] = [];
|
||||
}
|
||||
|
||||
if (isset($filename)) {
|
||||
$files[$type][$name] = $filename;
|
||||
}
|
||||
elseif (!isset($files[$type][$name])) {
|
||||
// If still unknown, retrieve the file list prepared in state by
|
||||
// \Drupal\Core\Extension\ExtensionList() and
|
||||
// \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData().
|
||||
if (!isset($files[$type][$name]) && \Drupal::hasService('state')) {
|
||||
$files[$type] += \Drupal::state()->get('system.' . $type . '.files', []);
|
||||
}
|
||||
}
|
||||
// If still unknown, retrieve the file list prepared in state by
|
||||
// system_rebuild_module_data() and
|
||||
// \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData().
|
||||
if (!isset($files[$type][$name]) && \Drupal::hasService('state')) {
|
||||
$files[$type] += \Drupal::state()->get('system.' . $type . '.files', []);
|
||||
}
|
||||
// If still unknown, create a user-level error message.
|
||||
if (!isset($files[$type][$name])) {
|
||||
trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($files[$type][$name])) {
|
||||
return $files[$type][$name];
|
||||
if (isset($files[$type][$name])) {
|
||||
return $files[$type][$name];
|
||||
}
|
||||
}
|
||||
// If the filename is still unknown, create a user-level error message.
|
||||
trigger_error(new FormattableMarkup('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,7 +286,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
|
|||
* The name of the item for which the path is requested. Ignored for
|
||||
* $type 'core'.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The path to the requested item or an empty string if the item is not found.
|
||||
*/
|
||||
function drupal_get_path($type, $name) {
|
||||
|
@ -329,7 +349,7 @@ function t($string, array $args = [], array $options = []) {
|
|||
* @see https://www.drupal.org/node/2302363
|
||||
*/
|
||||
function format_string($string, array $args) {
|
||||
return SafeMarkup::format($string, $args);
|
||||
return new FormattableMarkup($string, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -457,30 +477,18 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
|
|||
*
|
||||
* @see drupal_get_messages()
|
||||
* @see status-messages.html.twig
|
||||
* @see https://www.drupal.org/node/2774931
|
||||
*
|
||||
* @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
|
||||
*/
|
||||
function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) {
|
||||
@trigger_error('drupal_set_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. See https://www.drupal.org/node/2774931', E_USER_DEPRECATED);
|
||||
$messenger = \Drupal::messenger();
|
||||
if (isset($message)) {
|
||||
if (!isset($_SESSION['messages'][$type])) {
|
||||
$_SESSION['messages'][$type] = [];
|
||||
}
|
||||
|
||||
// Convert strings which are safe to the simplest Markup objects.
|
||||
if (!($message instanceof Markup) && $message instanceof MarkupInterface) {
|
||||
$message = Markup::create((string) $message);
|
||||
}
|
||||
|
||||
// Do not use strict type checking so that equivalent string and
|
||||
// MarkupInterface objects are detected.
|
||||
if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
|
||||
$_SESSION['messages'][$type][] = $message;
|
||||
}
|
||||
|
||||
// Mark this page as being uncacheable.
|
||||
\Drupal::service('page_cache_kill_switch')->trigger();
|
||||
$messenger->addMessage($message, $type, $repeat);
|
||||
}
|
||||
|
||||
// Messages not set when DB connection fails.
|
||||
return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
|
||||
return $messenger->all();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -507,12 +515,19 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE)
|
|||
*
|
||||
* @see drupal_set_message()
|
||||
* @see status-messages.html.twig
|
||||
* @see https://www.drupal.org/node/2774931
|
||||
*
|
||||
* @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Messenger\MessengerInterface::all() or
|
||||
* \Drupal\Core\Messenger\MessengerInterface::messagesByType() instead.
|
||||
*/
|
||||
function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
|
||||
if ($messages = drupal_set_message()) {
|
||||
@trigger_error('drupal_get_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface::all() or \Drupal\Core\Messenger\MessengerInterface::messagesByType() instead. See https://www.drupal.org/node/2774931', E_USER_DEPRECATED);
|
||||
$messenger = \Drupal::messenger();
|
||||
if ($messages = $messenger->all()) {
|
||||
if ($type) {
|
||||
if ($clear_queue) {
|
||||
unset($_SESSION['messages'][$type]);
|
||||
$messenger->deleteByType($type);
|
||||
}
|
||||
if (isset($messages[$type])) {
|
||||
return [$type => $messages[$type]];
|
||||
|
@ -520,7 +535,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
|
|||
}
|
||||
else {
|
||||
if ($clear_queue) {
|
||||
unset($_SESSION['messages']);
|
||||
$messenger->deleteAll();
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
|
@ -530,6 +545,9 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function drupal_get_user_timezone() {
|
||||
$user = \Drupal::currentUser();
|
||||
|
@ -554,14 +572,14 @@ function drupal_get_user_timezone() {
|
|||
* @param $message
|
||||
* The error message.
|
||||
* @param $filename
|
||||
* The filename that the error was raised in.
|
||||
* (optional) The filename that the error was raised in.
|
||||
* @param $line
|
||||
* The line number the error was raised at.
|
||||
* (optional) The line number the error was raised at.
|
||||
* @param $context
|
||||
* An array that points to the active symbol table at the point the error
|
||||
* occurred.
|
||||
* (optional) An array that points to the active symbol table at the point the
|
||||
* error occurred.
|
||||
*/
|
||||
function _drupal_error_handler($error_level, $message, $filename, $line, $context) {
|
||||
function _drupal_error_handler($error_level, $message, $filename = NULL, $line = NULL, $context = NULL) {
|
||||
require_once __DIR__ . '/errors.inc';
|
||||
_drupal_error_handler_real($error_level, $message, $filename, $line, $context);
|
||||
}
|
||||
|
@ -778,12 +796,6 @@ function drupal_get_profile() {
|
|||
else {
|
||||
$profile = BootstrapConfigStorageFactory::getDatabaseStorage()->read('core.extension')['profile'];
|
||||
}
|
||||
|
||||
// A BC layer just in in case this only exists in Settings. Introduced in
|
||||
// Drupal 8.3.x and will be removed before Drupal 9.0.0.
|
||||
if (empty($profile)) {
|
||||
$profile = Settings::get('install_profile');
|
||||
}
|
||||
}
|
||||
|
||||
return $profile;
|
||||
|
@ -909,7 +921,7 @@ function drupal_classloader_register($name, $path) {
|
|||
* internally and should not be passed in; use drupal_static_reset() instead.
|
||||
* (This function's return value should not be used when TRUE is passed in.)
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* Returns a variable by reference.
|
||||
*
|
||||
* @see drupal_static_reset()
|
||||
|
@ -963,10 +975,10 @@ function drupal_static_reset($name = NULL) {
|
|||
* Formats text for emphasized display in a placeholder inside a sentence.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\Component\Utility\SafeMarkup::format() 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.
|
||||
* \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
|
||||
*/
|
||||
|
@ -980,12 +992,12 @@ function drupal_placeholder($text) {
|
|||
* Wrapper for register_shutdown_function() that catches thrown exceptions to
|
||||
* avoid "Exception thrown without a stack frame in Unknown".
|
||||
*
|
||||
* @param $callback
|
||||
* @param callable $callback
|
||||
* The shutdown function to register.
|
||||
* @param ...
|
||||
* Additional arguments to pass to the shutdown function.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* Array of shutdown functions to be executed.
|
||||
*
|
||||
* @see register_shutdown_function()
|
||||
|
@ -1021,8 +1033,12 @@ function _drupal_shutdown_function() {
|
|||
chdir(DRUPAL_ROOT);
|
||||
|
||||
try {
|
||||
while (list($key, $callback) = each($callbacks)) {
|
||||
reset($callbacks);
|
||||
// Do not use foreach() here because it is possible that the callback will
|
||||
// add to the $callbacks array via drupal_register_shutdown_function().
|
||||
while ($callback = current($callbacks)) {
|
||||
call_user_func_array($callback['callback'], $callback['arguments']);
|
||||
next($callbacks);
|
||||
}
|
||||
}
|
||||
// PHP 7 introduces Throwable, which covers both Error and
|
||||
|
|
|
@ -17,7 +17,6 @@ use Drupal\Core\Cache\Cache;
|
|||
use Drupal\Core\Render\Element\Link;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\Core\PhpStorage\PhpStorageFactory;
|
||||
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\Render\Element;
|
||||
|
@ -47,7 +46,7 @@ use Drupal\Core\Render\Element;
|
|||
*
|
||||
* Correct:
|
||||
* @code
|
||||
* $my_substring = Unicode::substr($original_string, 0, 5);
|
||||
* $my_substring = mb_substr($original_string, 0, 5);
|
||||
* @endcode
|
||||
*
|
||||
* @}
|
||||
|
@ -148,12 +147,13 @@ const LOCALE_PLURAL_DELIMITER = PluralTranslatableMarkup::DELIMITER;
|
|||
* If the query parameter isn't present, then the URL of the current
|
||||
* request is returned.
|
||||
*
|
||||
* @see \Drupal\Core\EventSubscriber\RedirectResponseSubscriber::checkRedirectUrl()
|
||||
*
|
||||
* @ingroup form_api
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
|
||||
* Use the redirect.destination service.
|
||||
*
|
||||
* @see \Drupal\Core\EventSubscriber\RedirectResponseSubscriber::checkRedirectUrl()
|
||||
* @see https://www.drupal.org/node/2448603
|
||||
*/
|
||||
function drupal_get_destination() {
|
||||
return \Drupal::destination()->getAsArray();
|
||||
|
@ -176,6 +176,8 @@ function drupal_get_destination() {
|
|||
*
|
||||
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal::service('email.validator')->isValid().
|
||||
*
|
||||
* @see https://www.drupal.org/node/2912661
|
||||
*/
|
||||
function valid_email_address($mail) {
|
||||
return \Drupal::service('email.validator')->isValid($mail);
|
||||
|
@ -209,17 +211,18 @@ function valid_email_address($mail) {
|
|||
* Drupal\Core\Template\Attribute, call
|
||||
* \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() instead.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols()
|
||||
* @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
|
||||
* Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol()
|
||||
* instead. UrlHelper::stripDangerousProtocols() can be used in conjunction
|
||||
* with \Drupal\Component\Utility\SafeMarkup::format() and an @variable
|
||||
* with \Drupal\Component\Render\FormattableMarkup and an @variable
|
||||
* placeholder which will perform the necessary escaping.
|
||||
* UrlHelper::filterBadProtocol() is functionality equivalent to check_url()
|
||||
* apart from the fact it is protected from double escaping bugs. Note that
|
||||
* this method no longer marks its output as safe.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols()
|
||||
* @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
|
||||
* @see https://www.drupal.org/node/2560027
|
||||
*/
|
||||
function check_url($uri) {
|
||||
return Html::escape(UrlHelper::stripDangerousProtocols($uri));
|
||||
|
@ -252,7 +255,8 @@ function format_size($size, $langcode = NULL) {
|
|||
return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', [], ['langcode' => $langcode]);
|
||||
}
|
||||
else {
|
||||
$size = $size / Bytes::KILOBYTE; // Convert bytes to kilobytes.
|
||||
// Convert bytes to kilobytes.
|
||||
$size = $size / Bytes::KILOBYTE;
|
||||
$units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
foreach ($units as $unit) {
|
||||
if (round($size, 2) >= Bytes::KILOBYTE) {
|
||||
|
@ -314,10 +318,11 @@ function format_size($size, $langcode = NULL) {
|
|||
* @return
|
||||
* A translated date string in the requested format.
|
||||
*
|
||||
* @see \Drupal\Core\Datetime\DateFormatter::format()
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal::service('date.formatter')->format().
|
||||
*
|
||||
* @see \Drupal\Core\Datetime\DateFormatter::format()
|
||||
* @see https://www.drupal.org/node/1876852
|
||||
*/
|
||||
function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
|
||||
return \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode);
|
||||
|
@ -403,8 +408,8 @@ function drupal_set_time_limit($time_limit) {
|
|||
/**
|
||||
* Returns the base URL path (i.e., directory) of the Drupal installation.
|
||||
*
|
||||
* base_path() adds a "/" to the beginning and end of the returned path if the
|
||||
* path is not empty. At the very least, this will return "/".
|
||||
* Function base_path() adds a "/" to the beginning and end of the returned path
|
||||
* if the path is not empty. At the very least, this will return "/".
|
||||
*
|
||||
* Examples:
|
||||
* - http://example.com returns "/" because the path is empty.
|
||||
|
@ -419,6 +424,8 @@ function base_path() {
|
|||
*
|
||||
* @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
|
||||
* Use \Drupal\Core\Asset\AssetCollectionOptimizerInterface::deleteAll().
|
||||
*
|
||||
* @see https://www.drupal.org/node/2317841
|
||||
*/
|
||||
function drupal_clear_css_cache() {
|
||||
\Drupal::service('asset.css.collection_optimizer')->deleteAll();
|
||||
|
@ -600,7 +607,7 @@ function drupal_process_states(&$elements) {
|
|||
* 'id' => 'my-module-table',
|
||||
* ),
|
||||
* );
|
||||
* return drupal_render($table);
|
||||
* return \Drupal::service('renderer')->render($table);
|
||||
* @endcode
|
||||
*
|
||||
* In the theme function for the form, a special class must be added to each
|
||||
|
@ -708,7 +715,7 @@ function drupal_attach_tabledrag(&$element, array $options) {
|
|||
'subgroup' => NULL,
|
||||
'source' => NULL,
|
||||
'hidden' => TRUE,
|
||||
'limit' => 0
|
||||
'limit' => 0,
|
||||
];
|
||||
|
||||
$group = $options['group'];
|
||||
|
@ -736,6 +743,8 @@ function drupal_attach_tabledrag(&$element, array $options) {
|
|||
*
|
||||
* @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
|
||||
* Use \Drupal\Core\Asset\AssetCollectionOptimizerInterface::deleteAll().
|
||||
*
|
||||
* @see https://www.drupal.org/node/2317841
|
||||
*/
|
||||
function drupal_clear_js_cache() {
|
||||
\Drupal::service('asset.js.collection_optimizer')->deleteAll();
|
||||
|
@ -853,6 +862,7 @@ function drupal_pre_render_links($element) {
|
|||
* 'renderer' service instead.
|
||||
*
|
||||
* @see \Drupal\Core\Render\RendererInterface::renderRoot()
|
||||
* @see https://www.drupal.org/node/2912696
|
||||
*/
|
||||
function drupal_render_root(&$elements) {
|
||||
return \Drupal::service('renderer')->renderRoot($elements);
|
||||
|
@ -865,6 +875,7 @@ function drupal_render_root(&$elements) {
|
|||
* 'renderer' service instead.
|
||||
*
|
||||
* @see \Drupal\Core\Render\RendererInterface::render()
|
||||
* @see https://www.drupal.org/node/2912696
|
||||
*/
|
||||
function drupal_render(&$elements, $is_recursive_call = FALSE) {
|
||||
return \Drupal::service('renderer')->render($elements, $is_recursive_call);
|
||||
|
@ -887,7 +898,8 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
|
|||
* rendering when possible or loop through the elements and render them as
|
||||
* they are available.
|
||||
*
|
||||
* @see drupal_render()
|
||||
* @see \Drupal\Core\Render\RendererInterface::render()
|
||||
* @see https://www.drupal.org/node/2912757
|
||||
*/
|
||||
function drupal_render_children(&$element, $children_keys = NULL) {
|
||||
if ($children_keys === NULL) {
|
||||
|
@ -896,7 +908,7 @@ function drupal_render_children(&$element, $children_keys = NULL) {
|
|||
$output = '';
|
||||
foreach ($children_keys as $key) {
|
||||
if (!empty($element[$key])) {
|
||||
$output .= drupal_render($element[$key]);
|
||||
$output .= \Drupal::service('renderer')->render($element[$key]);
|
||||
}
|
||||
}
|
||||
return Markup::create($output);
|
||||
|
@ -1001,6 +1013,8 @@ function show(&$element) {
|
|||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal::service('element_info')->getInfo() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2235461
|
||||
*/
|
||||
function element_info($type) {
|
||||
return \Drupal::service('element_info')->getInfo($type);
|
||||
|
@ -1019,6 +1033,8 @@ function element_info($type) {
|
|||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal::service('element_info')->getInfoProperty() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2235461
|
||||
*/
|
||||
function element_info_property($type, $property_name, $default = NULL) {
|
||||
return \Drupal::service('element_info')->getInfoProperty($type, $property_name, $default);
|
||||
|
@ -1100,7 +1116,7 @@ function drupal_flush_all_caches() {
|
|||
\Drupal::service('kernel')->invalidateContainer();
|
||||
|
||||
// Wipe the Twig PHP Storage cache.
|
||||
PhpStorageFactory::get('twig')->deleteAll();
|
||||
\Drupal::service('twig')->invalidate();
|
||||
|
||||
// Rebuild module and theme data.
|
||||
$module_data = system_rebuild_module_data();
|
||||
|
@ -1111,7 +1127,6 @@ function drupal_flush_all_caches() {
|
|||
// to reset the theme manager.
|
||||
\Drupal::theme()->resetActiveTheme();
|
||||
|
||||
|
||||
// Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not
|
||||
// sufficient, since the list of enabled modules might have been adjusted
|
||||
// above due to changed code.
|
||||
|
@ -1244,7 +1259,7 @@ function archiver_get_extensions() {
|
|||
*/
|
||||
function archiver_get_archiver($file) {
|
||||
// Archivers can only work on local paths
|
||||
$filepath = drupal_realpath($file);
|
||||
$filepath = \Drupal::service('file_system')->realpath($file);
|
||||
if (!is_file($filepath)) {
|
||||
throw new Exception(t('Archivers can only operate on local files: %file not supported', ['%file' => $file]));
|
||||
}
|
||||
|
|
|
@ -335,6 +335,7 @@ function db_transaction($name = NULL, array $options = []) {
|
|||
* \Drupal\Core\Database\Database::setActiveConnection().
|
||||
*/
|
||||
function db_set_active($key = 'default') {
|
||||
@trigger_error('db_set_active() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\Database::setActiveConnection() instead. See https://www.drupal.org/node/2944084.', E_USER_DEPRECATED);
|
||||
return Database::setActiveConnection($key);
|
||||
}
|
||||
|
||||
|
@ -644,6 +645,11 @@ function db_index_exists($table, $name) {
|
|||
* @see \Drupal\Core\Database\Schema::tableExists()
|
||||
*/
|
||||
function db_table_exists($table) {
|
||||
@trigger_error(
|
||||
'db_table_exists() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use $injected_database->schema()->tableExists($table) instead. See https://www.drupal.org/node/2947929.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
return Database::getConnection()->schema()->tableExists($table);
|
||||
}
|
||||
|
||||
|
@ -722,6 +728,7 @@ function db_rename_table($table, $new_name) {
|
|||
* @see \Drupal\Core\Database\Schema::dropTable()
|
||||
*/
|
||||
function db_drop_table($table) {
|
||||
@trigger_error('db_drop_table() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\Database::getConnection()->schema()->dropTable() instead. See https://www.drupal.org/node/2987737', E_USER_DEPRECATED);
|
||||
return Database::getConnection()->schema()->dropTable($table);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,9 +67,9 @@ function entity_get_bundles($entity_type = NULL) {
|
|||
* \Drupal\node\Entity\Node::load() if the entity type is known. If the
|
||||
* entity type is variable, use the entity manager service to load the entity
|
||||
* from the entity storage:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->load($id);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->load($id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::load()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
|
@ -100,11 +100,11 @@ function entity_load($entity_type, $id, $reset = FALSE) {
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's loadRevision() method to load a specific entity
|
||||
* revision:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->loadRevision($revision_id);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->loadRevision($revision_id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadRevision()
|
||||
|
@ -127,11 +127,11 @@ function entity_revision_load($entity_type, $revision_id) {
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's deleteRevision() method to delete a specific entity
|
||||
* revision:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->deleteRevision($revision_id);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->deleteRevision($revision_id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::deleteRevision()
|
||||
|
@ -175,9 +175,9 @@ function entity_revision_delete($entity_type, $revision_id) {
|
|||
* \Drupal\node\Entity\Node::loadMultiple() if the entity type is known. If
|
||||
* the entity type is variable, use the entity manager service to load the
|
||||
* entity from the entity storage:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple($id);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple($id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::loadMultiple()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
|
@ -209,11 +209,11 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's loadByProperties() method to load an entity by their
|
||||
* property values:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->loadByProperties($values);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->loadByProperties($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadByProperties()
|
||||
|
@ -242,9 +242,9 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
|
|||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's loadUnchanged() method to load an unchanged entity:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->loadUnchanged($id);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->loadUnchanged($id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadUnchanged()
|
||||
|
@ -265,11 +265,11 @@ function entity_load_unchanged($entity_type, $id) {
|
|||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's delete() method to delete multiple entities:
|
||||
* @code
|
||||
* $storage_handler = \Drupal::entityTypeManager()->getStorage($entity_type);
|
||||
* $entities = $storage_handler->loadMultiple($ids);
|
||||
* $storage_handler->delete($entities);
|
||||
* @endcode
|
||||
* @code
|
||||
* $storage_handler = \Drupal::entityTypeManager()->getStorage($entity_type);
|
||||
* $entities = $storage_handler->loadMultiple($ids);
|
||||
* $storage_handler->delete($entities);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadMultiple()
|
||||
|
@ -298,9 +298,9 @@ function entity_delete_multiple($entity_type, array $ids) {
|
|||
* \Drupal\node\Entity\Node::create() if the entity type is known. If the
|
||||
* entity type is variable, use the entity storage's create() method to
|
||||
* construct a new entity:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->create($values);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->create($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
|
@ -326,9 +326,9 @@ function entity_create($entity_type, array $values = []) {
|
|||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity's label() method to get the label of the entity:
|
||||
* @code
|
||||
* $entity->label($langcode);
|
||||
* @endcode
|
||||
* @code
|
||||
* $entity->label($langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::label()
|
||||
*/
|
||||
|
@ -355,11 +355,11 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
|
|||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* Use the entity view builder's view() method for creating a render array:
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityTypeManager()
|
||||
* ->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->view($entity, $view_mode, $langcode);
|
||||
* @endcode
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityTypeManager()
|
||||
* ->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->view($entity, $view_mode, $langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::view()
|
||||
|
@ -393,11 +393,11 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* Use the entity view builder's viewMultiple() method for creating a render
|
||||
* array for the provided entities:
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityTypeManager()
|
||||
* ->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->viewMultiple($entities, $view_mode, $langcode);
|
||||
* @endcode
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityTypeManager()
|
||||
* ->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->viewMultiple($entities, $view_mode, $langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewMultiple()
|
||||
|
@ -531,24 +531,24 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
|
|||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* If the entity form display is available in configuration use:
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_form_display')
|
||||
* ->load($entity_type . '.' . $bundle . '.' . $form_mode);
|
||||
* @endcode
|
||||
* @code
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_form_display')
|
||||
* ->load($entity_type . '.' . $bundle . '.' . $form_mode);
|
||||
* @endcode
|
||||
* When the entity form display is not available in configuration, you can
|
||||
* create a new EntityFormDisplay object using:
|
||||
* @code
|
||||
* $values = array(
|
||||
* 'targetEntityType' => $entity_type,
|
||||
* 'bundle' => $bundle,
|
||||
* 'mode' => $form_mode,
|
||||
* 'status' => TRUE,
|
||||
* );
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_form_display')
|
||||
* ->create($values);
|
||||
* @endcode
|
||||
* @code
|
||||
* $values = array(
|
||||
* 'targetEntityType' => $entity_type,
|
||||
* 'bundle' => $bundle,
|
||||
* 'mode' => $form_mode,
|
||||
* 'status' => TRUE,
|
||||
* );
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_form_display')
|
||||
* ->create($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::load()
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Functions for error handling.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Render\Markup;
|
||||
|
@ -83,6 +83,19 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
|
|||
'@backtrace_string' => (new \Exception())->getTraceAsString(),
|
||||
], $recoverable || $to_string);
|
||||
}
|
||||
// If the site is a test site then fail for user deprecations so they can be
|
||||
// caught by the deprecation error handler.
|
||||
elseif (DRUPAL_TEST_IN_CHILD_SITE && $error_level === E_USER_DEPRECATED) {
|
||||
$backtrace = debug_backtrace();
|
||||
$caller = Error::getLastCaller($backtrace);
|
||||
_drupal_error_header(
|
||||
Markup::create(Xss::filterAdmin($message)),
|
||||
'User deprecated function',
|
||||
$caller['function'],
|
||||
$caller['file'],
|
||||
$caller['line']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,25 +149,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
// When running inside the testing framework, we relay the errors
|
||||
// to the tested site by the way of HTTP headers.
|
||||
if (DRUPAL_TEST_IN_CHILD_SITE && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
|
||||
// $number does not use drupal_static as it should not be reset
|
||||
// as it uniquely identifies each PHP error.
|
||||
static $number = 0;
|
||||
$assertion = [
|
||||
$error['@message'],
|
||||
$error['%type'],
|
||||
[
|
||||
'function' => $error['%function'],
|
||||
'file' => $error['%file'],
|
||||
'line' => $error['%line'],
|
||||
],
|
||||
];
|
||||
// For non-fatal errors (e.g. PHP notices) _drupal_log_error can be called
|
||||
// multiple times per request. In that case the response is typically
|
||||
// generated outside of the error handler, e.g., in a controller. As a
|
||||
// result it is not possible to use a Response object here but instead the
|
||||
// headers need to be emitted directly.
|
||||
header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
|
||||
$number++;
|
||||
_drupal_error_header($error['@message'], $error['%type'], $error['%function'], $error['%file'], $error['%line']);
|
||||
}
|
||||
|
||||
$response = new Response();
|
||||
|
@ -164,7 +159,8 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
// installer.
|
||||
if (\Drupal::hasService('logger.factory')) {
|
||||
try {
|
||||
\Drupal::logger('php')->log($error['severity_level'], '%type: @message in %function (line %line of %file) @backtrace_string.', $error);
|
||||
// Provide the PHP backtrace to logger implementations.
|
||||
\Drupal::logger('php')->log($error['severity_level'], '%type: @message in %function (line %line of %file) @backtrace_string.', $error + ['backtrace' => $backtrace]);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// We can't log, for example because the database connection is not
|
||||
|
@ -182,7 +178,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
if ($fatal) {
|
||||
// When called from CLI, simply output a plain text message.
|
||||
// Should not translate the string to avoid errors producing more errors.
|
||||
$response->setContent(html_entity_decode(strip_tags(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error))) . "\n");
|
||||
$response->setContent(html_entity_decode(strip_tags(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error))) . "\n");
|
||||
$response->send();
|
||||
exit;
|
||||
}
|
||||
|
@ -193,7 +189,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
if (error_displayable($error)) {
|
||||
// When called from JavaScript, simply output the error message.
|
||||
// Should not translate the string to avoid errors producing more errors.
|
||||
$response->setContent(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error));
|
||||
$response->setContent(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error));
|
||||
$response->send();
|
||||
}
|
||||
exit;
|
||||
|
@ -230,10 +226,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
if ($error_level != ERROR_REPORTING_DISPLAY_VERBOSE) {
|
||||
// Without verbose logging, use a simple message.
|
||||
|
||||
// We call SafeMarkup::format() directly here, rather than use t() since
|
||||
// we are in the middle of error handling, and we don't want t() to
|
||||
// cause further errors.
|
||||
$message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error);
|
||||
// We use \Drupal\Component\Render\FormattableMarkup directly here,
|
||||
// rather than use t() since we are in the middle of error handling, and
|
||||
// we don't want t() to cause further errors.
|
||||
$message = new FormattableMarkup('%type: @message in %function (line %line of %file).', $error);
|
||||
}
|
||||
else {
|
||||
// With verbose logging, we will also include a backtrace.
|
||||
|
@ -245,7 +241,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
array_shift($backtrace);
|
||||
// Generate a backtrace containing only scalar argument values.
|
||||
$error['@backtrace'] = Error::formatBacktrace($backtrace);
|
||||
$message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
|
||||
$message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +272,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
if ($message) {
|
||||
if (\Drupal::hasService('session')) {
|
||||
// Message display is dependent on sessions being available.
|
||||
drupal_set_message($message, $class, TRUE);
|
||||
\Drupal::messenger()->addMessage($message, $class, TRUE);
|
||||
}
|
||||
else {
|
||||
print $message;
|
||||
|
@ -324,3 +320,39 @@ function _drupal_get_error_level() {
|
|||
// request on a public site, so use the non-verbose default value.
|
||||
return $error_level ?: ERROR_REPORTING_DISPLAY_ALL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds error information to headers so that tests can access it.
|
||||
*
|
||||
* @param $message
|
||||
* The error message.
|
||||
* @param $type
|
||||
* The type of error.
|
||||
* @param $function
|
||||
* The function that emitted the error.
|
||||
* @param $file
|
||||
* The file that emitted the error.
|
||||
* @param $line
|
||||
* The line number in file that emitted the error.
|
||||
*/
|
||||
function _drupal_error_header($message, $type, $function, $file, $line) {
|
||||
// $number does not use drupal_static as it should not be reset
|
||||
// as it uniquely identifies each PHP error.
|
||||
static $number = 0;
|
||||
$assertion = [
|
||||
$message,
|
||||
$type,
|
||||
[
|
||||
'function' => $function,
|
||||
'file' => $file,
|
||||
'line' => $line,
|
||||
],
|
||||
];
|
||||
// For non-fatal errors (e.g. PHP notices) _drupal_log_error can be called
|
||||
// multiple times per request. In that case the response is typically
|
||||
// generated outside of the error handler, e.g., in a controller. As a
|
||||
// result it is not possible to use a Response object here but instead the
|
||||
// headers need to be emitted directly.
|
||||
header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
|
||||
$number++;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
use Drupal\Component\FileSystem\FileSystem as ComponentFileSystem;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Component\PhpStorage\FileStorage;
|
||||
use Drupal\Component\Utility\Bytes;
|
||||
|
@ -100,7 +99,6 @@ function file_stream_wrapper_valid_scheme($scheme) {
|
|||
return \Drupal::service('file_system')->validScheme($scheme);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the part of a URI after the schema.
|
||||
*
|
||||
|
@ -202,7 +200,7 @@ function file_create_url($uri) {
|
|||
// HTTP and to https://example.com/bar.jpg when viewing a HTTPS page)
|
||||
// Both types of relative URIs are characterized by a leading slash, hence
|
||||
// we can use a single check.
|
||||
if (Unicode::substr($uri, 0, 1) == '/') {
|
||||
if (mb_substr($uri, 0, 1) == '/') {
|
||||
return $uri;
|
||||
}
|
||||
else {
|
||||
|
@ -270,7 +268,7 @@ function file_url_transform_relative($file_url) {
|
|||
$http_host = $host . ':' . $port;
|
||||
}
|
||||
|
||||
return preg_replace('|^https?://' . $http_host . '|', '', $file_url);
|
||||
return preg_replace('|^https?://' . preg_quote($http_host, '|') . '|', '', $file_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,8 +460,9 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
|
|||
}
|
||||
// Attempt to resolve the URIs. This is necessary in certain configurations
|
||||
// (see above).
|
||||
$real_source = drupal_realpath($source) ?: $source;
|
||||
$real_destination = drupal_realpath($destination) ?: $destination;
|
||||
$file_system = \Drupal::service('file_system');
|
||||
$real_source = $file_system->realpath($source) ?: $source;
|
||||
$real_destination = $file_system->realpath($destination) ?: $destination;
|
||||
// Perform the copy operation.
|
||||
if (!@copy($real_source, $real_destination)) {
|
||||
\Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', ['%file' => $source, '%destination' => $destination]);
|
||||
|
@ -507,12 +506,14 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
|
|||
function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_EXISTS_RENAME) {
|
||||
$original_source = $source;
|
||||
$logger = \Drupal::logger('file');
|
||||
$file_system = \Drupal::service('file_system');
|
||||
|
||||
// Assert that the source file actually exists.
|
||||
if (!file_exists($source)) {
|
||||
// @todo Replace drupal_set_message() calls with exceptions instead.
|
||||
drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', ['%file' => $original_source]), 'error');
|
||||
if (($realpath = drupal_realpath($original_source)) !== FALSE) {
|
||||
// @todo Replace \Drupal::messenger()->addError() calls with exceptions
|
||||
// instead.
|
||||
\Drupal::messenger()->addError(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', ['%file' => $original_source]));
|
||||
if (($realpath = $file_system->realpath($original_source)) !== FALSE) {
|
||||
$logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', ['%file' => $original_source, '%realpath' => $realpath]);
|
||||
}
|
||||
else {
|
||||
|
@ -526,7 +527,6 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
|
|||
$destination = file_build_uri(drupal_basename($source));
|
||||
}
|
||||
|
||||
|
||||
// Prepare the destination directory.
|
||||
if (file_prepare_directory($destination)) {
|
||||
// The destination is already a directory, so append the source basename.
|
||||
|
@ -538,7 +538,7 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
|
|||
if (!file_prepare_directory($dirname)) {
|
||||
// The destination is not valid.
|
||||
$logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', ['%file' => $original_source, '%destination' => $dirname]);
|
||||
drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', ['%file' => $original_source]), 'error');
|
||||
\Drupal::messenger()->addError(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', ['%file' => $original_source]));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -546,16 +546,16 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
|
|||
// Determine whether we can perform this operation based on overwrite rules.
|
||||
$destination = file_destination($destination, $replace);
|
||||
if ($destination === FALSE) {
|
||||
drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', ['%file' => $original_source]), 'error');
|
||||
\Drupal::messenger()->addError(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', ['%file' => $original_source]));
|
||||
$logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', ['%file' => $original_source, '%destination' => $destination]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Assert that the source and destination filenames are not the same.
|
||||
$real_source = drupal_realpath($source);
|
||||
$real_destination = drupal_realpath($destination);
|
||||
$real_source = $file_system->realpath($source);
|
||||
$real_destination = $file_system->realpath($destination);
|
||||
if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) {
|
||||
drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', ['%file' => $source]), 'error');
|
||||
\Drupal::messenger()->addError(t('The specified file %file was not moved/copied because it would overwrite itself.', ['%file' => $source]));
|
||||
$logger->notice('File %file could not be moved/copied because it would overwrite itself.', ['%file' => $source]);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -653,8 +653,9 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
|
|||
}
|
||||
// Attempt to resolve the URIs. This is necessary in certain configurations
|
||||
// (see above) and can also permit fast moves across local schemes.
|
||||
$real_source = drupal_realpath($source) ?: $source;
|
||||
$real_destination = drupal_realpath($destination) ?: $destination;
|
||||
$file_system = \Drupal::service('file_system');
|
||||
$real_source = $file_system->realpath($source) ?: $source;
|
||||
$real_destination = $file_system->realpath($destination) ?: $destination;
|
||||
// Perform the move operation.
|
||||
if (!@rename($real_source, $real_destination)) {
|
||||
// Fall back to slow copy and unlink procedure. This is necessary for
|
||||
|
@ -696,8 +697,8 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
|
|||
* @param $extensions
|
||||
* A space-separated list of extensions that should not be altered.
|
||||
* @param $alerts
|
||||
* If TRUE, drupal_set_message() will be called to display a message if the
|
||||
* file name was changed.
|
||||
* If TRUE, \Drupal::messenger()->addStatus() will be called to display
|
||||
* a message if the file name was changed.
|
||||
*
|
||||
* @return string
|
||||
* The potentially modified $filename.
|
||||
|
@ -716,8 +717,10 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
|
|||
// Split the filename up by periods. The first part becomes the basename
|
||||
// the last part the final extension.
|
||||
$filename_parts = explode('.', $filename);
|
||||
$new_filename = array_shift($filename_parts); // Remove file basename.
|
||||
$final_extension = array_pop($filename_parts); // Remove final extension.
|
||||
// Remove file basename.
|
||||
$new_filename = array_shift($filename_parts);
|
||||
// Remove final extension.
|
||||
$final_extension = array_pop($filename_parts);
|
||||
|
||||
// Loop through the middle parts of the name and add an underscore to the
|
||||
// end of each section that could be a file extension but isn't in the list
|
||||
|
@ -731,7 +734,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
|
|||
$filename = $new_filename . '.' . $final_extension;
|
||||
|
||||
if ($alerts && $original != $filename) {
|
||||
drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', ['%filename' => $filename]));
|
||||
\Drupal::messenger()->addStatus(t('For security reasons, your upload has been renamed to %filename.', ['%filename' => $filename]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -891,7 +894,7 @@ function file_unmanaged_delete($path) {
|
|||
*
|
||||
* @param $path
|
||||
* A string containing either an URI or a file or directory path.
|
||||
* @param $callback
|
||||
* @param callable $callback
|
||||
* (optional) Callback function to run on each file prior to deleting it and
|
||||
* on each directory prior to traversing it. For example, can be used to
|
||||
* modify permissions.
|
||||
|
@ -922,8 +925,6 @@ function file_unmanaged_delete_recursive($path, $callback = NULL) {
|
|||
return file_unmanaged_delete($path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Moves an uploaded file to a new location.
|
||||
*
|
||||
|
@ -966,7 +967,7 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
|
|||
// Write the data to a temporary file.
|
||||
$temp_name = drupal_tempnam('temporary://', 'file');
|
||||
if (file_put_contents($temp_name, $data) === FALSE) {
|
||||
drupal_set_message(t('The file could not be created.'), 'error');
|
||||
\Drupal::messenger()->addError(t('The file could not be created.'));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1032,7 @@ function file_scan_directory($dir, $mask, $options = [], $depth = 0) {
|
|||
// performance boost.
|
||||
if (!isset($options['nomask'])) {
|
||||
$ignore_directories = Settings::get('file_scan_ignore_directories', []);
|
||||
array_walk($ignore_directories, function(&$value) {
|
||||
array_walk($ignore_directories, function (&$value) {
|
||||
$value = preg_quote($value, '/');
|
||||
});
|
||||
$default_nomask = '/^' . implode('|', $ignore_directories) . '$/';
|
||||
|
|
|
@ -235,13 +235,13 @@ function template_preprocess_fieldset(&$variables) {
|
|||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - element: An associative array containing the properties of the element.
|
||||
* Properties used: #attributes, #children, #open,
|
||||
* #description, #id, #title, #value, #optional.
|
||||
* Properties used: #attributes, #children, #description, #required,
|
||||
* #summary_attributes, #title, #value.
|
||||
*/
|
||||
function template_preprocess_details(&$variables) {
|
||||
$element = $variables['element'];
|
||||
$variables['attributes'] = $element['#attributes'];
|
||||
$variables['summary_attributes'] = new Attribute();
|
||||
$variables['summary_attributes'] = new Attribute($element['#summary_attributes']);
|
||||
if (!empty($element['#title'])) {
|
||||
$variables['summary_attributes']['role'] = 'button';
|
||||
if (!empty($element['#attributes']['id'])) {
|
||||
|
@ -251,6 +251,11 @@ function template_preprocess_details(&$variables) {
|
|||
$variables['summary_attributes']['aria-pressed'] = $variables['summary_attributes']['aria-expanded'];
|
||||
}
|
||||
$variables['title'] = (!empty($element['#title'])) ? $element['#title'] : '';
|
||||
// If the element title is a string, wrap it a render array so that markup
|
||||
// will not be escaped (but XSS-filtered).
|
||||
if (is_string($variables['title']) && $variables['title'] !== '') {
|
||||
$variables['title'] = ['#markup' => $variables['title']];
|
||||
}
|
||||
$variables['description'] = (!empty($element['#description'])) ? $element['#description'] : '';
|
||||
$variables['children'] = (isset($element['#children'])) ? $element['#children'] : '';
|
||||
$variables['value'] = (isset($element['#value'])) ? $element['#value'] : '';
|
||||
|
@ -370,12 +375,13 @@ function template_preprocess_form(&$variables) {
|
|||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - element: An associative array containing the properties of the element.
|
||||
* Properties used: #title, #value, #description, #rows, #cols,
|
||||
* #placeholder, #required, #attributes, #resizable
|
||||
* Properties used: #title, #value, #description, #rows, #cols, #maxlength,
|
||||
* #placeholder, #required, #attributes, #resizable.
|
||||
*/
|
||||
function template_preprocess_textarea(&$variables) {
|
||||
$element = $variables['element'];
|
||||
Element::setAttributes($element, ['id', 'name', 'rows', 'cols', 'placeholder']);
|
||||
$attributes = ['id', 'name', 'rows', 'cols', 'maxlength', 'placeholder'];
|
||||
Element::setAttributes($element, $attributes);
|
||||
RenderElement::setAttributes($element, ['form-textarea']);
|
||||
$variables['wrapper_attributes'] = new Attribute();
|
||||
$variables['attributes'] = new Attribute($element['#attributes']);
|
||||
|
@ -638,7 +644,7 @@ function template_preprocess_form_element_label(&$variables) {
|
|||
* else {
|
||||
* $message = t('Finished with an error.');
|
||||
* }
|
||||
* drupal_set_message($message);
|
||||
* \Drupal::messenger()->addMessage($message);
|
||||
* // Providing data for the redirected page is done through $_SESSION.
|
||||
* foreach ($results as $result) {
|
||||
* $items[] = t('Loaded node %title.', array('%title' => $result));
|
||||
|
@ -786,8 +792,8 @@ function batch_set($batch_definition) {
|
|||
* is omitted and no redirect response was returned by the 'finished'
|
||||
* callback. Any query arguments will be automatically persisted.
|
||||
* @param \Drupal\Core\Url $url
|
||||
* (optional - should only be used for separate scripts like update.php)
|
||||
* URL of the batch processing page.
|
||||
* (optional) URL of the batch processing page. Should only be used for
|
||||
* separate scripts like update.php.
|
||||
* @param $redirect_callback
|
||||
* (optional) Specify a function to be called to redirect to the progressive
|
||||
* processing page.
|
||||
|
|
|
@ -6,13 +6,18 @@
|
|||
*/
|
||||
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Batch\BatchBuilder;
|
||||
use Drupal\Core\Config\ConfigImporter;
|
||||
use Drupal\Core\Config\ConfigImporterException;
|
||||
use Drupal\Core\Config\Importer\ConfigImporterBatch;
|
||||
use Drupal\Core\Config\FileStorage;
|
||||
use Drupal\Core\Config\StorageComparer;
|
||||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Database\DatabaseExceptionWrapper;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Installer\Exception\AlreadyInstalledException;
|
||||
use Drupal\Core\Installer\Exception\InstallerException;
|
||||
use Drupal\Core\Installer\Exception\InstallProfileMismatchException;
|
||||
use Drupal\Core\Installer\Exception\NoProfilesException;
|
||||
use Drupal\Core\Installer\InstallerKernel;
|
||||
use Drupal\Core\Language\Language;
|
||||
|
@ -89,10 +94,13 @@ const INSTALL_TASK_RUN_IF_NOT_COMPLETED = 3;
|
|||
* page request (optimized for the command line) and not send any output
|
||||
* intended for the web browser. See install_state_defaults() for a list of
|
||||
* elements that are allowed to appear in this array.
|
||||
* @param callable $callback
|
||||
* (optional) A callback to allow command line processes to update a progress
|
||||
* bar. The callback is passed the $install_state variable.
|
||||
*
|
||||
* @see install_state_defaults()
|
||||
*/
|
||||
function install_drupal($class_loader, $settings = []) {
|
||||
function install_drupal($class_loader, $settings = [], callable $callback = NULL) {
|
||||
// Support the old way of calling this function with just a settings array.
|
||||
// @todo Remove this when Drush is updated in the Drupal testing
|
||||
// infrastructure in https://www.drupal.org/node/2389243
|
||||
|
@ -114,7 +122,7 @@ function install_drupal($class_loader, $settings = []) {
|
|||
install_begin_request($class_loader, $install_state);
|
||||
// Based on the installation state, run the remaining tasks for this page
|
||||
// request, and collect any output.
|
||||
$output = install_run_tasks($install_state);
|
||||
$output = install_run_tasks($install_state, $callback);
|
||||
}
|
||||
catch (InstallerException $e) {
|
||||
// In the non-interactive installer, exceptions are always thrown directly.
|
||||
|
@ -135,6 +143,9 @@ function install_drupal($class_loader, $settings = []) {
|
|||
$state = $install_state;
|
||||
if (!empty($install_state['installation_finished'])) {
|
||||
unset($GLOBALS['install_state']);
|
||||
// If installation is finished ensure any further container rebuilds do not
|
||||
// use the installer's service provider.
|
||||
unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']);
|
||||
}
|
||||
|
||||
// All available tasks for this page request are now complete. Interactive
|
||||
|
@ -157,7 +168,11 @@ function install_drupal($class_loader, $settings = []) {
|
|||
}
|
||||
elseif ($state['installation_finished']) {
|
||||
// Redirect to the newly installed site.
|
||||
install_goto('');
|
||||
$finish_url = '';
|
||||
if (isset($install_state['profile_info']['distribution']['install']['finish_url'])) {
|
||||
$finish_url = $install_state['profile_info']['distribution']['install']['finish_url'];
|
||||
}
|
||||
install_goto($finish_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,6 +203,10 @@ function install_state_defaults() {
|
|||
// The last task that was completed during the previous installation
|
||||
// request.
|
||||
'completed_task' => NULL,
|
||||
// Partial configuration cached during an installation from existing config.
|
||||
'config' => NULL,
|
||||
// The path to the configuration to install when installing from config.
|
||||
'config_install_path' => NULL,
|
||||
// TRUE when there are valid config directories.
|
||||
'config_verified' => FALSE,
|
||||
// TRUE when there is a valid database connection.
|
||||
|
@ -282,6 +301,8 @@ function install_state_defaults() {
|
|||
* @param $install_state
|
||||
* An array of information about the current installation state. This is
|
||||
* modified with information gleaned from the beginning of the page request.
|
||||
*
|
||||
* @see install_drupal()
|
||||
*/
|
||||
function install_begin_request($class_loader, &$install_state) {
|
||||
$request = Request::createFromGlobals();
|
||||
|
@ -302,12 +323,6 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
// Allow command line scripts to override server variables used by Drupal.
|
||||
require_once __DIR__ . '/bootstrap.inc';
|
||||
|
||||
// Before having installed the system module and being able to do a module
|
||||
// rebuild, prime the drupal_get_filename() static cache with the module's
|
||||
// exact location.
|
||||
// @todo Remove as part of https://www.drupal.org/node/2186491
|
||||
drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml');
|
||||
|
||||
// If the hash salt leaks, it becomes possible to forge a valid testing user
|
||||
// agent, install a new copy of Drupal, and take over the original site.
|
||||
// The user agent header is used to pass a database prefix in the request when
|
||||
|
@ -318,8 +333,16 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
header($request->server->get('SERVER_PROTOCOL') . ' 403 Forbidden');
|
||||
exit;
|
||||
}
|
||||
if ($install_state['interactive'] && drupal_valid_test_ua()) {
|
||||
// Set the default timezone. While this doesn't cause any tests to fail, PHP
|
||||
// complains if 'date.timezone' is not set in php.ini. The Australia/Sydney
|
||||
// timezone is chosen so all tests are run using an edge case scenario
|
||||
// (UTC+10 and DST). This choice is made to prevent timezone related
|
||||
// regressions and reduce the fragility of the testing system in general.
|
||||
date_default_timezone_set('Australia/Sydney');
|
||||
}
|
||||
|
||||
$site_path = DrupalKernel::findSitePath($request, FALSE);
|
||||
$site_path = empty($install_state['site_path']) ? DrupalKernel::findSitePath($request, FALSE) : $install_state['site_path'];
|
||||
Settings::initialize(dirname(dirname(__DIR__)), $site_path, $class_loader);
|
||||
|
||||
// Ensure that procedural dependencies are loaded as early as possible,
|
||||
|
@ -406,10 +429,15 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
}
|
||||
else {
|
||||
$environment = 'prod';
|
||||
$GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\NormalInstallerServiceProvider';
|
||||
}
|
||||
$GLOBALS['conf']['container_service_providers']['InstallerConfigOverride'] = 'Drupal\Core\Installer\ConfigOverride';
|
||||
|
||||
// Only allow dumping the container once the hash salt has been created.
|
||||
$kernel = InstallerKernel::createFromRequest($request, $class_loader, $environment, (bool) Settings::get('hash_salt', FALSE));
|
||||
// Only allow dumping the container once the hash salt has been created. Note,
|
||||
// InstallerKernel::createFromRequest() is not used because Settings is
|
||||
// already initialized.
|
||||
$kernel = new InstallerKernel($environment, $class_loader, (bool) Settings::get('hash_salt', FALSE));
|
||||
$kernel::bootEnvironment();
|
||||
$kernel->setSitePath($site_path);
|
||||
$kernel->boot();
|
||||
$container = $kernel->getContainer();
|
||||
|
@ -435,6 +463,9 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
// Prime drupal_get_filename()'s static cache.
|
||||
foreach ($install_state['profiles'] as $name => $profile) {
|
||||
drupal_get_filename('profile', $name, $profile->getPathname());
|
||||
// drupal_get_filename() is called both with 'module' and 'profile', see
|
||||
// \Drupal\Core\Config\ConfigInstaller::getProfileStorages for example.
|
||||
drupal_get_filename('module', $name, $profile->getPathname());
|
||||
}
|
||||
|
||||
if ($profile = _install_select_profile($install_state)) {
|
||||
|
@ -445,9 +476,19 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
}
|
||||
}
|
||||
|
||||
// Use the language from the profile configuration, if available, to override
|
||||
// the language previously set in the parameters.
|
||||
if (isset($install_state['profile_info']['distribution']['langcode'])) {
|
||||
// Before having installed the system module and being able to do a module
|
||||
// rebuild, prime the drupal_get_filename() static cache with the system
|
||||
// module's location.
|
||||
// @todo Remove as part of https://www.drupal.org/node/2186491
|
||||
drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml');
|
||||
|
||||
// Use the language from profile configuration if available.
|
||||
if (!empty($install_state['config_install_path']) && $install_state['config']['system.site']) {
|
||||
$install_state['parameters']['langcode'] = $install_state['config']['system.site']['default_langcode'];
|
||||
}
|
||||
elseif (isset($install_state['profile_info']['distribution']['langcode'])) {
|
||||
// Otherwise, Use the language from the profile configuration, if available,
|
||||
// to override the language previously set in the parameters.
|
||||
$install_state['parameters']['langcode'] = $install_state['profile_info']['distribution']['langcode'];
|
||||
}
|
||||
|
||||
|
@ -519,11 +560,14 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
* @param $install_state
|
||||
* An array of information about the current installation state. This is
|
||||
* passed along to each task, so it can be modified if necessary.
|
||||
* @param callable $callback
|
||||
* (optional) A callback to allow command line processes to update a progress
|
||||
* bar. The callback is passed the $install_state variable.
|
||||
*
|
||||
* @return
|
||||
* HTML output from the last completed task.
|
||||
*/
|
||||
function install_run_tasks(&$install_state) {
|
||||
function install_run_tasks(&$install_state, callable $callback = NULL) {
|
||||
do {
|
||||
// Obtain a list of tasks to perform. The list of tasks itself can be
|
||||
// dynamic (e.g., some might be defined by the installation profile,
|
||||
|
@ -555,6 +599,9 @@ function install_run_tasks(&$install_state) {
|
|||
\Drupal::state()->set('install_task', $install_state['installation_finished'] ? 'done' : $task_name);
|
||||
}
|
||||
}
|
||||
if ($callback) {
|
||||
$callback($install_state);
|
||||
}
|
||||
// Stop when there are no tasks left. In the case of an interactive
|
||||
// installation, also stop if we have some output to send to the browser,
|
||||
// the URL parameters have changed, or an end to the page request was
|
||||
|
@ -754,8 +801,7 @@ 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_write_profile' => [],
|
||||
'install_verify_database_ready' => [
|
||||
'run' => $install_state['database_ready'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
|
||||
],
|
||||
|
@ -770,10 +816,8 @@ function install_tasks($install_state) {
|
|||
'display_name' => t('Install site'),
|
||||
'type' => 'batch',
|
||||
],
|
||||
'install_profile_themes' => [
|
||||
],
|
||||
'install_install_profile' => [
|
||||
],
|
||||
'install_profile_themes' => [],
|
||||
'install_install_profile' => [],
|
||||
'install_import_translations' => [
|
||||
'display_name' => t('Set up translations'),
|
||||
'display' => $needs_translations,
|
||||
|
@ -787,6 +831,30 @@ function install_tasks($install_state) {
|
|||
],
|
||||
];
|
||||
|
||||
if (!empty($install_state['config_install_path'])) {
|
||||
// The chosen profile indicates that rather than installing a new site, an
|
||||
// instance of the same site should be installed from the given
|
||||
// configuration.
|
||||
// That means we need to remove the steps installing the extensions and
|
||||
// replace them with a configuration synchronization step.
|
||||
unset($tasks['install_download_translation']);
|
||||
$key = array_search('install_profile_modules', array_keys($tasks), TRUE);
|
||||
unset($tasks['install_profile_modules']);
|
||||
unset($tasks['install_profile_themes']);
|
||||
unset($tasks['install_install_profile']);
|
||||
$config_tasks = [
|
||||
'install_config_import_batch' => [
|
||||
'display_name' => t('Install configuration'),
|
||||
'type' => 'batch',
|
||||
],
|
||||
'install_config_download_translations' => [],
|
||||
'install_config_revert_install_changes' => [],
|
||||
];
|
||||
$tasks = array_slice($tasks, 0, $key, TRUE) +
|
||||
$config_tasks +
|
||||
array_slice($tasks, $key, NULL, TRUE);
|
||||
}
|
||||
|
||||
// Now add any tasks defined by the installation profile.
|
||||
if (!empty($install_state['parameters']['profile'])) {
|
||||
// Load the profile install file, because it is not always loaded when
|
||||
|
@ -813,8 +881,7 @@ function install_tasks($install_state) {
|
|||
'type' => 'batch',
|
||||
'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
|
||||
],
|
||||
'install_finished' => [
|
||||
],
|
||||
'install_finished' => [],
|
||||
];
|
||||
|
||||
// Allow the installation profile to modify the full list of tasks.
|
||||
|
@ -1073,7 +1140,7 @@ function install_base_system(&$install_state) {
|
|||
|
||||
// Save the list of other modules to install for the upcoming tasks.
|
||||
// State can be set to the database now that system.module is installed.
|
||||
$modules = $install_state['profile_info']['dependencies'];
|
||||
$modules = $install_state['profile_info']['install'];
|
||||
|
||||
\Drupal::state()->set('install_profile_modules', array_diff($modules, ['system']));
|
||||
$install_state['base_system_verified'] = TRUE;
|
||||
|
@ -1203,12 +1270,19 @@ function install_select_profile(&$install_state) {
|
|||
/**
|
||||
* Determines the installation profile to use in the installer.
|
||||
*
|
||||
* A profile will be selected in the following order of conditions:
|
||||
* Depending on the context from which it's being called, this method
|
||||
* may be used to:
|
||||
* - Automatically select a profile under certain conditions.
|
||||
* - Indicate which profile has already been selected.
|
||||
* - Indicate that a profile still needs to be selected.
|
||||
*
|
||||
* A profile will be selected automatically if one of the following conditions
|
||||
* is met. They are checked in the given order:
|
||||
* - Only one profile is available.
|
||||
* - A specific profile name is requested in installation parameters:
|
||||
* - For interactive installations via request query parameters.
|
||||
* - For non-interactive installations via install_drupal() settings.
|
||||
* - A discovered profile that is a distribution. If multiple profiles are
|
||||
* - One of the available profiles is a distribution. If multiple profiles are
|
||||
* distributions, then the first discovered profile will be selected.
|
||||
* - Only one visible profile is available.
|
||||
*
|
||||
|
@ -1216,35 +1290,37 @@ function install_select_profile(&$install_state) {
|
|||
* The current installer state, containing a 'profiles' key, which is an
|
||||
* associative array of profiles with the machine-readable names as keys.
|
||||
*
|
||||
* @return
|
||||
* @return string|null
|
||||
* The machine-readable name of the selected profile or NULL if no profile was
|
||||
* selected.
|
||||
*
|
||||
* @see install_select_profile()
|
||||
*/
|
||||
function _install_select_profile(&$install_state) {
|
||||
// Don't need to choose profile if only one available.
|
||||
// If there is only one profile available it will always be the one selected.
|
||||
if (count($install_state['profiles']) == 1) {
|
||||
return key($install_state['profiles']);
|
||||
}
|
||||
// If a valid profile has already been selected, return the selection.
|
||||
if (!empty($install_state['parameters']['profile'])) {
|
||||
$profile = $install_state['parameters']['profile'];
|
||||
if (isset($install_state['profiles'][$profile])) {
|
||||
return $profile;
|
||||
}
|
||||
}
|
||||
// Check for a distribution profile.
|
||||
// If any of the profiles are distribution profiles, return the first one.
|
||||
foreach ($install_state['profiles'] as $profile) {
|
||||
$profile_info = install_profile_info($profile->getName());
|
||||
if (!empty($profile_info['distribution'])) {
|
||||
return $profile->getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Get all visible (not hidden) profiles.
|
||||
$visible_profiles = array_filter($install_state['profiles'], function ($profile) {
|
||||
$profile_info = install_profile_info($profile->getName());
|
||||
return !isset($profile_info['hidden']) || !$profile_info['hidden'];
|
||||
});
|
||||
|
||||
// If there is only one visible profile, return it.
|
||||
if (count($visible_profiles) == 1) {
|
||||
return (key($visible_profiles));
|
||||
}
|
||||
|
@ -1375,7 +1451,7 @@ function install_download_translation(&$install_state) {
|
|||
*/
|
||||
function install_retrieve_file($uri, $destination) {
|
||||
$parsed_url = parse_url($uri);
|
||||
if (is_dir(drupal_realpath($destination))) {
|
||||
if (is_dir(\Drupal::service('file_system')->realpath($destination))) {
|
||||
// Prevent URIs with triple slashes when gluing parts together.
|
||||
$path = str_replace('///', '//', "$destination/") . drupal_basename($parsed_url['path']);
|
||||
}
|
||||
|
@ -1420,7 +1496,7 @@ function install_check_localization_server($uri) {
|
|||
*
|
||||
* @param string $version
|
||||
* Version info string (e.g., 8.0.0, 8.1.0, 8.0.0-dev, 8.0.0-unstable1,
|
||||
* 8.0.0-alpha2, 8.0.0-beta3, and 8.0.0-rc4).
|
||||
* 8.0.0-alpha2, 8.0.0-beta3, 8.6.x, and 8.0.0-rc4).
|
||||
*
|
||||
* @return array
|
||||
* Associative array of version info:
|
||||
|
@ -1438,7 +1514,7 @@ function _install_get_version_info($version) {
|
|||
\. # .
|
||||
(?P<minor>[0-9]+) # Minor release number.
|
||||
\. # .
|
||||
(?P<patch>[0-9]+) # Patch release number.
|
||||
(?P<patch>[0-9]+|x) # Patch release number.
|
||||
) #
|
||||
( #
|
||||
- # - separator for "extra" version information.
|
||||
|
@ -1461,9 +1537,24 @@ function _install_get_version_info($version) {
|
|||
* profile information will be added here.
|
||||
*/
|
||||
function install_load_profile(&$install_state) {
|
||||
global $config_directories;
|
||||
$profile = $install_state['parameters']['profile'];
|
||||
$install_state['profiles'][$profile]->load();
|
||||
$install_state['profile_info'] = install_profile_info($profile, isset($install_state['parameters']['langcode']) ? $install_state['parameters']['langcode'] : 'en');
|
||||
|
||||
if (!empty($install_state['parameters']['existing_config']) && !empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
|
||||
$install_state['config_install_path'] = $config_directories[CONFIG_SYNC_DIRECTORY];
|
||||
}
|
||||
// If the profile has a config/sync directory copy the information to the
|
||||
// install_state global.
|
||||
elseif (!empty($install_state['profile_info']['config_install_path'])) {
|
||||
$install_state['config_install_path'] = $install_state['profile_info']['config_install_path'];
|
||||
}
|
||||
|
||||
if (!empty($install_state['config_install_path'])) {
|
||||
$sync = new FileStorage($install_state['config_install_path']);
|
||||
$install_state['config']['system.site'] = $sync->read('system.site');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1710,6 +1801,9 @@ function _install_prepare_import($langcodes, $server_pattern) {
|
|||
];
|
||||
\Drupal::service('locale.project')->set($data['name'], $data);
|
||||
module_load_include('compare.inc', 'locale');
|
||||
// Reset project information static cache so that it uses the data
|
||||
// set above.
|
||||
locale_translation_clear_cache_projects();
|
||||
locale_translation_check_projects_local(['drupal'], [$langcode]);
|
||||
}
|
||||
}
|
||||
|
@ -1788,7 +1882,7 @@ function install_finished(&$install_state) {
|
|||
$success_message = t('Congratulations, you installed @drupal!', [
|
||||
'@drupal' => drupal_install_profile_distribution_name(),
|
||||
]);
|
||||
drupal_set_message($success_message);
|
||||
\Drupal::messenger()->addStatus($success_message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1810,10 +1904,11 @@ function _install_module_batch($module, $module_name, &$context) {
|
|||
* @param string $server_pattern
|
||||
* Server access pattern (to replace language code, version number, etc. in).
|
||||
*
|
||||
* @return array
|
||||
* @return array|null
|
||||
* Requirements compliance array. If the translation was downloaded
|
||||
* successfully then an empty array is returned. Otherwise the requirements
|
||||
* error with detailed information.
|
||||
* error with detailed information. NULL if the file already exists for this
|
||||
* language code.
|
||||
*/
|
||||
function install_check_translations($langcode, $server_pattern) {
|
||||
$requirements = [];
|
||||
|
@ -1844,10 +1939,19 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
return;
|
||||
}
|
||||
|
||||
$version = \Drupal::VERSION;
|
||||
// For dev releases, remove the '-dev' part and trust the translation server
|
||||
// to fall back to the latest stable release for that branch.
|
||||
// @see locale_translation_build_projects()
|
||||
if (preg_match("/^(\d+\.\d+\.).*-dev$/", $version, $matches)) {
|
||||
// Example match: 8.0.0-dev => 8.0.x (Drupal core)
|
||||
$version = $matches[1] . 'x';
|
||||
}
|
||||
|
||||
// Build URL for the translation file and the translation server.
|
||||
$variables = [
|
||||
'%project' => 'drupal',
|
||||
'%version' => \Drupal::VERSION,
|
||||
'%version' => $version,
|
||||
'%core' => \Drupal::CORE_COMPATIBILITY,
|
||||
'%language' => $langcode,
|
||||
];
|
||||
|
@ -1872,7 +1976,7 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
}
|
||||
}
|
||||
|
||||
// If the translations directory does not exists, throw an error.
|
||||
// If the translations directory does not exist, throw an error.
|
||||
if (!$translations_directory_exists) {
|
||||
$requirements['translations directory exists'] = [
|
||||
'title' => t('Translations directory'),
|
||||
|
@ -2010,7 +2114,7 @@ function install_check_requirements($install_state) {
|
|||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', [
|
||||
'@drupal' => drupal_install_profile_distribution_name(),
|
||||
'%default-file' => $default_file
|
||||
'%default-file' => $default_file,
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
@ -2071,7 +2175,7 @@ function install_check_requirements($install_state) {
|
|||
'@drupal' => drupal_install_profile_distribution_name(),
|
||||
'%file' => $file,
|
||||
'%default_file' => $default_file,
|
||||
':install_txt' => base_path() . 'core/INSTALL.txt'
|
||||
':install_txt' => base_path() . 'core/INSTALL.txt',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
@ -2089,7 +2193,7 @@ function install_check_requirements($install_state) {
|
|||
'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,
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
@ -2102,7 +2206,7 @@ function install_check_requirements($install_state) {
|
|||
'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,
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
@ -2122,7 +2226,7 @@ function install_check_requirements($install_state) {
|
|||
'%file' => $file,
|
||||
'%default_file' => $default_file,
|
||||
':install_txt' => base_path() . 'core/INSTALL.txt',
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
@ -2196,16 +2300,16 @@ function install_display_requirements($install_state, $requirements) {
|
|||
*
|
||||
* @see _install_select_profile()
|
||||
*
|
||||
* @throws \Drupal\Core\Installer\Exception\InstallProfileMismatchException
|
||||
*
|
||||
* @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. The
|
||||
* install profile is written to core.extension.
|
||||
*/
|
||||
function install_write_profile($install_state) {
|
||||
// Only need to write to settings.php if it is possible. The primary storage
|
||||
// for the install profile is the core.extension configuration.
|
||||
// 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)) {
|
||||
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'],
|
||||
|
@ -2213,7 +2317,135 @@ function install_write_profile($install_state) {
|
|||
];
|
||||
drupal_rewrite_settings($settings);
|
||||
}
|
||||
elseif (($settings_profile = Settings::get('install_profile')) && $settings_profile !== $install_state['parameters']['profile']) {
|
||||
throw new InstallProfileMismatchException($install_state['parameters']['profile'], $settings_profile, $settings_path, \Drupal::translation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a batch for the config importer to process.
|
||||
*
|
||||
* @see install_tasks()
|
||||
*/
|
||||
function install_config_import_batch() {
|
||||
// We need to manually trigger the installation of core-provided entity types,
|
||||
// as those will not be handled by the module installer.
|
||||
// @see install_profile_modules()
|
||||
install_core_entity_type_definitions();
|
||||
|
||||
// Get the sync storage.
|
||||
$sync = \Drupal::service('config.storage.sync');
|
||||
// Match up the site UUIDs, the install_base_system install task will have
|
||||
// installed the system module and created a new UUID.
|
||||
$system_site = $sync->read('system.site');
|
||||
\Drupal::configFactory()->getEditable('system.site')->set('uuid', $system_site['uuid'])->save();
|
||||
|
||||
// Create the storage comparer and the config importer.
|
||||
$config_manager = \Drupal::service('config.manager');
|
||||
$storage_comparer = new StorageComparer($sync, \Drupal::service('config.storage'), $config_manager);
|
||||
$storage_comparer->createChangelist();
|
||||
$config_importer = new ConfigImporter(
|
||||
$storage_comparer,
|
||||
\Drupal::service('event_dispatcher'),
|
||||
$config_manager,
|
||||
\Drupal::service('lock.persistent'),
|
||||
\Drupal::service('config.typed'),
|
||||
\Drupal::service('module_handler'),
|
||||
\Drupal::service('module_installer'),
|
||||
\Drupal::service('theme_handler'),
|
||||
\Drupal::service('string_translation')
|
||||
);
|
||||
|
||||
try {
|
||||
$sync_steps = $config_importer->initialize();
|
||||
|
||||
$batch_builder = new BatchBuilder();
|
||||
$batch_builder
|
||||
->setFinishCallback([ConfigImporterBatch::class, 'finish'])
|
||||
->setTitle(t('Importing configuration'))
|
||||
->setInitMessage(t('Starting configuration import.'))
|
||||
->setErrorMessage(t('Configuration import has encountered an error.'));
|
||||
|
||||
foreach ($sync_steps as $sync_step) {
|
||||
$batch_builder->addOperation([ConfigImporterBatch::class, 'process'], [$config_importer, $sync_step]);
|
||||
}
|
||||
|
||||
return $batch_builder->toArray();
|
||||
}
|
||||
catch (ConfigImporterException $e) {
|
||||
global $install_state;
|
||||
// There are validation errors.
|
||||
$messenger = \Drupal::messenger();
|
||||
$messenger->addError(t('The configuration synchronization failed validation.'));
|
||||
foreach ($config_importer->getErrors() as $message) {
|
||||
$messenger->addError($message);
|
||||
}
|
||||
install_display_output(['#title' => t('Configuration validation')], $install_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces install_download_translation() during configuration installs.
|
||||
*
|
||||
* @param array $install_state
|
||||
* An array of information about the current installation state.
|
||||
*
|
||||
* @return string
|
||||
* A themed status report, or an exception if there are requirement errors.
|
||||
* Upon successful download the page is reloaded and no output is returned.
|
||||
*
|
||||
* @see install_download_translation()
|
||||
*/
|
||||
function install_config_download_translations(&$install_state) {
|
||||
$needs_download = isset($install_state['parameters']['langcode']) && !isset($install_state['translations'][$install_state['parameters']['langcode']]) && $install_state['parameters']['langcode'] !== 'en';
|
||||
if ($needs_download) {
|
||||
return install_download_translation($install_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverts configuration if hook_install() implementations have made changes.
|
||||
*
|
||||
* This step ensures that the final configuration matches the configuration
|
||||
* provided to the installer.
|
||||
*/
|
||||
function install_config_revert_install_changes() {
|
||||
global $install_state;
|
||||
|
||||
$config_manager = \Drupal::service('config.manager');
|
||||
$storage_comparer = new StorageComparer(\Drupal::service('config.storage.sync'), \Drupal::service('config.storage'), $config_manager);
|
||||
$storage_comparer->createChangelist();
|
||||
if ($storage_comparer->hasChanges()) {
|
||||
$config_importer = new ConfigImporter(
|
||||
$storage_comparer,
|
||||
\Drupal::service('event_dispatcher'),
|
||||
$config_manager,
|
||||
\Drupal::service('lock.persistent'),
|
||||
\Drupal::service('config.typed'),
|
||||
\Drupal::service('module_handler'),
|
||||
\Drupal::service('module_installer'),
|
||||
\Drupal::service('theme_handler'),
|
||||
\Drupal::service('string_translation')
|
||||
);
|
||||
try {
|
||||
$config_importer->import();
|
||||
}
|
||||
catch (ConfigImporterException $e) {
|
||||
global $install_state;
|
||||
$messenger = \Drupal::messenger();
|
||||
// There are validation errors.
|
||||
$messenger->addError(t('The configuration synchronization failed validation.'));
|
||||
foreach ($config_importer->getErrors() as $message) {
|
||||
$messenger->addError($message);
|
||||
}
|
||||
install_display_output(['#title' => t('Configuration validation')], $install_state);
|
||||
}
|
||||
|
||||
// At this point the configuration should match completely.
|
||||
if (\Drupal::moduleHandler()->moduleExists('language')) {
|
||||
// If the English language exists at this point we need to ensure
|
||||
// install_download_additional_translations_operations() does not delete
|
||||
// it.
|
||||
if (ConfigurableLanguage::load('en')) {
|
||||
$install_state['profile_info']['keep_english'] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use Drupal\Component\Utility\Crypt;
|
|||
use Drupal\Component\Utility\OpCodeCache;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\Extension\ModuleHandler;
|
||||
use Drupal\Core\Site\Settings;
|
||||
|
||||
/**
|
||||
|
@ -114,9 +115,10 @@ function drupal_install_profile_distribution_name() {
|
|||
/**
|
||||
* Loads the installation profile, extracting its defined version.
|
||||
*
|
||||
* @return string Distribution version defined in the profile's .info.yml file.
|
||||
* Defaults to \Drupal::VERSION if no version is explicitly provided
|
||||
* by the installation profile.
|
||||
* @return string
|
||||
* Distribution version defined in the profile's .info.yml file.
|
||||
* Defaults to \Drupal::VERSION if no version is explicitly provided by the
|
||||
* installation profile.
|
||||
*
|
||||
* @see install_profile_info()
|
||||
*/
|
||||
|
@ -379,7 +381,6 @@ function _drupal_rewrite_settings_is_simple($type, $value) {
|
|||
return $is_integer || $is_float || $is_string || $is_boolean_or_null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper for drupal_rewrite_settings().
|
||||
*
|
||||
|
@ -450,7 +451,6 @@ function _drupal_rewrite_settings_dump($variable, $variable_name) {
|
|||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper for drupal_rewrite_settings().
|
||||
*
|
||||
|
@ -482,12 +482,20 @@ function _drupal_rewrite_settings_dump_one(\stdClass $variable, $prefix = '', $s
|
|||
* @see update_prepare_d8_bootstrap()
|
||||
*/
|
||||
function drupal_install_config_directories() {
|
||||
global $config_directories;
|
||||
global $config_directories, $install_state;
|
||||
|
||||
// Add a randomized config directory name to settings.php, unless it was
|
||||
// manually defined in the existing already.
|
||||
// If settings.php does not contain a config sync directory name we need to
|
||||
// configure one.
|
||||
if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
|
||||
$config_directories[CONFIG_SYNC_DIRECTORY] = \Drupal::service('site.path') . '/files/config_' . Crypt::randomBytesBase64(55) . '/sync';
|
||||
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,
|
||||
|
@ -530,8 +538,11 @@ function drupal_install_config_directories() {
|
|||
*
|
||||
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.x. Use
|
||||
* config_get_config_directory() and file_prepare_directory() 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 file_prepare_directory() 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])) {
|
||||
|
@ -570,7 +581,7 @@ function drupal_verify_profile($install_state) {
|
|||
$present_modules[] = $profile;
|
||||
|
||||
// Verify that all of the profile's required modules are present.
|
||||
$missing_modules = array_diff($info['dependencies'], $present_modules);
|
||||
$missing_modules = array_diff($info['install'], $present_modules);
|
||||
|
||||
$requirements = [];
|
||||
|
||||
|
@ -608,6 +619,8 @@ function drupal_verify_profile($install_state) {
|
|||
function drupal_install_system($install_state) {
|
||||
// Remove the service provider of the early installer.
|
||||
unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']);
|
||||
// Add the normal installer service provider.
|
||||
$GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\NormalInstallerServiceProvider';
|
||||
|
||||
$request = \Drupal::request();
|
||||
// Reboot into a full production environment to continue the installation.
|
||||
|
@ -618,6 +631,13 @@ function drupal_install_system($install_state) {
|
|||
$kernel->rebuildContainer(FALSE);
|
||||
$kernel->prepareLegacyRequest($request);
|
||||
|
||||
// Before having installed the system module and being able to do a module
|
||||
// rebuild, prime the \Drupal\Core\Extension\ModuleExtensionList static cache
|
||||
// with the module's location.
|
||||
// @todo Try to install system as any other module, see
|
||||
// https://www.drupal.org/node/2719315.
|
||||
\Drupal::service('extension.list.module')->setPathname('system', 'core/modules/system/system.info.yml');
|
||||
|
||||
// Install base system configuration.
|
||||
\Drupal::service('config.installer')->installDefaultConfig('core', 'core');
|
||||
|
||||
|
@ -649,11 +669,14 @@ function drupal_install_system($install_state) {
|
|||
* An optional bitmask created from various FILE_* constants.
|
||||
* @param $type
|
||||
* The type of file. Can be file (default), dir, or link.
|
||||
* @param bool $autofix
|
||||
* (optional) Determines whether to attempt fixing the permissions according
|
||||
* to the provided $mask. Defaults to TRUE.
|
||||
*
|
||||
* @return
|
||||
* TRUE on success or FALSE on failure. A message is set for the latter.
|
||||
*/
|
||||
function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
|
||||
function drupal_verify_install_file($file, $mask = NULL, $type = 'file', $autofix = TRUE) {
|
||||
$return = TRUE;
|
||||
// Check for files that shouldn't be there.
|
||||
if (isset($mask) && ($mask & FILE_NOT_EXIST) && file_exists($file)) {
|
||||
|
@ -675,7 +698,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
|
|||
switch ($current_mask) {
|
||||
case FILE_EXIST:
|
||||
if (!file_exists($file)) {
|
||||
if ($type == 'dir') {
|
||||
if ($type == 'dir' && $autofix) {
|
||||
drupal_install_mkdir($file, $mask);
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
|
@ -684,32 +707,32 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
|
|||
}
|
||||
break;
|
||||
case FILE_READABLE:
|
||||
if (!is_readable($file) && !drupal_install_fix_file($file, $mask)) {
|
||||
if (!is_readable($file)) {
|
||||
$return = FALSE;
|
||||
}
|
||||
break;
|
||||
case FILE_WRITABLE:
|
||||
if (!is_writable($file) && !drupal_install_fix_file($file, $mask)) {
|
||||
if (!is_writable($file)) {
|
||||
$return = FALSE;
|
||||
}
|
||||
break;
|
||||
case FILE_EXECUTABLE:
|
||||
if (!is_executable($file) && !drupal_install_fix_file($file, $mask)) {
|
||||
if (!is_executable($file)) {
|
||||
$return = FALSE;
|
||||
}
|
||||
break;
|
||||
case FILE_NOT_READABLE:
|
||||
if (is_readable($file) && !drupal_install_fix_file($file, $mask)) {
|
||||
if (is_readable($file)) {
|
||||
$return = FALSE;
|
||||
}
|
||||
break;
|
||||
case FILE_NOT_WRITABLE:
|
||||
if (is_writable($file) && !drupal_install_fix_file($file, $mask)) {
|
||||
if (is_writable($file)) {
|
||||
$return = FALSE;
|
||||
}
|
||||
break;
|
||||
case FILE_NOT_EXECUTABLE:
|
||||
if (is_executable($file) && !drupal_install_fix_file($file, $mask)) {
|
||||
if (is_executable($file)) {
|
||||
$return = FALSE;
|
||||
}
|
||||
break;
|
||||
|
@ -717,6 +740,9 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!$return && $autofix) {
|
||||
return drupal_install_fix_file($file, $mask);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -944,7 +970,7 @@ function drupal_check_profile($profile) {
|
|||
$drupal_root = \Drupal::root();
|
||||
$module_list = (new ExtensionDiscovery($drupal_root))->scan('module');
|
||||
|
||||
foreach ($info['dependencies'] as $module) {
|
||||
foreach ($info['install'] as $module) {
|
||||
// If the module is in the module list we know it exists and we can continue
|
||||
// including and registering it.
|
||||
// @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory()
|
||||
|
@ -965,6 +991,12 @@ function drupal_check_profile($profile) {
|
|||
}
|
||||
}
|
||||
|
||||
// Add the profile requirements.
|
||||
$function = $profile . '_requirements';
|
||||
if (function_exists($function)) {
|
||||
$requirements = array_merge($requirements, $function('install'));
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
|
@ -1009,7 +1041,7 @@ function drupal_check_module($module) {
|
|||
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']]);
|
||||
}
|
||||
drupal_set_message($message, 'error');
|
||||
\Drupal::messenger()->addError($message);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -1026,6 +1058,8 @@ function drupal_check_module($module) {
|
|||
* - description: A brief description of the profile.
|
||||
* - dependencies: An array of shortnames of other modules that this install
|
||||
* profile requires.
|
||||
* - install: An array of shortname of other modules to install that are not
|
||||
* required by this install profile.
|
||||
*
|
||||
* Additional, less commonly-used information that can appear in a
|
||||
* profile.info.yml file but not in a normal Drupal module .info.yml file
|
||||
|
@ -1043,6 +1077,8 @@ function drupal_check_module($module) {
|
|||
* - install: Optional parameters to override the installer:
|
||||
* - theme: The machine name of a theme to use in the installer instead of
|
||||
* Drupal's default installer theme.
|
||||
* - finish_url: A destination to visit after the installation of the
|
||||
* distribution is finished
|
||||
*
|
||||
* Note that this function does an expensive file system scan to get info file
|
||||
* information for dependencies. If you only need information from the info
|
||||
|
@ -1052,7 +1088,7 @@ function drupal_check_module($module) {
|
|||
* @code
|
||||
* name: Minimal
|
||||
* description: Start fresh, with only a few modules enabled.
|
||||
* dependencies:
|
||||
* install:
|
||||
* - block
|
||||
* - dblog
|
||||
* @endcode
|
||||
|
@ -1072,24 +1108,42 @@ function install_profile_info($profile, $langcode = 'en') {
|
|||
// Set defaults for module info.
|
||||
$defaults = [
|
||||
'dependencies' => [],
|
||||
'install' => [],
|
||||
'themes' => ['stark'],
|
||||
'description' => '',
|
||||
'version' => NULL,
|
||||
'hidden' => FALSE,
|
||||
'php' => DRUPAL_MINIMUM_PHP,
|
||||
'config_install_path' => NULL,
|
||||
];
|
||||
$profile_file = drupal_get_path('profile', $profile) . "/$profile.info.yml";
|
||||
$info = \Drupal::service('info_parser')->parse($profile_file);
|
||||
$profile_path = drupal_get_path('profile', $profile);
|
||||
$info = \Drupal::service('info_parser')->parse("$profile_path/$profile.info.yml");
|
||||
$info += $defaults;
|
||||
|
||||
// Convert dependencies in [project:module] format.
|
||||
$info['dependencies'] = array_map(function ($dependency) {
|
||||
return ModuleHandler::parseDependency($dependency)['name'];
|
||||
}, $info['dependencies']);
|
||||
|
||||
// Convert install key in [project:module] format.
|
||||
$info['install'] = array_map(function ($dependency) {
|
||||
return ModuleHandler::parseDependency($dependency)['name'];
|
||||
}, $info['install']);
|
||||
|
||||
// drupal_required_modules() includes the current profile as a dependency.
|
||||
// Remove that dependency, since a module cannot depend on itself.
|
||||
$required = array_diff(drupal_required_modules(), [$profile]);
|
||||
|
||||
$locale = !empty($langcode) && $langcode != 'en' ? ['locale'] : [];
|
||||
|
||||
$info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale));
|
||||
// Merge dependencies, required modules and locale into install list and
|
||||
// remove any duplicates.
|
||||
$info['install'] = array_unique(array_merge($info['install'], $required, $info['dependencies'], $locale));
|
||||
|
||||
// If the profile has a config/sync directory use that to install drupal.
|
||||
if (is_dir($profile_path . '/config/sync')) {
|
||||
$info['config_install_path'] = $profile_path . '/config/sync';
|
||||
}
|
||||
$cache[$profile][$langcode] = $info;
|
||||
}
|
||||
return $cache[$profile][$langcode];
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Render\Element;
|
||||
|
||||
|
||||
/**
|
||||
* Prepares variables for single local task link templates.
|
||||
*
|
||||
|
@ -37,7 +36,7 @@ function template_preprocess_menu_local_task(&$variables) {
|
|||
$variables['is_active'] = TRUE;
|
||||
|
||||
// Add text to indicate active tab for non-visual users.
|
||||
$active = SafeMarkup::format('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
|
||||
$active = new FormattableMarkup('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
|
||||
$link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]);
|
||||
}
|
||||
|
||||
|
@ -105,6 +104,7 @@ function menu_list_system_menus() {
|
|||
* tasks.
|
||||
*
|
||||
* @see hook_menu_local_tasks_alter()
|
||||
* @see https://www.drupal.org/node/2544940
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
|
||||
*/
|
||||
|
@ -117,6 +117,8 @@ function menu_local_tasks($level = 0) {
|
|||
/**
|
||||
* Returns the rendered local tasks at the top level.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2874695
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
|
||||
*/
|
||||
function menu_primary_local_tasks() {
|
||||
|
@ -130,6 +132,8 @@ function menu_primary_local_tasks() {
|
|||
/**
|
||||
* Returns the rendered local tasks at the second level.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2874695
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
|
||||
*/
|
||||
function menu_secondary_local_tasks() {
|
||||
|
@ -157,8 +161,14 @@ function menu_local_tabs() {
|
|||
*
|
||||
* 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, will be removed before 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ function system_list($type) {
|
|||
*/
|
||||
function system_list_reset() {
|
||||
drupal_static_reset('system_list');
|
||||
drupal_static_reset('system_rebuild_module_data');
|
||||
\Drupal::service('extension.list.module')->reset();
|
||||
\Drupal::cache('bootstrap')->delete('system_list');
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ function drupal_install_schema($module) {
|
|||
_drupal_schema_initialize($schema, $module, FALSE);
|
||||
|
||||
foreach ($schema as $name => $table) {
|
||||
db_create_table($name, $table);
|
||||
\Drupal::database()->schema()->createTable($name, $table);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,12 +130,12 @@ function drupal_install_schema($module) {
|
|||
* The module for which the tables will be removed.
|
||||
*/
|
||||
function drupal_uninstall_schema($module) {
|
||||
$schema = drupal_get_module_schema($module);
|
||||
_drupal_schema_initialize($schema, $module, FALSE);
|
||||
|
||||
foreach ($schema as $table) {
|
||||
if (db_table_exists($table['name'])) {
|
||||
db_drop_table($table['name']);
|
||||
$tables = drupal_get_module_schema($module);
|
||||
_drupal_schema_initialize($tables, $module, FALSE);
|
||||
$schema = \Drupal::database()->schema();
|
||||
foreach ($tables as $table) {
|
||||
if ($schema->tableExists($table['name'])) {
|
||||
$schema->dropTable($table['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRU
|
|||
}
|
||||
|
||||
/**
|
||||
* Typecasts values to proper datatypes.
|
||||
* Typecasts values to proper data types.
|
||||
*
|
||||
* MySQL PDO silently casts, e.g. FALSE and '' to 0, when inserting the value
|
||||
* into an integer column, but PostgreSQL PDO does not. Look up the schema
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* column.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
|
||||
|
@ -53,14 +53,14 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
|
|||
'#theme' => 'tablesort_indicator',
|
||||
'#style' => $ts['sort'],
|
||||
];
|
||||
$image = drupal_render($tablesort_indicator);
|
||||
$image = \Drupal::service('renderer')->render($tablesort_indicator);
|
||||
}
|
||||
else {
|
||||
// If the user clicks a different header, we want to sort ascending initially.
|
||||
$ts['sort'] = 'asc';
|
||||
$image = '';
|
||||
}
|
||||
$cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [
|
||||
$cell_content = \Drupal::l(new FormattableMarkup('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [
|
||||
'attributes' => ['title' => $title],
|
||||
'query' => array_merge($ts['query'], [
|
||||
'sort' => $ts['sort'],
|
||||
|
|
|
@ -12,7 +12,6 @@ use Drupal\Component\Serialization\Json;
|
|||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Config\StorageException;
|
||||
|
@ -240,8 +239,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
|
|||
// Match templates based on the 'template' filename.
|
||||
foreach ($cache as $hook => $info) {
|
||||
if (isset($info['template'])) {
|
||||
$template_candidates = [$info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template'])];
|
||||
if (in_array($template, $template_candidates)) {
|
||||
if ($template === $info['template']) {
|
||||
$implementations[$hook] = [
|
||||
'template' => $template,
|
||||
'path' => dirname($file->uri),
|
||||
|
@ -345,7 +343,8 @@ function theme_get_setting($setting_name, $theme = NULL) {
|
|||
|
||||
// Generate the path to the logo image.
|
||||
if ($cache[$theme]->get('logo.use_default')) {
|
||||
$cache[$theme]->set('logo.url', file_url_transform_relative(file_create_url($theme_object->getPath() . '/logo.svg')));
|
||||
$logo = \Drupal::service('theme.initialization')->getActiveThemeByName($theme)->getLogo();
|
||||
$cache[$theme]->set('logo.url', file_url_transform_relative(file_create_url($logo)));
|
||||
}
|
||||
elseif ($logo_path = $cache[$theme]->get('logo.path')) {
|
||||
$cache[$theme]->set('logo.url', file_url_transform_relative(file_create_url($logo_path)));
|
||||
|
@ -462,7 +461,7 @@ function theme_render_and_autoescape($arg) {
|
|||
*
|
||||
* @param array $theme_settings
|
||||
* An array of theme settings from system setting form or a Drupal 7 variable.
|
||||
* @param Config $config
|
||||
* @param \Drupal\Core\Config\Config $config
|
||||
* The configuration object to update.
|
||||
*
|
||||
* @return
|
||||
|
@ -486,7 +485,7 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config)
|
|||
$config->set('favicon.mimetype', $value);
|
||||
}
|
||||
elseif (substr($key, 0, 7) == 'toggle_') {
|
||||
$config->set('features.' . Unicode::substr($key, 7), $value);
|
||||
$config->set('features.' . mb_substr($key, 7), $value);
|
||||
}
|
||||
elseif (!in_array($key, ['theme', 'logo_upload'])) {
|
||||
$config->set($key, $value);
|
||||
|
@ -571,6 +570,11 @@ function template_preprocess_datetime_wrapper(&$variables) {
|
|||
|
||||
if (!empty($element['#title'])) {
|
||||
$variables['title'] = $element['#title'];
|
||||
// If the element title is a string, wrap it a render array so that markup
|
||||
// will not be escaped (but XSS-filtered).
|
||||
if (is_string($variables['title']) && $variables['title'] !== '') {
|
||||
$variables['title'] = ['#markup' => $variables['title']];
|
||||
}
|
||||
}
|
||||
|
||||
// Suppress error messages.
|
||||
|
@ -625,16 +629,12 @@ function template_preprocess_datetime_wrapper(&$variables) {
|
|||
* of links.
|
||||
* - set_active_class: (optional) Whether each link should compare the
|
||||
* route_name + route_parameters or href (path), language and query options
|
||||
* to the current URL, to determine whether the link is "active". If so, an
|
||||
* "active" class will be applied to the list item containing the link, as
|
||||
* well as the link itself. It is important to use this sparingly since it
|
||||
* is usually unnecessary and requires extra processing.
|
||||
* For anonymous users, the "active" class will be calculated on the server,
|
||||
* because most sites serve each anonymous user the same cached page anyway.
|
||||
* For authenticated users, the "active" class will be calculated on the
|
||||
* client (through JavaScript), only data- attributes are added to list
|
||||
* items and contained links, to prevent breaking the render cache. The
|
||||
* JavaScript is added in system_page_attachments().
|
||||
* to the current URL, to determine whether the link is "active". If so,
|
||||
* attributes will be added to the HTML elements for both the link and the
|
||||
* list item that contains it, which will result in an "is-active" class
|
||||
* being added to both. The class is added via JavaScript for authenticated
|
||||
* users (in the active-link library), and via PHP for anonymous users (in
|
||||
* the \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter class).
|
||||
* - heading: (optional) A heading to precede the links. May be an
|
||||
* associative array or a string. If it's an array, it can have the
|
||||
* following elements:
|
||||
|
@ -694,7 +694,16 @@ function template_preprocess_links(&$variables) {
|
|||
];
|
||||
|
||||
// Handle links and ensure that the active class is added on the LIs, but
|
||||
// only if the 'set_active_class' option is not empty.
|
||||
// only if the 'set_active_class' option is not empty. Links templates
|
||||
// duplicate the "is-active" class handling of l() and
|
||||
// LinkGenerator::generate() because they need to be able to set the
|
||||
// "is-active" class not on the links themselves (<a> tags), but on the
|
||||
// list items (<li> tags) that contain the links. This is necessary for
|
||||
// CSS to be able to style list items differently when the link is active,
|
||||
// since CSS does not yet allow one to style list items only if they
|
||||
// contain a certain element with a certain class. That is, we cannot yet
|
||||
// convert this jQuery selector to a CSS selector:
|
||||
// jQuery('li:has("a.is-active")')
|
||||
if (isset($link['url'])) {
|
||||
if (!empty($variables['set_active_class'])) {
|
||||
|
||||
|
@ -707,6 +716,8 @@ function template_preprocess_links(&$variables) {
|
|||
|
||||
// Add a "data-drupal-link-query" attribute to let the
|
||||
// drupal.active-link library know the query in a standardized manner.
|
||||
// Only add the data- attribute. The "is-active" class will be
|
||||
// calculated using JavaScript, to prevent breaking the render cache.
|
||||
if (!empty($link['query'])) {
|
||||
$query = $link['query'];
|
||||
ksort($query);
|
||||
|
@ -717,7 +728,10 @@ function template_preprocess_links(&$variables) {
|
|||
$url = $link['url'];
|
||||
if ($url->isRouted()) {
|
||||
// Add a "data-drupal-link-system-path" attribute to let the
|
||||
// drupal.active-link library know the path in a standardized manner.
|
||||
// drupal.active-link library know the path in a standardized
|
||||
// manner. Only add the data- attribute. The "is-active" class will
|
||||
// be calculated using JavaScript, to prevent breaking the render
|
||||
// cache.
|
||||
$system_path = $url->getInternalPath();
|
||||
// @todo System path is deprecated - use the route name and parameters.
|
||||
// Special case for the front page.
|
||||
|
@ -1191,10 +1205,9 @@ function template_preprocess_maintenance_task_list(&$variables) {
|
|||
/**
|
||||
* Adds a default set of helper variables for preprocessors and templates.
|
||||
*
|
||||
* This function is called for theme hooks implemented as templates only, not
|
||||
* for theme hooks implemented as functions. This preprocess function is the
|
||||
* first in the sequence of preprocessing functions that are called when
|
||||
* preparing variables for a template.
|
||||
* This function is called for every theme hook. It is the first in the
|
||||
* sequence of preprocessing functions called when preparing variables for a
|
||||
* template.
|
||||
*
|
||||
* See the @link themeable Default theme implementations topic @endlink for
|
||||
* details.
|
||||
|
@ -1358,9 +1371,9 @@ function template_preprocess_page(&$variables) {
|
|||
}
|
||||
}
|
||||
|
||||
$variables['base_path'] = base_path();
|
||||
$variables['front_page'] = \Drupal::url('<front>');
|
||||
$variables['language'] = $language_interface;
|
||||
$variables['base_path'] = base_path();
|
||||
$variables['front_page'] = \Drupal::url('<front>');
|
||||
$variables['language'] = $language_interface;
|
||||
|
||||
// An exception might be thrown.
|
||||
try {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* Theming for maintenance pages.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Site\Settings;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +28,6 @@ function _drupal_maintenance_theme() {
|
|||
require_once __DIR__ . '/file.inc';
|
||||
require_once __DIR__ . '/module.inc';
|
||||
require_once __DIR__ . '/database.inc';
|
||||
Unicode::check();
|
||||
|
||||
// Install and update pages are treated differently to prevent theming overrides.
|
||||
if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
|
||||
|
|
|
@ -10,7 +10,17 @@ use Drupal\Component\Utility\Unicode;
|
|||
/**
|
||||
* Returns Unicode library status and errors.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Moves unicode_requirements() logic to system_requirements().
|
||||
*
|
||||
* @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884698
|
||||
*/
|
||||
function unicode_requirements() {
|
||||
@trigger_error('unicode_requirements() is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. There is no replacement; system_requirements() now includes the logic instead. See https://www.drupal.org/node/2884698', E_USER_DEPRECATED);
|
||||
|
||||
$libraries = [
|
||||
Unicode::STATUS_SINGLEBYTE => t('Standard PHP'),
|
||||
Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'),
|
||||
|
|
|
@ -83,7 +83,7 @@ function update_system_schema_requirements() {
|
|||
$requirements['minimum schema'] += [
|
||||
'value' => 'The installed schema version does not meet the minimum.',
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must <a href="https://www.drupal.org/node/2179269">migrate your site to Drupal 8</a> first.',
|
||||
'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.',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -323,8 +323,7 @@ function update_get_update_list() {
|
|||
continue;
|
||||
}
|
||||
|
||||
$updates = array_combine($updates, $updates);
|
||||
foreach (array_keys($updates) as $update) {
|
||||
foreach ($updates as $update) {
|
||||
if ($update == \Drupal::CORE_MINIMUM_SCHEMA_VERSION) {
|
||||
$ret[$module]['warning'] = '<em>' . $module . '</em> module cannot be updated. It contains an update numbered as ' . \Drupal::CORE_MINIMUM_SCHEMA_VERSION . ' which is reserved for the earliest installation of a module in Drupal ' . \Drupal::CORE_COMPATIBILITY . ', before any updates. In order to update <em>' . $module . '</em> module, you will need to install a version of the module with valid updates.';
|
||||
continue 2;
|
||||
|
|
Reference in a new issue