Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -47,14 +47,7 @@ function _batch_page(Request $request) {
|
|||
return new RedirectResponse(\Drupal::url('<front>', [], ['absolute' => TRUE]));
|
||||
}
|
||||
}
|
||||
// Restore safe strings from previous batches.
|
||||
// This is safe because we are passing through the known safe values from
|
||||
// SafeMarkup::getAll(). See _batch_shutdown().
|
||||
// @todo Ensure we are not storing an excessively large string list in:
|
||||
// https://www.drupal.org/node/2295823
|
||||
if (!empty($batch['safe_strings'])) {
|
||||
SafeMarkup::setMultiple($batch['safe_strings']);
|
||||
}
|
||||
|
||||
// Register database update for the end of processing.
|
||||
drupal_register_shutdown_function('_batch_shutdown');
|
||||
|
||||
|
@ -521,10 +514,6 @@ function _batch_finished() {
|
|||
*/
|
||||
function _batch_shutdown() {
|
||||
if ($batch = batch_get()) {
|
||||
// Update safe strings.
|
||||
// @todo Ensure we are not storing an excessively large string list in:
|
||||
// https://www.drupal.org/node/2295823
|
||||
$batch['safe_strings'] = SafeMarkup::getAll();
|
||||
\Drupal::service('batch.storage')->update($batch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use Drupal\Component\Utility\Unicode;
|
|||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\Utility\Error;
|
||||
|
@ -101,13 +102,27 @@ const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
|
|||
* $config_directories key for active directory.
|
||||
*
|
||||
* @see config_get_config_directory()
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Drupal core no
|
||||
* longer creates an active directory.
|
||||
*/
|
||||
const CONFIG_ACTIVE_DIRECTORY = 'active';
|
||||
|
||||
/**
|
||||
* $config_directories key for sync directory.
|
||||
*
|
||||
* @see config_get_config_directory()
|
||||
*/
|
||||
const CONFIG_SYNC_DIRECTORY = 'sync';
|
||||
|
||||
/**
|
||||
* $config_directories key for staging directory.
|
||||
*
|
||||
* @see config_get_config_directory()
|
||||
* @see CONFIG_SYNC_DIRECTORY
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x and will be removed before 9.0.0. The staging
|
||||
* directory was renamed to sync.
|
||||
*/
|
||||
const CONFIG_STAGING_DIRECTORY = 'staging';
|
||||
|
||||
|
@ -118,60 +133,29 @@ const CONFIG_STAGING_DIRECTORY = 'staging';
|
|||
*/
|
||||
define('DRUPAL_ROOT', dirname(dirname(__DIR__)));
|
||||
|
||||
/**
|
||||
* Returns the appropriate configuration directory.
|
||||
*
|
||||
* @param bool $require_settings
|
||||
* Only configuration directories with an existing settings.php file
|
||||
* will be recognized. Defaults to TRUE. During initial installation,
|
||||
* this is set to FALSE so that Drupal can detect a matching directory,
|
||||
* then create a new settings.php file in it.
|
||||
* @param bool $reset
|
||||
* Force a full search for matching directories even if one had been
|
||||
* found previously. Defaults to FALSE.
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* (optional) The current request. Defaults to \Drupal::request() or a new
|
||||
* request created from globals.
|
||||
*
|
||||
* @return string
|
||||
* The path of the matching directory.@see default.settings.php
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
|
||||
* Use \Drupal\Core\DrupalKernel::getSitePath() instead. If the kernel is
|
||||
* unavailable or the site path needs to be recalculated then
|
||||
* Drupal\Core\DrupalKernel::findSitePath() can be used.
|
||||
*/
|
||||
function conf_path($require_settings = TRUE, $reset = FALSE, Request $request = NULL) {
|
||||
if (!isset($request)) {
|
||||
if (\Drupal::hasRequest()) {
|
||||
$request = \Drupal::request();
|
||||
}
|
||||
// @todo Remove once external CLI scripts (Drush) are updated.
|
||||
else {
|
||||
$request = Request::createFromGlobals();
|
||||
}
|
||||
}
|
||||
if (\Drupal::hasService('kernel')) {
|
||||
$site_path = \Drupal::service('kernel')->getSitePath();
|
||||
}
|
||||
if (!isset($site_path) || empty($site_path)) {
|
||||
$site_path = DrupalKernel::findSitePath($request, $require_settings);
|
||||
}
|
||||
return $site_path;
|
||||
}
|
||||
/**
|
||||
* Returns the path of a configuration directory.
|
||||
*
|
||||
* Configuration directories are configured using $config_directories in
|
||||
* settings.php.
|
||||
*
|
||||
* @param string $type
|
||||
* (optional) The type of config directory to return. Drupal core provides
|
||||
* 'active' and 'staging'. Defaults to CONFIG_ACTIVE_DIRECTORY.
|
||||
* The type of config directory to return. Drupal core provides the
|
||||
* CONFIG_SYNC_DIRECTORY constant to access the sync directory.
|
||||
*
|
||||
* @return string
|
||||
* The configuration directory path.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
|
||||
function config_get_config_directory($type) {
|
||||
global $config_directories;
|
||||
|
||||
// @todo Remove fallback in Drupal 9. https://www.drupal.org/node/2574943
|
||||
if ($type == CONFIG_SYNC_DIRECTORY && !isset($config_directories[CONFIG_SYNC_DIRECTORY]) && isset($config_directories[CONFIG_STAGING_DIRECTORY])) {
|
||||
$type = CONFIG_STAGING_DIRECTORY;
|
||||
}
|
||||
|
||||
if (!empty($config_directories[$type])) {
|
||||
return $config_directories[$type];
|
||||
}
|
||||
|
@ -305,7 +289,7 @@ function drupal_get_path($type, $name) {
|
|||
* names or link URLs into translated text. Variable substitution looks like
|
||||
* this:
|
||||
* @code
|
||||
* $text = t("@name's blog", array('@name' => user_format_name($account)));
|
||||
* $text = t("@name's blog", array('@name' => $account->getDisplayName()));
|
||||
* @endcode
|
||||
* Basically, you can put variables like @name into your string, and t() will
|
||||
* substitute their sanitized values at translation time. (See the
|
||||
|
@ -435,7 +419,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
|
|||
* drupal_set_message(t('An error occurred and processing did not complete.'), 'error');
|
||||
* @endcode
|
||||
*
|
||||
* @param string|\Drupal\Component\Utility\SafeStringInterface $message
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $message
|
||||
* (optional) The translated message to be displayed to the user. For
|
||||
* consistency with other messages, it should begin with a capital letter and
|
||||
* end with a period.
|
||||
|
@ -482,13 +466,13 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE)
|
|||
$_SESSION['messages'][$type] = array();
|
||||
}
|
||||
|
||||
// Convert strings which are in the safe markup list to SafeString objects.
|
||||
if (is_string($message) && SafeMarkup::isSafe($message)) {
|
||||
$message = \Drupal\Core\Render\SafeString::create($message);
|
||||
// Convert strings which are safe to the simplest Markup objects.
|
||||
if (!($message instanceof Markup) && SafeMarkup::isSafe($message)) {
|
||||
$message = Markup::create((string) $message);
|
||||
}
|
||||
|
||||
// Do not use strict type checking so that equivalent string and
|
||||
// SafeStringInterface objects are detected.
|
||||
// MarkupInterface objects are detected.
|
||||
if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
|
||||
$_SESSION['messages'][$type][] = $message;
|
||||
}
|
||||
|
|
|
@ -22,9 +22,10 @@ use Drupal\Component\Utility\UrlHelper;
|
|||
use Drupal\Core\Asset\AttachedAssets;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Render\SafeString;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\Render\Renderer;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -32,6 +33,7 @@ use Drupal\Core\PhpStorage\PhpStorageFactory;
|
|||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Core\Routing\GeneratorNotInitializedException;
|
||||
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\Render\Element;
|
||||
|
@ -141,67 +143,11 @@ const JS_THEME = 100;
|
|||
/**
|
||||
* The delimiter used to split plural strings.
|
||||
*
|
||||
* This is the ETX (End of text) character and is used as a minimal means to
|
||||
* separate singular and plural variants in source and translation text. It
|
||||
* was found to be the most compatible delimiter for the supported databases.
|
||||
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\StringTranslation\PluralTranslatableMarkup::DELIMITER
|
||||
* instead.
|
||||
*/
|
||||
const LOCALE_PLURAL_DELIMITER = "\03";
|
||||
|
||||
/**
|
||||
* Adds output to the HEAD tag of the HTML page.
|
||||
*
|
||||
* This function can be called as long as the headers aren't sent. Pass no
|
||||
* arguments (or NULL for both) to retrieve the currently stored elements.
|
||||
*
|
||||
* @param $data
|
||||
* A renderable array. If the '#type' key is not set then 'html_tag' will be
|
||||
* added as the default '#type'.
|
||||
* @param $key
|
||||
* A unique string key to allow implementations of hook_html_head_alter() to
|
||||
* identify the element in $data. Required if $data is not NULL.
|
||||
*
|
||||
* @return
|
||||
* An array of all stored HEAD elements.
|
||||
*
|
||||
* @see \Drupal\Core\Render\Element\HtmlTag::preRenderHtmlTag()
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0
|
||||
* Use #attached on render arrays.
|
||||
*/
|
||||
function _drupal_add_html_head($data = NULL, $key = NULL) {
|
||||
$stored_head = &drupal_static(__FUNCTION__, array());
|
||||
|
||||
if (isset($data) && isset($key)) {
|
||||
if (!isset($data['#type'])) {
|
||||
$data['#type'] = 'html_tag';
|
||||
}
|
||||
$stored_head[$key] = $data;
|
||||
}
|
||||
return $stored_head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves output to be displayed in the HEAD tag of the HTML page.
|
||||
*
|
||||
* @param bool $render
|
||||
* If TRUE render the HEAD elements, otherwise return just the elements.
|
||||
*
|
||||
* @return string|array
|
||||
* Return the rendered HTML head or the elements itself.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0
|
||||
* Use #attached on render arrays.
|
||||
*/
|
||||
function drupal_get_html_head($render = TRUE) {
|
||||
$elements = _drupal_add_html_head();
|
||||
\Drupal::moduleHandler()->alter('html_head', $elements);
|
||||
if ($render) {
|
||||
return \Drupal::service('renderer')->renderPlain($elements);
|
||||
}
|
||||
else {
|
||||
return $elements;
|
||||
}
|
||||
}
|
||||
const LOCALE_PLURAL_DELIMITER = PluralTranslatableMarkup::DELIMITER;
|
||||
|
||||
/**
|
||||
* Prepares a 'destination' URL query parameter for use with url().
|
||||
|
@ -316,7 +262,7 @@ function check_url($uri) {
|
|||
* Optional language code to translate to a language other than what is used
|
||||
* to display the page.
|
||||
*
|
||||
* @return
|
||||
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
|
||||
* A translated string representation of the size.
|
||||
*/
|
||||
function format_size($size, $langcode = NULL) {
|
||||
|
@ -325,16 +271,7 @@ function format_size($size, $langcode = NULL) {
|
|||
}
|
||||
else {
|
||||
$size = $size / Bytes::KILOBYTE; // Convert bytes to kilobytes.
|
||||
$units = array(
|
||||
t('@size KB', array(), array('langcode' => $langcode)),
|
||||
t('@size MB', array(), array('langcode' => $langcode)),
|
||||
t('@size GB', array(), array('langcode' => $langcode)),
|
||||
t('@size TB', array(), array('langcode' => $langcode)),
|
||||
t('@size PB', array(), array('langcode' => $langcode)),
|
||||
t('@size EB', array(), array('langcode' => $langcode)),
|
||||
t('@size ZB', array(), array('langcode' => $langcode)),
|
||||
t('@size YB', array(), array('langcode' => $langcode)),
|
||||
);
|
||||
$units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
foreach ($units as $unit) {
|
||||
if (round($size, 2) >= Bytes::KILOBYTE) {
|
||||
$size = $size / Bytes::KILOBYTE;
|
||||
|
@ -343,7 +280,26 @@ function format_size($size, $langcode = NULL) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return str_replace('@size', round($size, 2), $unit);
|
||||
$args = ['@size' => round($size, 2)];
|
||||
$options = ['langcode' => $langcode];
|
||||
switch ($unit) {
|
||||
case 'KB':
|
||||
return new TranslatableMarkup('@size KB', $args, $options);
|
||||
case 'MB':
|
||||
return new TranslatableMarkup('@size MB', $args, $options);
|
||||
case 'GB':
|
||||
return new TranslatableMarkup('@size GB', $args, $options);
|
||||
case 'TB':
|
||||
return new TranslatableMarkup('@size TB', $args, $options);
|
||||
case 'PB':
|
||||
return new TranslatableMarkup('@size PB', $args, $options);
|
||||
case 'EB':
|
||||
return new TranslatableMarkup('@size EB', $args, $options);
|
||||
case 'ZB':
|
||||
return new TranslatableMarkup('@size ZB', $args, $options);
|
||||
case 'YB':
|
||||
return new TranslatableMarkup('@size YB', $args, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,39 +432,6 @@ function base_path() {
|
|||
return $GLOBALS['base_path'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a LINK tag with a distinct 'rel' attribute to the page's HEAD.
|
||||
*
|
||||
* This function can be called as long the HTML header hasn't been sent, which
|
||||
* on normal pages is up through the preprocess step of _theme('html'). Adding
|
||||
* a link will overwrite a prior link with the exact same 'rel' and 'href'
|
||||
* attributes.
|
||||
*
|
||||
* @param $attributes
|
||||
* Associative array of element attributes including 'href' and 'rel'.
|
||||
* @param $header
|
||||
* Optional flag to determine if a HTTP 'Link:' header should be sent.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0
|
||||
* Use #attached on render arrays.
|
||||
*/
|
||||
function _drupal_add_html_head_link($attributes, $header = FALSE) {
|
||||
$element = array(
|
||||
'#tag' => 'link',
|
||||
'#attributes' => $attributes,
|
||||
);
|
||||
$href = $attributes['href'];
|
||||
|
||||
if ($header) {
|
||||
// Also add a HTTP header "Link:".
|
||||
$href = '<' . Html::escape($attributes['href']) . '>;';
|
||||
unset($attributes['href']);
|
||||
$element['#attached']['http_header'][] = array('Link', $href . drupal_http_header_attributes($attributes), TRUE);
|
||||
}
|
||||
|
||||
_drupal_add_html_head($element, 'html_head_link:' . $attributes['rel'] . ':' . $href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes old cached CSS files.
|
||||
*
|
||||
|
@ -542,128 +465,6 @@ function drupal_js_defaults($data = NULL) {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two #attached arrays.
|
||||
*
|
||||
* The values under the 'drupalSettings' key are merged in a special way, to
|
||||
* match the behavior of:
|
||||
*
|
||||
* @code
|
||||
* jQuery.extend(true, {}, $settings_items[0], $settings_items[1], ...)
|
||||
* @endcode
|
||||
*
|
||||
* This means integer indices are preserved just like string indices are,
|
||||
* rather than re-indexed as is common in PHP array merging.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* function module1_page_attachments(&$page) {
|
||||
* $page['a']['#attached']['drupalSettings']['foo'] = ['a', 'b', 'c'];
|
||||
* }
|
||||
* function module2_page_attachments(&$page) {
|
||||
* $page['#attached']['drupalSettings']['foo'] = ['d'];
|
||||
* }
|
||||
* // When the page is rendered after the above code, and the browser runs the
|
||||
* // resulting <SCRIPT> tags, the value of drupalSettings.foo is
|
||||
* // ['d', 'b', 'c'], not ['a', 'b', 'c', 'd'].
|
||||
* @endcode
|
||||
*
|
||||
* By following jQuery.extend() merge logic rather than common PHP array merge
|
||||
* logic, the following are ensured:
|
||||
* - Attaching JavaScript settings is idempotent: attaching the same settings
|
||||
* twice does not change the output sent to the browser.
|
||||
* - If pieces of the page are rendered in separate PHP requests and the
|
||||
* returned settings are merged by JavaScript, the resulting settings are the
|
||||
* same as if rendered in one PHP request and merged by PHP.
|
||||
*
|
||||
* @param array $a
|
||||
* An #attached array.
|
||||
* @param array $b
|
||||
* Another #attached array.
|
||||
*
|
||||
* @return array
|
||||
* The merged #attached array.
|
||||
*
|
||||
* @deprecated To be removed in Drupal 8.0.x. Use
|
||||
* \Drupal\Core\Render\BubbleableMetadata::mergeAttachments() instead.
|
||||
*/
|
||||
function drupal_merge_attached(array $a, array $b) {
|
||||
return BubbleableMetadata::mergeAttachments($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes non-asset attachments in a render() structure.
|
||||
*
|
||||
* Libraries, JavaScript settings, feeds, HTML <head> tags and HTML <head> links
|
||||
* are attached to elements using the #attached property. The #attached property
|
||||
* is an associative array, where the keys are the attachment types and the
|
||||
* values are the attached data. For example:
|
||||
*
|
||||
* @code
|
||||
* $build['#attached'] = [
|
||||
* 'library' => ['core/jquery']
|
||||
* ];
|
||||
* $build['#attached']['http_header'] = [
|
||||
* ['Content-Type', 'application/rss+xml; charset=utf-8'],
|
||||
* ];
|
||||
* @endcode
|
||||
*
|
||||
* The available keys are:
|
||||
* - 'library' (asset libraries)
|
||||
* - 'drupalSettings' (JavaScript settings)
|
||||
* - 'feed' (RSS feeds)
|
||||
* - 'html_head' (tags in HTML <head>)
|
||||
* - 'html_head_link' (<link> tags in HTML <head>)
|
||||
* - 'http_header' (HTTP headers)
|
||||
*
|
||||
* This function processes all non-asset attachments, to apply them to the
|
||||
* current response (that means all keys except 'library' and 'drupalSettings').
|
||||
*
|
||||
* @param array $elements
|
||||
* The structured array describing the data being rendered.
|
||||
*
|
||||
* @see drupal_render()
|
||||
* @see \Drupal\Core\Asset\AssetResolver
|
||||
*
|
||||
* @throws LogicException
|
||||
* When attaching something of a non-existing attachment type.
|
||||
*/
|
||||
function drupal_process_attached(array $elements) {
|
||||
// Asset attachments are handled by \Drupal\Core\Asset\AssetResolver.
|
||||
foreach (array('library', 'drupalSettings') as $type) {
|
||||
unset($elements['#attached'][$type]);
|
||||
}
|
||||
|
||||
// Add additional types of attachments specified in the render() structure.
|
||||
foreach ($elements['#attached'] as $callback => $options) {
|
||||
foreach ($elements['#attached'][$callback] as $args) {
|
||||
// Limit the amount allowed entries.
|
||||
switch ($callback) {
|
||||
case 'html_head':
|
||||
call_user_func_array('_drupal_add_html_head', $args);
|
||||
break;
|
||||
case 'feed':
|
||||
$args = [[
|
||||
'href' => $args[0],
|
||||
'rel' => 'alternate',
|
||||
'title' => $args[1],
|
||||
'type' => 'application/rss+xml',
|
||||
]];
|
||||
call_user_func_array('_drupal_add_html_head_link', $args);
|
||||
break;
|
||||
case 'html_head_link':
|
||||
call_user_func_array('_drupal_add_html_head_link', $args);
|
||||
break;
|
||||
case 'http_header':
|
||||
// @todo Remove validation in https://www.drupal.org/node/2477223
|
||||
break;
|
||||
default:
|
||||
throw new \LogicException(sprintf('You are not allowed to use %s in #attached', $callback));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JavaScript to change the state of an element based on another element.
|
||||
*
|
||||
|
@ -1057,7 +858,7 @@ function drupal_pre_render_links($element) {
|
|||
}
|
||||
// Merge attachments.
|
||||
if (isset($child['#attached'])) {
|
||||
$element['#attached'] = drupal_merge_attached($element['#attached'], $child['#attached']);
|
||||
$element['#attached'] = BubbleableMetadata::mergeAttachments($element['#attached'], $child['#attached']);
|
||||
}
|
||||
}
|
||||
return $element;
|
||||
|
@ -1097,7 +898,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
|
|||
* can be passed in to save another run of
|
||||
* \Drupal\Core\Render\Element::children().
|
||||
*
|
||||
* @return string|\Drupal\Component\Utility\SafeStringInterface
|
||||
* @return string|\Drupal\Component\Render\MarkupInterface
|
||||
* The rendered HTML of all children of the element.
|
||||
*
|
||||
* @see drupal_render()
|
||||
|
@ -1112,7 +913,7 @@ function drupal_render_children(&$element, $children_keys = NULL) {
|
|||
$output .= drupal_render($element[$key]);
|
||||
}
|
||||
}
|
||||
return SafeString::create($output);
|
||||
return Markup::create($output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -360,7 +360,7 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
|
|||
function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
|
||||
if ($reset) {
|
||||
$render_controller->resetCache(array($entity->id()));
|
||||
$render_controller->resetCache([$entity]);
|
||||
}
|
||||
return $render_controller->view($entity, $view_mode, $langcode);
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
|
|||
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId());
|
||||
if ($reset) {
|
||||
$render_controller->resetCache(array_keys($entities));
|
||||
$render_controller->resetCache($entities);
|
||||
}
|
||||
return $render_controller->viewMultiple($entities, $view_mode, $langcode);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Render\SafeString;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\Utility\Error;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
@ -65,17 +65,22 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
|
|||
$caller = Error::getLastCaller($backtrace);
|
||||
|
||||
// We treat recoverable errors as fatal.
|
||||
$recoverable = $error_level == E_RECOVERABLE_ERROR;
|
||||
// As __toString() methods must not throw exceptions (recoverable errors)
|
||||
// in PHP, we allow them to trigger a fatal error by emitting a user error
|
||||
// using trigger_error().
|
||||
$to_string = $error_level == E_USER_ERROR && substr($caller['function'], -strlen('__toString()')) == '__toString()';
|
||||
_drupal_log_error(array(
|
||||
'%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
|
||||
// The standard PHP error handler considers that the error messages
|
||||
// are HTML. We mimick this behavior here.
|
||||
'@message' => SafeString::create(Xss::filterAdmin($message)),
|
||||
'@message' => Markup::create(Xss::filterAdmin($message)),
|
||||
'%function' => $caller['function'],
|
||||
'%file' => $caller['file'],
|
||||
'%line' => $caller['line'],
|
||||
'severity_level' => $severity_level,
|
||||
'backtrace' => $backtrace,
|
||||
), $error_level == E_RECOVERABLE_ERROR);
|
||||
), $recoverable || $to_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -335,8 +335,7 @@ function file_ensure_htaccess() {
|
|||
file_save_htaccess('private://', TRUE);
|
||||
}
|
||||
file_save_htaccess('temporary://', TRUE);
|
||||
file_save_htaccess(config_get_config_directory(), TRUE);
|
||||
file_save_htaccess(config_get_config_directory(CONFIG_STAGING_DIRECTORY), TRUE);
|
||||
file_save_htaccess(config_get_config_directory(CONFIG_SYNC_DIRECTORY), TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,8 +370,8 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS
|
|||
return drupal_chmod($htaccess_path, 0444);
|
||||
}
|
||||
else {
|
||||
$variables = array('%directory' => $directory, '!htaccess' => '<br />' . nl2br(Html::escape($htaccess_lines)));
|
||||
\Drupal::logger('security')->error("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", $variables);
|
||||
$variables = array('%directory' => $directory, '@htaccess' => $htaccess_lines);
|
||||
\Drupal::logger('security')->error("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <pre><code>@htaccess</code></pre>", $variables);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
*/
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Form\FormElementHelper;
|
||||
use Drupal\Core\Form\OptGroup;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
|
@ -223,11 +221,8 @@ function template_preprocess_fieldset(&$variables) {
|
|||
$variables['attributes']['aria-describedby'] = $description_id;
|
||||
}
|
||||
|
||||
// Display any error messages.
|
||||
// Suppress error messages.
|
||||
$variables['errors'] = NULL;
|
||||
if (!empty($element['#errors']) && empty($element['#error_no_message'])) {
|
||||
$variables['errors'] = $element['#errors'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,6 +252,9 @@ function template_preprocess_details(&$variables) {
|
|||
$variables['description'] = (!empty($element['#description'])) ? $element['#description'] : '';
|
||||
$variables['children'] = (isset($element['#children'])) ? $element['#children'] : '';
|
||||
$variables['value'] = (isset($element['#value'])) ? $element['#value'] : '';
|
||||
|
||||
// Suppress error messages.
|
||||
$variables['errors'] = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -432,7 +430,7 @@ function template_preprocess_form_element(&$variables) {
|
|||
);
|
||||
$variables['attributes'] = $element['#wrapper_attributes'];
|
||||
|
||||
// Add element #id for #type 'item' and 'password_confirm'.
|
||||
// Add element #id for #type 'item'.
|
||||
if (isset($element['#markup']) && !empty($element['#id'])) {
|
||||
$variables['attributes']['id'] = $element['#id'];
|
||||
}
|
||||
|
@ -448,11 +446,8 @@ function template_preprocess_form_element(&$variables) {
|
|||
// Pass elements disabled status to template.
|
||||
$variables['disabled'] = !empty($element['#attributes']['disabled']) ? $element['#attributes']['disabled'] : NULL;
|
||||
|
||||
// Display any error messages.
|
||||
// Suppress error messages.
|
||||
$variables['errors'] = NULL;
|
||||
if (!empty($element['#errors']) && empty($element['#error_no_message'])) {
|
||||
$variables['errors'] = $element['#errors'];
|
||||
}
|
||||
|
||||
// If #title is not set, we don't display any label.
|
||||
if (!isset($element['#title'])) {
|
||||
|
@ -695,8 +690,6 @@ function template_preprocess_form_element_label(&$variables) {
|
|||
* - css: Array of paths to CSS files to be used on the progress page.
|
||||
* - url_options: options passed to url() when constructing redirect URLs for
|
||||
* the batch.
|
||||
* - safe_strings: Internal use only. Used to store and retrieve strings
|
||||
* marked as safe between requests.
|
||||
* - progressive: A Boolean that indicates whether or not the batch needs to
|
||||
* run progressively. TRUE indicates that the batch will run in more than
|
||||
* one run. FALSE (default) indicates that the batch will finish in a single
|
||||
|
@ -838,7 +831,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
|
|||
$query_options['op'] = 'finished';
|
||||
$error_url->setOption('query', $query_options);
|
||||
|
||||
$batch['error_message'] = t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => $error_url->toString(TRUE)->getGeneratedUrl()));
|
||||
$batch['error_message'] = t('Please continue to <a href=":error_url">the error page</a>', array(':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()));
|
||||
|
||||
// Clear the way for the redirection to the batch processing page, by
|
||||
// saving and unsetting the 'destination', if there is any.
|
||||
|
@ -848,11 +841,6 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
|
|||
$request->query->remove('destination');
|
||||
}
|
||||
|
||||
// Store safe strings.
|
||||
// @todo Ensure we are not storing an excessively large string list in:
|
||||
// https://www.drupal.org/node/2295823
|
||||
$batch['safe_strings'] = SafeMarkup::getAll();
|
||||
|
||||
// Store the batch.
|
||||
\Drupal::service('batch.storage')->create($batch);
|
||||
|
||||
|
|
|
@ -345,12 +345,9 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
$container
|
||||
->register('language.default', 'Drupal\Core\Language\LanguageDefault')
|
||||
->addArgument('%language.default_values%');
|
||||
$container
|
||||
->register('language_manager', 'Drupal\Core\Language\LanguageManager')
|
||||
->addArgument(new Reference('language.default'));
|
||||
$container
|
||||
->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager')
|
||||
->addArgument(new Reference('language_manager'));
|
||||
->addArgument(new Reference('language.default'));
|
||||
|
||||
// Register the stream wrapper manager.
|
||||
$container
|
||||
|
@ -365,7 +362,7 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
\Drupal::setContainer($container);
|
||||
|
||||
// Determine whether base system services are ready to operate.
|
||||
$install_state['config_verified'] = install_ensure_config_directory(CONFIG_ACTIVE_DIRECTORY) && install_ensure_config_directory(CONFIG_STAGING_DIRECTORY);
|
||||
$install_state['config_verified'] = install_ensure_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
$install_state['database_verified'] = install_verify_database_settings($site_path);
|
||||
$install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified'];
|
||||
|
||||
|
@ -1317,7 +1314,7 @@ function install_select_language(&$install_state) {
|
|||
return;
|
||||
}
|
||||
else {
|
||||
throw new InstallerException(t('Sorry, you must select a language to continue the installation.'));
|
||||
throw new InstallerException(t('You must select a language to continue the installation.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1404,129 +1401,6 @@ function install_check_localization_server($uri) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the core release version and release alternatives for localization.
|
||||
*
|
||||
* In case core is a development version or the translation file for the
|
||||
* release is not available, fall back to an earlier release.
|
||||
* For example, 8.2.0-dev might fall back to 8.1.0 and 8.0.0-dev
|
||||
* might fall back to 7.0.
|
||||
*
|
||||
* @param string $version
|
||||
* (optional) Version of core trying to find translation files for.
|
||||
*
|
||||
* @return array
|
||||
* Array of release data. Each array element is an associative array with:
|
||||
* - core: Core compatibility version (e.g., 8.x).
|
||||
* - version: Release version (e.g., 8.1.0).
|
||||
*/
|
||||
function install_get_localization_release($version = \Drupal::VERSION) {
|
||||
$releases = array();
|
||||
$alternatives = array();
|
||||
|
||||
$info = _install_get_version_info($version);
|
||||
|
||||
// This code assumes there is a first alpha available as "alpha1". For
|
||||
// Drupal 8.0.0 that isn't the case. In addition the semantic versioning
|
||||
// wasn't introduced before "alpha14". However, we have already gotten to
|
||||
// "beta1" so we are ignoring this for now.
|
||||
|
||||
// The fallback detection is relaxed - removing version duplicates at the end.
|
||||
|
||||
// Check if the version is a regular stable release (no 'rc', 'beta', 'alpha',
|
||||
// 'dev', etc.)
|
||||
if (!isset($info['extra_text'])) {
|
||||
// First version alternative: the current version.
|
||||
$alternatives[] = $version;
|
||||
|
||||
// Patch-level: Previous and zero patch level (e.g., 8.2.4 falls back to
|
||||
// 8.2.3 and 8.2.0).
|
||||
if ($info['patch'] > 0) {
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.' . ($info['patch'] - 1);
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0';
|
||||
}
|
||||
// Zero patch: First release candidate (e.g., 8.0.0 falls back to
|
||||
// 8.0.0-rc1).
|
||||
else {
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-rc1';
|
||||
}
|
||||
// Point-releases: Previous and zero minor release (e.g., 8.2.x falls back
|
||||
// to 8.1.0 and 8.0.0).
|
||||
if ($info['minor'] > 0) {
|
||||
$alternatives[] = $info['major'] . '.' . ($info['minor'] - 1) . '.0';
|
||||
$alternatives[] = $info['major'] . '.0.0';
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Below we assume that for all dev, alpha, beta or rc releases the patch
|
||||
// level is 0.
|
||||
|
||||
$release_levels = array('rc', 'beta', 'alpha');
|
||||
|
||||
if ($info['extra_text'] == 'dev') {
|
||||
// Dev release: Any unstable release (e.g., 8.2.0-dev falls back to
|
||||
// 8.2.0-rc1, 8.2.0-beta1 and 8.2.0-alpha1).
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-rc1';
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-beta1';
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-alpha1';
|
||||
}
|
||||
elseif (in_array($info['extra_text'], $release_levels)) {
|
||||
// All other unstable release always includes the current version.
|
||||
$alternatives[] = $version;
|
||||
// Alpha release: Previous alpha release (e.g. 8.0.0-alpha2 falls back to
|
||||
// 8.0.0-alpha1).
|
||||
// Beta release: Previous beta release and first alpha release (e.g.
|
||||
// 8.0.0-beta2 falls back to 8.0.0-beta1 and 8.0.0-alpha1).
|
||||
// Release candidate: Previous release candidate and the first beta
|
||||
// release (e.g. 8.0.0-rc2 falls back to 8.0.0-rc1 and 8.0.0-beta1).
|
||||
$release_level_key = array_search($info['extra_text'], $release_levels);
|
||||
if ($info['extra_number'] > 1) {
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-' . $info['extra_text'] . ($info['extra_number'] - 1);
|
||||
}
|
||||
if ($info['extra_text'] != 'alpha') {
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-' . $release_levels[$release_level_key + 1] . '1';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$alternatives[] = $info['major'] . '.' . $info['minor'] . '.0';
|
||||
}
|
||||
// All unstable releases except the zero release: The previous minor release
|
||||
// and the zero release.
|
||||
if ($info['minor'] > 0) {
|
||||
$alternatives[] = $info['major'] . '.' . ($info['minor'] - 1) . '.0';
|
||||
$alternatives[] = $info['major'] . '.0.0';
|
||||
}
|
||||
}
|
||||
|
||||
$alternatives = array_unique($alternatives);
|
||||
foreach ($alternatives as $alternative) {
|
||||
list($core) = explode('.', $alternative);
|
||||
$releases[] = array(
|
||||
'core' => $core . '.x',
|
||||
'version' => $alternative,
|
||||
);
|
||||
}
|
||||
|
||||
// All releases may fall back to the previous major release (e.g., 8.1.0
|
||||
// may fall back to 7.0). This will probably only be used for early dev
|
||||
// releases or languages with an inactive translation team.
|
||||
if ($info['major'] == 8) {
|
||||
$releases[] = array(
|
||||
'core' => '7.x',
|
||||
'version' => '7.0',
|
||||
);
|
||||
}
|
||||
else {
|
||||
$prev_major = $info['major'] - 1;
|
||||
$releases[] = array(
|
||||
'core' => $prev_major . '.x',
|
||||
'version' => $prev_major . '.0.0',
|
||||
);
|
||||
}
|
||||
|
||||
return $releases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts version information from a drupal core version string.
|
||||
*
|
||||
|
@ -1937,7 +1811,6 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
$files_directory = $site_path . '/files';
|
||||
$translations_directory = $site_path . '/files/translations';
|
||||
$translations_directory_exists = FALSE;
|
||||
$translation_available = FALSE;
|
||||
$online = FALSE;
|
||||
|
||||
// First attempt to create or make writable the files directory.
|
||||
|
@ -1957,19 +1830,16 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Build URLs for the translation file and the translation server.
|
||||
$releases = install_get_localization_release();
|
||||
$translation_urls = array();
|
||||
foreach ($releases as $release) {
|
||||
$variables = array(
|
||||
'%project' => 'drupal',
|
||||
'%version' => $release['version'],
|
||||
'%core' => $release['core'],
|
||||
'%language' => $langcode,
|
||||
);
|
||||
$translation_urls[] = strtr($server_pattern, $variables);
|
||||
}
|
||||
$elements = parse_url(reset($translation_urls));
|
||||
// Build URL for the translation file and the translation server.
|
||||
$variables = array(
|
||||
'%project' => 'drupal',
|
||||
'%version' => \Drupal::VERSION,
|
||||
'%core' => \Drupal::CORE_COMPATIBILITY,
|
||||
'%language' => $langcode,
|
||||
);
|
||||
$translation_url = strtr($server_pattern, $variables);
|
||||
|
||||
$elements = parse_url($translation_url);
|
||||
$server_url = $elements['scheme'] . '://' . $elements['host'];
|
||||
|
||||
// Build the language name for display.
|
||||
|
@ -1979,11 +1849,8 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
// Check if any of the desired translation files are available or if the
|
||||
// translation server can be reached. In other words, check if we are online
|
||||
// and have an internet connection.
|
||||
foreach ($translation_urls as $translation_url) {
|
||||
if ($translation_available = install_check_localization_server($translation_url)) {
|
||||
$online = TRUE;
|
||||
break;
|
||||
}
|
||||
if ($translation_available = install_check_localization_server($translation_url)) {
|
||||
$online = TRUE;
|
||||
}
|
||||
if (!$translation_available) {
|
||||
if (install_check_localization_server($server_url)) {
|
||||
|
@ -1997,7 +1864,7 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
'title' => t('Translations directory'),
|
||||
'value' => t('The translations directory does not exist.'),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>.', array('%translations_directory' => $translations_directory, '@install_txt' => base_path() . 'core/INSTALL.txt')),
|
||||
'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', array('%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt')),
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -2011,7 +1878,7 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
'title' => t('Translations directory'),
|
||||
'value' => t('The translations directory is not readable.'),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The installer requires read permissions to %translations_directory at all times. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">online handbook</a>.', array('%translations_directory' => $translations_directory, '@handbook_url' => 'https://www.drupal.org/server-permissions')),
|
||||
'description' => t('The installer requires read permissions to %translations_directory at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')),
|
||||
);
|
||||
}
|
||||
// If translations directory is not writable, throw an error.
|
||||
|
@ -2020,7 +1887,7 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
'title' => t('Translations directory'),
|
||||
'value' => t('The translations directory is not writable.'),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The installer requires write permissions to %translations_directory during the installation process. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">online handbook</a>.', array('%translations_directory' => $translations_directory, '@handbook_url' => 'https://www.drupal.org/server-permissions')),
|
||||
'description' => t('The installer requires write permissions to %translations_directory during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')),
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -2037,7 +1904,7 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
'title' => t('Internet'),
|
||||
'value' => t('The translation server is offline.'),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href="!server_url">!server_url</a>.', array('!server_url' => $server_url)),
|
||||
'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href=":server_url">@server_url</a>.', array(':server_url' => $server_url, '@server_url' => $server_url)),
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -2052,7 +1919,7 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
'title' => t('Translation'),
|
||||
'value' => t('The %language translation is not available.', array('%language' => $language)),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The %language translation file is not available at the translation server. <a href="@url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, '@url' => UrlHelper::stripDangerousProtocols($_SERVER['SCRIPT_NAME']))),
|
||||
'description' => t('The %language translation file is not available at the translation server. <a href=":url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])),
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -2071,7 +1938,7 @@ function install_check_translations($langcode, $server_pattern) {
|
|||
'title' => t('Translation'),
|
||||
'value' => t('The %language translation could not be downloaded.', array('%language' => $language)),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The %language translation file could not be downloaded. <a href="@url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, '@url' => UrlHelper::stripDangerousProtocols($_SERVER['SCRIPT_NAME']))),
|
||||
'description' => t('The %language translation file could not be downloaded. <a href=":url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2186,11 +2053,11 @@ function install_check_requirements($install_state) {
|
|||
'title' => $default_file_info['title'],
|
||||
'value' => t('The %file does not exist.', array('%file' => $default_file_info['title'])),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>.', array(
|
||||
'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', array(
|
||||
'@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'
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
@ -2205,10 +2072,10 @@ function install_check_requirements($install_state) {
|
|||
'title' => $default_file_info['title'],
|
||||
'value' => t('The %file is not readable.', array('%file' => $default_file_info['title'])),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('@drupal requires read permissions to %file at all times. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">online handbook</a>.', array(
|
||||
'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.', array(
|
||||
'@drupal' => drupal_install_profile_distribution_name(),
|
||||
'%file' => $file,
|
||||
'@handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
@ -2218,10 +2085,10 @@ function install_check_requirements($install_state) {
|
|||
'title' => $default_file_info['title'],
|
||||
'value' => t('The %file is not writable.', array('%file' => $default_file_info['title'])),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">online handbook</a>.', array(
|
||||
'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.', array(
|
||||
'@drupal' => drupal_install_profile_distribution_name(),
|
||||
'%file' => $file,
|
||||
'@handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
@ -2236,12 +2103,12 @@ function install_check_requirements($install_state) {
|
|||
'title' => $default_file_info['title'],
|
||||
'value' => t('The @file is owned by the web server.', array('@file' => $default_file_info['title'])),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href="@install_txt">INSTALL.txt</a>. If you have problems with the file permissions on your server, consult the <a href="@handbook_url">online handbook</a>.', array(
|
||||
'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array(
|
||||
'@drupal' => drupal_install_profile_distribution_name(),
|
||||
'%file' => $file,
|
||||
'%default_file' => $default_file,
|
||||
'@install_txt' => base_path() . 'core/INSTALL.txt',
|
||||
'@handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
':install_txt' => base_path() . 'core/INSTALL.txt',
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions'
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
@ -2281,11 +2148,11 @@ function install_display_requirements($install_state, $requirements) {
|
|||
$build['report']['#requirements'] = $requirements;
|
||||
if ($severity == REQUIREMENT_WARNING) {
|
||||
$build['#title'] = t('Requirements review');
|
||||
$build['#suffix'] = t('Check the messages and <a href="@retry">retry</a>, or you may choose to <a href="@cont">continue anyway</a>.', array('@retry' => UrlHelper::stripDangerousProtocols(drupal_requirements_url(REQUIREMENT_ERROR)), '@cont' => UrlHelper::stripDangerousProtocols(drupal_requirements_url($severity))));
|
||||
$build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', array(':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)));
|
||||
}
|
||||
else {
|
||||
$build['#title'] = t('Requirements problem');
|
||||
$build['#suffix'] = t('Check the messages and <a href="@url">try again</a>.', array('@url' => UrlHelper::stripDangerousProtocols(drupal_requirements_url($severity))));
|
||||
$build['#suffix'] = t('Check the messages and <a href=":url">try again</a>.', array(':url' => drupal_requirements_url($severity)));
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
|
|
|
@ -111,6 +111,30 @@ function drupal_install_profile_distribution_name() {
|
|||
return isset($info['distribution']['name']) ? $info['distribution']['name'] : 'Drupal';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @see install_profile_info()
|
||||
*/
|
||||
function drupal_install_profile_distribution_version() {
|
||||
// During installation, the profile information is stored in the global
|
||||
// installation state (it might not be saved anywhere yet).
|
||||
if (drupal_installation_attempted()) {
|
||||
global $install_state;
|
||||
return isset($install_state['profile_info']['version']) ? $install_state['profile_info']['version'] : \Drupal::VERSION;
|
||||
}
|
||||
// At all other times, we load the profile via standard methods.
|
||||
else {
|
||||
$profile = drupal_get_profile();
|
||||
$info = system_get_info('module', $profile);
|
||||
return $info['version'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects all supported databases that are compiled into PHP.
|
||||
*
|
||||
|
@ -178,12 +202,8 @@ function drupal_get_database_types() {
|
|||
* and comment properties.
|
||||
* @code
|
||||
* $settings['config_directories'] = array(
|
||||
* CONFIG_ACTIVE_DIRECTORY => (object) array(
|
||||
* 'value' => 'config_hash/active'
|
||||
* 'required' => TRUE,
|
||||
* ),
|
||||
* CONFIG_STAGING_DIRECTORY => (object) array(
|
||||
* 'value' => 'config_hash/staging',
|
||||
* CONFIG_SYNC_DIRECTORY => (object) array(
|
||||
* 'value' => 'config_hash/sync',
|
||||
* 'required' => TRUE,
|
||||
* ),
|
||||
* );
|
||||
|
@ -191,7 +211,7 @@ function drupal_get_database_types() {
|
|||
* gets dumped as:
|
||||
* @code
|
||||
* $config_directories['active'] = 'config_hash/active';
|
||||
* $config_directories['staging'] = 'config_hash/staging'
|
||||
* $config_directories['sync'] = 'config_hash/sync'
|
||||
* @endcode
|
||||
*/
|
||||
function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
|
||||
|
@ -467,15 +487,9 @@ function drupal_install_config_directories() {
|
|||
// manually defined in the existing already.
|
||||
$settings = [];
|
||||
$config_directories_hash = Crypt::randomBytesBase64(55);
|
||||
if (empty($config_directories[CONFIG_ACTIVE_DIRECTORY])) {
|
||||
$settings['config_directories'][CONFIG_ACTIVE_DIRECTORY] = (object) [
|
||||
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/active',
|
||||
'required' => TRUE,
|
||||
];
|
||||
}
|
||||
if (empty($config_directories[CONFIG_STAGING_DIRECTORY])) {
|
||||
$settings['config_directories'][CONFIG_STAGING_DIRECTORY] = (object) [
|
||||
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/staging',
|
||||
if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
|
||||
$settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
|
||||
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/sync',
|
||||
'required' => TRUE,
|
||||
];
|
||||
}
|
||||
|
@ -485,36 +499,25 @@ function drupal_install_config_directories() {
|
|||
drupal_rewrite_settings($settings);
|
||||
}
|
||||
|
||||
// Ensure the config directories exist or can be created, and are writable.
|
||||
foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $config_type) {
|
||||
// This should never fail, since if the config directory was specified in
|
||||
// settings.php it will have already been created and verified earlier, and
|
||||
// if it wasn't specified in settings.php, it is created here inside the
|
||||
// public files directory, which has already been verified to be writable
|
||||
// itself. But if it somehow fails anyway, the installation cannot proceed.
|
||||
// Bail out using a similar error message as in system_requirements().
|
||||
if (!install_ensure_config_directory($config_type)) {
|
||||
throw new Exception(t('The directory %directory could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the <a href="@handbook_url">online handbook</a>.', array(
|
||||
'%directory' => config_get_config_directory($config_type),
|
||||
'@handbook_url' => 'https://www.drupal.org/server-permissions',
|
||||
)));
|
||||
}
|
||||
|
||||
// Put a README.txt into each config directory. This is required so that
|
||||
// they can later be added to git. Since these directories are auto-
|
||||
// created, we have to write out the README rather than just adding it
|
||||
// to the drupal core repo.
|
||||
switch ($config_type) {
|
||||
case CONFIG_ACTIVE_DIRECTORY:
|
||||
$text = 'If you change the configuration system to use file storage instead of the database for the active Drupal site configuration, this directory will contain the active configuration. By default, this directory will be empty. If you are using files to store the active configuration, and you want to move it between environments, files from this directory should be placed in the staging directory on the target server. To make this configuration active, visit admin/config/development/configuration/sync on the target server.';
|
||||
break;
|
||||
case CONFIG_STAGING_DIRECTORY:
|
||||
$text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.';
|
||||
break;
|
||||
}
|
||||
$text .= ' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
|
||||
file_put_contents(config_get_config_directory($config_type) . '/README.txt', $text);
|
||||
// This should never fail, since if the config directory was specified in
|
||||
// settings.php it will have already been created and verified earlier, and
|
||||
// if it wasn't specified in settings.php, it is created here inside the
|
||||
// public files directory, which has already been verified to be writable
|
||||
// itself. But if it somehow fails anyway, the installation cannot proceed.
|
||||
// Bail out using a similar error message as in system_requirements().
|
||||
if (!install_ensure_config_directory(CONFIG_SYNC_DIRECTORY)) {
|
||||
throw new Exception(t('The directory %directory could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', array(
|
||||
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions',
|
||||
)));
|
||||
}
|
||||
|
||||
// Put a README.txt into the sync config directory. This is required so that
|
||||
// they can later be added to git. Since this directory is auto-created, we
|
||||
// have to write out the README rather than just adding it to the drupal core
|
||||
// repo.
|
||||
$text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.' .' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
|
||||
file_put_contents(config_get_config_directory(CONFIG_SYNC_DIRECTORY) . '/README.txt', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -522,7 +525,7 @@ function drupal_install_config_directories() {
|
|||
*
|
||||
* @param string $type
|
||||
* Type of config directory to return. Drupal core provides 'active' and
|
||||
* 'staging'.
|
||||
* 'sync'.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the config directory exists and is writable.
|
||||
|
@ -570,16 +573,22 @@ function drupal_verify_profile($install_state) {
|
|||
|
||||
$requirements = array();
|
||||
|
||||
if (count($missing_modules)) {
|
||||
$modules = array();
|
||||
if ($missing_modules) {
|
||||
$build = [
|
||||
'#theme' => 'item_list',
|
||||
'#context' => ['list_style' => 'comma-list'],
|
||||
];
|
||||
|
||||
foreach ($missing_modules as $module) {
|
||||
$modules[] = '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>';
|
||||
$build['#items'][] = array('#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>');
|
||||
}
|
||||
|
||||
$modules_list = \Drupal::service('renderer')->renderPlain($build);
|
||||
$requirements['required_modules'] = array(
|
||||
'title' => t('Required modules'),
|
||||
'value' => t('Required modules not found.'),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: !modules', array('!modules' => implode(', ', $modules))),
|
||||
'title' => t('Required modules'),
|
||||
'value' => t('Required modules not found.'),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', array('@modules' => $modules_list)),
|
||||
);
|
||||
}
|
||||
return $requirements;
|
||||
|
|
|
@ -168,8 +168,8 @@ function pager_get_query_parameters() {
|
|||
* - #tags: An array of labels for the controls in the pager.
|
||||
* - #element: An optional integer to distinguish between multiple pagers on
|
||||
* one page.
|
||||
* - #parameters: An associative array of query string parameters to append to
|
||||
* the pager links.
|
||||
* - #parameters: An associative array of query string parameters to append
|
||||
* to the pager links.
|
||||
* - #quantity: The number of pages in the list.
|
||||
*/
|
||||
function template_preprocess_pager(&$variables) {
|
||||
|
@ -189,13 +189,13 @@ function template_preprocess_pager(&$variables) {
|
|||
// Calculate various markers within this pager piece:
|
||||
// Middle is used to "center" pages around the current page.
|
||||
$pager_middle = ceil($quantity / 2);
|
||||
// current is the page we are currently paged to
|
||||
// current is the page we are currently paged to.
|
||||
$pager_current = $pager_page_array[$element] + 1;
|
||||
// first is the first page listed by this pager piece (re quantity)
|
||||
// first is the first page listed by this pager piece (re quantity).
|
||||
$pager_first = $pager_current - $pager_middle + 1;
|
||||
// last is the last page listed by this pager piece (re quantity)
|
||||
// last is the last page listed by this pager piece (re quantity).
|
||||
$pager_last = $pager_current + $quantity - $pager_middle;
|
||||
// max is the maximum page number
|
||||
// max is the maximum page number.
|
||||
$pager_max = $pager_total[$element];
|
||||
// End of marker calculations.
|
||||
|
||||
|
@ -278,64 +278,48 @@ function template_preprocess_pager(&$variables) {
|
|||
|
||||
$variables['items'] = $items;
|
||||
|
||||
// The rendered link needs to play well with any other query parameter
|
||||
// used on the page, like exposed filters, so for the cacheability all query
|
||||
// The rendered link needs to play well with any other query parameter used
|
||||
// on the page, like exposed filters, so for the cacheability all query
|
||||
// parameters matter.
|
||||
$variables['#cache']['contexts'][] = 'url.query_args';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the 'page' parameter to the query parameter array of a pager link.
|
||||
* Get the query parameter array of a pager link.
|
||||
*
|
||||
* Adds or adjusts the 'page' parameter to make sure that, following the link,
|
||||
* the requested $page for the given $element is displayed.
|
||||
* The 'page' parameter is a comma-delimited string, where each value is the
|
||||
* target page for the corresponding pager $element.
|
||||
*
|
||||
* @param array $query
|
||||
* An associative array of query parameters to add to.
|
||||
* @param integer $element
|
||||
* An integer to distinguish between multiple pagers on one page.
|
||||
* @param integer $index
|
||||
* The index of the target page in the pager array.
|
||||
* The index of the target page, for the given element, in the pager array.
|
||||
*
|
||||
* @return array
|
||||
* The altered $query parameter array.
|
||||
*
|
||||
* @todo Document the pager/element/index architecture and logic. It is not
|
||||
* clear what is happening in this function as well as pager_load_array(),
|
||||
* and whether this can be simplified in any way.
|
||||
*/
|
||||
function pager_query_add_page(array $query, $element, $index) {
|
||||
global $pager_page_array;
|
||||
|
||||
// Determine the first result to display on the linked page.
|
||||
$page_new = pager_load_array($index, $element, $pager_page_array);
|
||||
|
||||
$page = \Drupal::request()->query->get('page', '');
|
||||
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
|
||||
$query['page'] = $new_page;
|
||||
// Build the 'page' query parameter. This is built based on the current
|
||||
// page of each pager element (or NULL if the pager is not set), with the
|
||||
// exception of the requested page index for the current element.
|
||||
$max_element = max(array_keys($pager_page_array));
|
||||
$element_pages = [];
|
||||
for ($i = 0; $i <= $max_element; $i++) {
|
||||
$element_pages[] = ($i == $element) ? $index : (isset($pager_page_array[$i]) ? $pager_page_array[$i] : NULL);
|
||||
}
|
||||
$query['page'] = implode(',', $element_pages);
|
||||
|
||||
// Merge the query parameters passed to this function with the parameters
|
||||
// from the current request. In case of collision, the parameters passed
|
||||
// into this function take precedence.
|
||||
// from the current request. In case of collision, the parameters passed into
|
||||
// this function take precedence.
|
||||
if ($current_request_query = pager_get_query_parameters()) {
|
||||
$query = array_merge($current_request_query, $query);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function
|
||||
*
|
||||
* Copies $old_array to $new_array and sets $new_array[$element] = $value
|
||||
* Fills in $new_array[0 .. $element - 1] = 0
|
||||
*/
|
||||
function pager_load_array($value, $element, $old_array) {
|
||||
$new_array = $old_array;
|
||||
// Look for empty elements.
|
||||
for ($i = 0; $i < $element; $i++) {
|
||||
if (empty($new_array[$i])) {
|
||||
// Load found empty element with 0.
|
||||
$new_array[$i] = 0;
|
||||
}
|
||||
}
|
||||
// Update the changed element.
|
||||
$new_array[$element] = (int) $value;
|
||||
return $new_array;
|
||||
}
|
||||
|
|
|
@ -130,12 +130,6 @@ function drupal_install_schema($module) {
|
|||
*
|
||||
* @param string $module
|
||||
* The module for which the tables will be removed.
|
||||
*
|
||||
* @return array
|
||||
* An array of arrays with the following key/value pairs:
|
||||
* - success: a boolean indicating whether the query succeeded.
|
||||
* - query: the SQL query(s) executed, passed through
|
||||
* \Drupal\Component\Utility\SafeMarkup::checkPlain().
|
||||
*/
|
||||
function drupal_uninstall_schema($module) {
|
||||
$schema = drupal_get_module_schema($module);
|
||||
|
|
|
@ -12,15 +12,17 @@ use Drupal\Component\Serialization\Json;
|
|||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Config\StorageException;
|
||||
use Drupal\Core\Render\RenderableInterface;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\Core\Theme\ThemeSettings;
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\Core\Render\SafeString;
|
||||
use Drupal\Core\Render\Markup;
|
||||
|
||||
/**
|
||||
* @defgroup content_flags Content markers
|
||||
|
@ -326,14 +328,11 @@ function theme_get_setting($setting_name, $theme = NULL) {
|
|||
}
|
||||
|
||||
// Generate the path to the logo image.
|
||||
if ($cache[$theme]->get('features.logo')) {
|
||||
$logo_path = $cache[$theme]->get('logo.path');
|
||||
if ($cache[$theme]->get('logo.use_default')) {
|
||||
$cache[$theme]->set('logo.url', file_create_url($theme_object->getPath() . '/logo.svg'));
|
||||
}
|
||||
elseif ($logo_path) {
|
||||
$cache[$theme]->set('logo.url', file_create_url($logo_path));
|
||||
}
|
||||
if ($cache[$theme]->get('logo.use_default')) {
|
||||
$cache[$theme]->set('logo.url', file_create_url($theme_object->getPath() . '/logo.svg'));
|
||||
}
|
||||
elseif ($logo_path = $cache[$theme]->get('logo.path')) {
|
||||
$cache[$theme]->set('logo.url', file_create_url($logo_path));
|
||||
}
|
||||
|
||||
// Generate the path to the favicon.
|
||||
|
@ -360,6 +359,75 @@ function theme_get_setting($setting_name, $theme = NULL) {
|
|||
return $cache[$theme]->get($setting_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes and renders variables for theme functions.
|
||||
*
|
||||
* This method is used in theme functions to ensure that the result is safe for
|
||||
* output inside HTML fragments. This mimics the behavior of the auto-escape
|
||||
* functionality in Twig.
|
||||
*
|
||||
* Note: This function should be kept in sync with
|
||||
* \Drupal\Core\Template\TwigExtension::escapeFilter().
|
||||
*
|
||||
* @param mixed $arg
|
||||
* The string, object, or render array to escape if needed.
|
||||
*
|
||||
* @return string
|
||||
* The rendered string, safe for use in HTML. The string is not safe when used
|
||||
* as any part of an HTML attribute name or value.
|
||||
*
|
||||
* @throws \Exception
|
||||
* Thrown when an object is passed in which cannot be printed.
|
||||
*
|
||||
* @see \Drupal\Core\Template\TwigExtension::escapeFilter()
|
||||
*
|
||||
* @todo Discuss deprecating this in https://www.drupal.org/node/2575081.
|
||||
* @todo Refactor this to keep it in sync with Twig filtering in
|
||||
* https://www.drupal.org/node/2575065
|
||||
*/
|
||||
function theme_render_and_autoescape($arg) {
|
||||
if ($arg instanceOf MarkupInterface) {
|
||||
return (string) $arg;
|
||||
}
|
||||
$return = NULL;
|
||||
|
||||
if (is_scalar($arg)) {
|
||||
$return = (string) $arg;
|
||||
}
|
||||
elseif (is_object($arg)) {
|
||||
if ($arg instanceof RenderableInterface) {
|
||||
$arg = $arg->toRenderable();
|
||||
}
|
||||
elseif (method_exists($arg, '__toString')) {
|
||||
$return = (string) $arg;
|
||||
}
|
||||
// You can't throw exceptions in the magic PHP __toString methods, see
|
||||
// http://php.net/manual/en/language.oop5.magic.php#object.tostring so
|
||||
// we also support a toString method.
|
||||
elseif (method_exists($arg, 'toString')) {
|
||||
$return = $arg->toString();
|
||||
}
|
||||
else {
|
||||
throw new \Exception(t('Object of type "@class" cannot be printed.', array('@class' => get_class($arg))));
|
||||
}
|
||||
}
|
||||
|
||||
// We have a string or an object converted to a string: Escape it!
|
||||
if (isset($return)) {
|
||||
return SafeMarkup::isSafe($return, 'html') ? $return : Html::escape($return);
|
||||
}
|
||||
|
||||
// This is a normal render array, which is safe by definition, with special
|
||||
// simple cases already handled.
|
||||
|
||||
// Early return if this element was pre-rendered (no need to re-render).
|
||||
if (isset($arg['#printed']) && $arg['#printed'] == TRUE && isset($arg['#markup']) && strlen($arg['#markup']) > 0) {
|
||||
return (string) $arg['#markup'];
|
||||
}
|
||||
$arg['#printed'] = FALSE;
|
||||
return (string) \Drupal::service('renderer')->render($arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts theme settings to configuration.
|
||||
*
|
||||
|
@ -478,11 +546,8 @@ function template_preprocess_datetime_wrapper(&$variables) {
|
|||
$variables['title'] = $element['#title'];
|
||||
}
|
||||
|
||||
// Display any error messages.
|
||||
// Suppress error messages.
|
||||
$variables['errors'] = NULL;
|
||||
if (!empty($element['#errors']) && empty($element['#error_no_message'])) {
|
||||
$variables['errors'] = $element['#errors'];
|
||||
}
|
||||
|
||||
if (!empty($element['#description'])) {
|
||||
$variables['description'] = $element['#description'];
|
||||
|
@ -962,25 +1027,6 @@ function template_preprocess_table(&$variables) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for tablesort indicator templates.
|
||||
*
|
||||
* Default template: tablesort-indicator.html.twig.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - style: Set to either 'asc' or 'desc'. This determines which icon to show.
|
||||
*/
|
||||
function template_preprocess_tablesort_indicator(&$variables) {
|
||||
// Provide the image attributes for an ascending or descending image.
|
||||
if ($variables['style'] == 'asc') {
|
||||
$variables['arrow_asc'] = file_create_url('core/misc/arrow-asc.png');
|
||||
}
|
||||
else {
|
||||
$variables['arrow_desc'] = file_create_url('core/misc/arrow-desc.png');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for item list templates.
|
||||
*
|
||||
|
@ -1000,6 +1046,7 @@ function template_preprocess_tablesort_indicator(&$variables) {
|
|||
* @see https://www.drupal.org/node/1842756
|
||||
*/
|
||||
function template_preprocess_item_list(&$variables) {
|
||||
$variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']);
|
||||
foreach ($variables['items'] as &$item) {
|
||||
$attributes = array();
|
||||
// If the item value is an array, then it is a render array.
|
||||
|
@ -1047,23 +1094,6 @@ function template_preprocess_item_list(&$variables) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for an indentation div; used for drag and drop tables.
|
||||
*
|
||||
* @param $variables
|
||||
* An associative array containing:
|
||||
* - size: Optional. The number of indentations to create.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_indentation($variables) {
|
||||
$output = '';
|
||||
for ($n = 0; $n < $variables['size']; $n++) {
|
||||
$output .= '<div class="js-indentation indentation"> </div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for container templates.
|
||||
*
|
||||
|
@ -1243,7 +1273,7 @@ function template_preprocess_html(&$variables) {
|
|||
if (!empty($variables['page']['#title'])) {
|
||||
$head_title = array(
|
||||
// Marking the title as safe since it has had the tags stripped.
|
||||
'title' => SafeString::create(trim(strip_tags($variables['page']['#title']))),
|
||||
'title' => Markup::create(trim(strip_tags($variables['page']['#title']))),
|
||||
'name' => $site_config->get('name'),
|
||||
);
|
||||
}
|
||||
|
@ -1269,19 +1299,15 @@ function template_preprocess_html(&$variables) {
|
|||
// Create placeholder strings for these keys.
|
||||
// @see \Drupal\Core\Render\HtmlResponseSubscriber
|
||||
$types = [
|
||||
'styles',
|
||||
'scripts',
|
||||
'scripts_bottom',
|
||||
'head',
|
||||
'styles' => 'css',
|
||||
'scripts' => 'js',
|
||||
'scripts_bottom' => 'js-bottom',
|
||||
'head' => 'head',
|
||||
];
|
||||
$token = Crypt::randomBytesBase64(55);
|
||||
foreach ($types as $type) {
|
||||
$placeholder = SafeMarkup::format('<drupal-html-response-attachment-placeholder type="@type" token="@token"></drupal-html-response-attachment-placeholder>', [
|
||||
'@type' => $type,
|
||||
'@token' => $token,
|
||||
]);
|
||||
$variables[$type]['#markup'] = $placeholder;
|
||||
$variables[$type]['#attached']['html_response_attachment_placeholders'][$type] = $placeholder;
|
||||
$variables['placeholder_token'] = Crypt::randomBytesBase64(55);
|
||||
foreach ($types as $type => $placeholder_name) {
|
||||
$placeholder = '<' . $placeholder_name . '-placeholder token="' . $variables['placeholder_token'] . '">';
|
||||
$variables['#attached']['html_response_attachment_placeholders'][$type] = $placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1296,10 +1322,6 @@ function template_preprocess_html(&$variables) {
|
|||
*/
|
||||
function template_preprocess_page(&$variables) {
|
||||
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
|
||||
$site_config = \Drupal::config('system.site');
|
||||
|
||||
// Move some variables to the top level for themer convenience and template cleanliness.
|
||||
$variables['title'] = $variables['page']['#title'];
|
||||
|
||||
foreach (\Drupal::theme()->getActiveTheme()->getRegions() as $region) {
|
||||
if (!isset($variables['page'][$region])) {
|
||||
|
@ -1310,9 +1332,6 @@ function template_preprocess_page(&$variables) {
|
|||
$variables['base_path'] = base_path();
|
||||
$variables['front_page'] = \Drupal::url('<front>');
|
||||
$variables['language'] = $language_interface;
|
||||
$variables['logo'] = theme_get_setting('logo.url');
|
||||
$variables['site_name'] = (theme_get_setting('features.name') ? $site_config->get('name') : '');
|
||||
$variables['site_slogan']['#markup'] = (theme_get_setting('features.slogan') ? $site_config->get('slogan') : '');
|
||||
|
||||
// An exception might be thrown.
|
||||
try {
|
||||
|
@ -1417,6 +1436,17 @@ function template_preprocess_maintenance_page(&$variables) {
|
|||
|
||||
// @see system_page_attachments()
|
||||
$variables['#attached']['library'][] = 'system/maintenance';
|
||||
|
||||
// Maintenance page and install page need branding info in variables because
|
||||
// there is no blocks.
|
||||
$site_config = \Drupal::config('system.site');
|
||||
$variables['logo'] = theme_get_setting('logo.url');
|
||||
$variables['site_name'] = $site_config->get('name');
|
||||
$variables['site_slogan'] = $site_config->get('slogan');
|
||||
|
||||
// Maintenance page and install page need page title in variable because there
|
||||
// are no blocks.
|
||||
$variables['title'] = $variables['page']['#title'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1437,6 +1467,7 @@ function template_preprocess_install_page(&$variables) {
|
|||
// still in the process of being installed.
|
||||
$distribution_name = drupal_install_profile_distribution_name();
|
||||
$variables['site_name'] = $distribution_name;
|
||||
$variables['site_version'] = drupal_install_profile_distribution_version();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1484,11 +1515,7 @@ function template_preprocess_field(&$variables, $hook) {
|
|||
// readers.
|
||||
$variables['label'] = $element['#title'];
|
||||
|
||||
|
||||
// @todo Check for is_object() required due to pseudo field used in
|
||||
// quickedit_test_entity_view_alter(). Remove this check after this is fixed
|
||||
// in https://www.drupal.org/node/2550225.
|
||||
$variables['multiple'] = is_object($element['#items']) ? $element['#items']->getFieldDefinition()->getFieldStorageDefinition()->isMultiple() : FALSE;
|
||||
$variables['multiple'] = $element['#is_multiple'];
|
||||
|
||||
static $default_attributes;
|
||||
if (!isset($default_attributes)) {
|
||||
|
@ -1496,7 +1523,7 @@ function template_preprocess_field(&$variables, $hook) {
|
|||
}
|
||||
|
||||
// Merge attributes when a single-value field has a hidden label.
|
||||
if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && is_object($element['#items'][0])) {
|
||||
if ($element['#label_display'] == 'hidden' && !$variables['multiple']) {
|
||||
$variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], (array) $element['#items'][0]->_attributes);
|
||||
}
|
||||
|
||||
|
@ -1613,7 +1640,15 @@ function template_preprocess_field_multiple_value_form(&$variables) {
|
|||
),
|
||||
);
|
||||
|
||||
$variables['description'] = $element['#description'];
|
||||
if (!empty($element['#description'])) {
|
||||
$description_id = $element['#attributes']['aria-describedby'];
|
||||
$description_attributes['id'] = $description_id;
|
||||
$variables['description']['attributes'] = new Attribute($description_attributes);
|
||||
$variables['description']['content'] = $element['#description'];
|
||||
|
||||
// Add the description's id to the table aria attributes.
|
||||
$variables['table']['#attributes']['aria-describedby'] = $element['#attributes']['aria-describedby'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$variables['elements'] = array();
|
||||
|
@ -1663,6 +1698,9 @@ function drupal_common_theme() {
|
|||
'page' => array(
|
||||
'render element' => 'page',
|
||||
),
|
||||
'page_title' => array(
|
||||
'variables' => array('title' => NULL),
|
||||
),
|
||||
'region' => array(
|
||||
'render element' => 'elements',
|
||||
),
|
||||
|
@ -1712,7 +1750,7 @@ function drupal_common_theme() {
|
|||
'variables' => array('status' => MARK_NEW),
|
||||
),
|
||||
'item_list' => array(
|
||||
'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL, 'context' => array()),
|
||||
'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => array(), 'attributes' => array(), 'empty' => NULL, 'context' => array()),
|
||||
),
|
||||
'feed_icon' => array(
|
||||
'variables' => array('url' => NULL, 'title' => NULL),
|
||||
|
@ -1722,7 +1760,6 @@ function drupal_common_theme() {
|
|||
),
|
||||
'indentation' => array(
|
||||
'variables' => array('size' => 1),
|
||||
'function' => 'theme_indentation',
|
||||
),
|
||||
// From theme.maintenance.inc.
|
||||
'maintenance_page' => array(
|
||||
|
|
|
@ -29,26 +29,26 @@ function unicode_requirements() {
|
|||
'value' => $libraries[$library],
|
||||
'severity' => $severities[$library],
|
||||
);
|
||||
$t_args = array('@url' => 'http://www.php.net/mbstring');
|
||||
$t_args = array(':url' => 'http://www.php.net/mbstring');
|
||||
switch ($failed_check) {
|
||||
case 'mb_strlen':
|
||||
$requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', $t_args);
|
||||
$requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href=":url">PHP mbstring extension</a> for improved Unicode support.', $t_args);
|
||||
break;
|
||||
|
||||
case 'mbstring.func_overload':
|
||||
$requirements['unicode']['description'] = t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
$requirements['unicode']['description'] = t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href=":url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
break;
|
||||
|
||||
case 'mbstring.encoding_translation':
|
||||
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href=":url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
break;
|
||||
|
||||
case 'mbstring.http_input':
|
||||
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href=":url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
break;
|
||||
|
||||
case 'mbstring.http_output':
|
||||
$requirements['unicode']['description'] = t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
$requirements['unicode']['description'] = t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href=":url">PHP mbstring documentation</a> for more information.', $t_args);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
use Drupal\Component\Graph\Graph;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Entity\EntityStorageException;
|
||||
use Drupal\Core\Utility\Error;
|
||||
|
||||
/**
|
||||
|
@ -183,6 +182,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
|
|||
// @TODO We may want to do different error handling for different
|
||||
// exception types, but for now we'll just log the exception and
|
||||
// return the message for printing.
|
||||
// @see https://www.drupal.org/node/2564311
|
||||
catch (Exception $e) {
|
||||
watchdog_exception('update', $e);
|
||||
|
||||
|
@ -215,7 +215,68 @@ function update_do_one($module, $number, $dependency_map, &$context) {
|
|||
drupal_set_installed_schema_version($module, $number);
|
||||
}
|
||||
|
||||
$context['message'] = 'Updating ' . Html::escape($module) . ' module';
|
||||
$context['message'] = t('Updating @module', ['@module' => $module]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a single hook_post_update_NAME().
|
||||
*
|
||||
* @param string $function
|
||||
* The function name, that should be executed.
|
||||
* @param array $context
|
||||
* The batch context array.
|
||||
*/
|
||||
function update_invoke_post_update($function, &$context) {
|
||||
$ret = [];
|
||||
|
||||
// If this update was aborted in a previous step, or has a dependency that was
|
||||
// aborted in a previous step, go no further.
|
||||
if (!empty($context['results']['#abort'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
list($module, $name) = explode('_post_update_', $function, 2);
|
||||
module_load_include('php', $module, $module . '.post_update');
|
||||
if (function_exists($function)) {
|
||||
try {
|
||||
$ret['results']['query'] = $function($context['sandbox']);
|
||||
$ret['results']['success'] = TRUE;
|
||||
|
||||
if (!isset($context['sandbox']['#finished']) || (isset($context['sandbox']['#finished']) && $context['sandbox']['#finished'] >= 1)) {
|
||||
\Drupal::service('update.post_update_registry')->registerInvokedUpdates([$function]);
|
||||
}
|
||||
}
|
||||
// @TODO We may want to do different error handling for different exception
|
||||
// types, but for now we'll just log the exception and return the message
|
||||
// for printing.
|
||||
// @see https://www.drupal.org/node/2564311
|
||||
catch (Exception $e) {
|
||||
watchdog_exception('update', $e);
|
||||
|
||||
$variables = Error::decodeException($e);
|
||||
unset($variables['backtrace']);
|
||||
$ret['#abort'] = [
|
||||
'success' => FALSE,
|
||||
'query' => t('%type: @message in %function (line %line of %file).', $variables),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($context['sandbox']['#finished'])) {
|
||||
$context['finished'] = $context['sandbox']['#finished'];
|
||||
unset($context['sandbox']['#finished']);
|
||||
}
|
||||
if (!isset($context['results'][$module][$name])) {
|
||||
$context['results'][$module][$name] = array();
|
||||
}
|
||||
$context['results'][$module][$name] = array_merge($context['results'][$module][$name], $ret);
|
||||
|
||||
if (!empty($ret['#abort'])) {
|
||||
// Record this function in the list of updates that were aborted.
|
||||
$context['results']['#abort'][] = $function;
|
||||
}
|
||||
|
||||
$context['message'] = t('Post updating @module', ['@module' => $module]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -552,7 +613,7 @@ function update_retrieve_dependencies() {
|
|||
// Ensure install file is loaded.
|
||||
module_load_install($module);
|
||||
if (function_exists($function)) {
|
||||
$result = $function();
|
||||
$updated_dependencies = $function();
|
||||
// Each implementation of hook_update_dependencies() returns a
|
||||
// multidimensional, associative array containing some keys that
|
||||
// represent module names (which are strings) and other keys that
|
||||
|
@ -561,9 +622,9 @@ function update_retrieve_dependencies() {
|
|||
// treats strings and integers differently. Therefore, we have to
|
||||
// explicitly loop through the expected array structure here and perform
|
||||
// the merge manually.
|
||||
if (isset($result) && is_array($result)) {
|
||||
foreach ($result as $module => $module_data) {
|
||||
foreach ($module_data as $update => $update_data) {
|
||||
if (isset($updated_dependencies) && is_array($updated_dependencies)) {
|
||||
foreach ($updated_dependencies as $module_name => $module_data) {
|
||||
foreach ($module_data as $update_version => $update_data) {
|
||||
foreach ($update_data as $module_dependency => $update_dependency) {
|
||||
// If there are redundant dependencies declared for the same
|
||||
// update function (so that it is declared to depend on more than
|
||||
|
@ -584,8 +645,8 @@ function update_retrieve_dependencies() {
|
|||
// guaranteed to run before system_update_8003() anyway (within
|
||||
// an individual module, updates are always run in numerical
|
||||
// order).
|
||||
if (!isset($return[$module][$update][$module_dependency]) || $update_dependency > $return[$module][$update][$module_dependency]) {
|
||||
$return[$module][$update][$module_dependency] = $update_dependency;
|
||||
if (!isset($return[$module_name][$update_version][$module_dependency]) || $update_dependency > $return[$module_name][$update_version][$module_dependency]) {
|
||||
$return[$module_name][$update_version][$module_dependency] = $update_dependency;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue