updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ 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]));
}
}
+40 -44
View File
@@ -7,13 +7,13 @@
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\Test\TestDatabase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Utility\Error;
use Drupal\Core\StringTranslation\TranslatableMarkup;
@@ -235,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);
}
/**
@@ -347,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);
}
/**
@@ -794,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;
@@ -979,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
*/
+8 -9
View File
@@ -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
*
* @}
@@ -215,7 +214,7 @@ function valid_email_address($mail) {
* @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
@@ -409,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.
@@ -608,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
@@ -716,7 +715,7 @@ function drupal_attach_tabledrag(&$element, array $options) {
'subgroup' => NULL,
'source' => NULL,
'hidden' => TRUE,
'limit' => 0
'limit' => 0,
];
$group = $options['group'];
@@ -899,7 +898,7 @@ 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) {
@@ -1117,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();
+7
View 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);
}
+45 -45
View File
@@ -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()
+9 -9
View File
@@ -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;
@@ -178,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;
}
@@ -189,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;
@@ -226,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.
@@ -241,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);
}
}
@@ -272,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;
+12 -14
View File
@@ -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);
}
/**
@@ -512,8 +510,9 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
// 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');
// @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]);
}
@@ -539,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;
}
}
@@ -547,7 +546,7 @@ 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;
}
@@ -556,7 +555,7 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
$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;
}
@@ -698,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.
@@ -735,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]));
}
}
@@ -926,7 +925,6 @@ function file_unmanaged_delete_recursive($path, $callback = NULL) {
return file_unmanaged_delete($path);
}
/**
* Moves an uploaded file to a new location.
*
@@ -969,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;
}
+9 -4
View File
@@ -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'] : '';
@@ -639,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));
+252 -35
View File
@@ -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
@@ -327,7 +342,7 @@ function install_begin_request($class_loader, &$install_state) {
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,
@@ -414,11 +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();
@@ -444,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)) {
@@ -454,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'];
}
@@ -528,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,
@@ -564,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
@@ -793,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
@@ -1078,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;
@@ -1425,7 +1487,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:
@@ -1443,7 +1505,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.
@@ -1466,9 +1528,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');
}
}
/**
@@ -1715,6 +1792,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]);
}
}
@@ -1793,7 +1873,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);
}
/**
@@ -1850,10 +1930,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,
];
@@ -1878,7 +1967,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'),
@@ -2016,7 +2105,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,
]),
];
}
@@ -2077,7 +2166,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',
]),
];
}
@@ -2095,7 +2184,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',
]),
];
}
@@ -2108,7 +2197,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',
]),
];
}
@@ -2128,7 +2217,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',
]),
];
}
@@ -2202,16 +2291,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'],
@@ -2219,7 +2308,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;
}
}
}
}
+54 -21
View File
@@ -380,7 +380,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().
*
@@ -451,7 +450,6 @@ function _drupal_rewrite_settings_dump($variable, $variable_name) {
return $return;
}
/**
* Helper for drupal_rewrite_settings().
*
@@ -483,12 +481,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,
@@ -574,7 +580,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 = [];
@@ -612,6 +618,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.
@@ -622,6 +630,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');
@@ -653,11 +668,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)) {
@@ -679,7 +697,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)) {
@@ -688,32 +706,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;
@@ -721,6 +739,9 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
}
}
}
if (!$return && $autofix) {
return drupal_install_fix_file($file, $mask);
}
return $return;
}
@@ -948,7 +969,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()
@@ -1013,7 +1034,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;
@@ -1030,6 +1051,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
@@ -1047,6 +1070,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
@@ -1056,7 +1081,7 @@ function drupal_check_module($module) {
* @code
* name: Minimal
* description: Start fresh, with only a few modules enabled.
* dependencies:
* install:
* - block
* - dblog
* @endcode
@@ -1076,14 +1101,16 @@ 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;
// drupal_required_modules() includes the current profile as a dependency.
@@ -1092,8 +1119,14 @@ function install_profile_info($profile, $langcode = 'en') {
$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];
+8 -2
View File
@@ -10,7 +10,7 @@
* @{
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Render\Element;
/**
@@ -36,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]);
}
@@ -161,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();
}
+1 -1
View File
@@ -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');
}
+7 -7
View File
@@ -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
+2 -2
View File
@@ -9,7 +9,7 @@
* column.
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;
@@ -60,7 +60,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
$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'],
+33 -18
View File
@@ -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;
@@ -344,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)));
@@ -485,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);
@@ -570,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.
@@ -624,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:
@@ -693,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'])) {
@@ -706,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);
@@ -716,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.
@@ -1356,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 {
-2
View File
@@ -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')) {
+1
View File
@@ -10,6 +10,7 @@ use Drupal\Component\Utility\Unicode;
/**
* Returns Unicode library status and errors.
*/
/**
* Moves unicode_requirements() logic to system_requirements().
*