Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -170,7 +170,7 @@ function _batch_progress_page() {
$build = array(
'#theme' => 'progress_bar',
'#percent' => $percentage,
'#message' => $message,
'#message' => array('#markup' => $message),
'#label' => $label,
'#attached' => array(
'html_head' => array(
@ -406,6 +406,7 @@ function _batch_next_set() {
*/
function _batch_finished() {
$batch = &batch_get();
$batch_finished_redirect = NULL;
// Execute the 'finished' callbacks for each batch set, if defined.
foreach ($batch['sets'] as $batch_set) {
@ -417,7 +418,13 @@ function _batch_finished() {
if (is_callable($batch_set['finished'])) {
$queue = _batch_queue($batch_set);
$operations = $queue->getAllItems();
call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)));
$batch_set_result = call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)));
// If a batch 'finished' callback requested a redirect after the batch
// is complete, save that for later use. If more than one batch set
// returned a redirect, the last one is used.
if ($batch_set_result instanceof RedirectResponse) {
$batch_finished_redirect = $batch_set_result;
}
}
}
}
@ -448,8 +455,13 @@ function _batch_finished() {
\Drupal::request()->query->set('destination', $_batch['destination']);
}
// Determine the target path to redirect to.
if (!isset($_batch['form_state'])) {
// Determine the target path to redirect to. If a batch 'finished' callback
// returned a redirect response object, use that. Otherwise, fall back on
// the form redirection.
if (isset($batch_finished_redirect)) {
return $batch_finished_redirect;
}
elseif (!isset($_batch['form_state'])) {
$_batch['form_state'] = new FormState();
}
if ($_batch['form_state']->getRedirect() === NULL) {

View file

@ -7,6 +7,7 @@
use Drupal\Component\Datetime\DateTimePlus;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Environment;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\DrupalKernel;
@ -278,89 +279,6 @@ function drupal_get_path($type, $name) {
return dirname(drupal_get_filename($type, $name));
}
/**
* Sets an HTTP response header for the current page.
*
* Note: When sending a Content-Type header, always include a 'charset' type,
* too. This is necessary to avoid security bugs (e.g. UTF-7 XSS).
*
* @param $name
* The HTTP header name, or the special 'Status' header name.
* @param $value
* The HTTP header value; if equal to FALSE, the specified header is unset.
* If $name is 'Status', this is expected to be a status code followed by a
* reason phrase, e.g. "404 Not Found".
* @param $append
* Whether to append the value to an existing header or to replace it.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Symfony\Component\HttpFoundation\Response->headers->set().
* See https://www.drupal.org/node/2181523.
*/
function _drupal_add_http_header($name, $value, $append = FALSE) {
// The headers as name/value pairs.
$headers = &drupal_static('drupal_http_headers', array());
$name_lower = strtolower($name);
_drupal_set_preferred_header_name($name);
if ($value === FALSE) {
$headers[$name_lower] = FALSE;
}
elseif (isset($headers[$name_lower]) && $append) {
// Multiple headers with identical names may be combined using comma (RFC
// 2616, section 4.2).
$headers[$name_lower] .= ',' . $value;
}
else {
$headers[$name_lower] = $value;
}
}
/**
* Gets the HTTP response headers for the current page.
*
* @param $name
* An HTTP header name. If omitted, all headers are returned as name/value
* pairs. If an array value is FALSE, the header has been unset.
*
* @return
* A string containing the header value, or FALSE if the header has been set,
* or NULL if the header has not been set.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Symfony\Component\HttpFoundation\Response->headers->get().
* See https://www.drupal.org/node/2181523.
*/
function drupal_get_http_header($name = NULL) {
$headers = &drupal_static('drupal_http_headers', array());
if (isset($name)) {
$name = strtolower($name);
return isset($headers[$name]) ? $headers[$name] : NULL;
}
else {
return $headers;
}
}
/**
* Sets the preferred name for the HTTP header.
*
* Header names are case-insensitive, but for maximum compatibility they should
* follow "common form" (see RFC 2616, section 4.2).
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* See https://www.drupal.org/node/2181523.
*/
function _drupal_set_preferred_header_name($name = NULL) {
static $header_names = array();
if (!isset($name)) {
return $header_names;
}
$header_names[strtolower($name)] = $name;
}
/**
* Translates a string to the current language or to a given language.
*
@ -426,8 +344,11 @@ function t($string, array $args = array(), array $options = array()) {
* @see \Drupal\Component\Utility\SafeMarkup::format()
* @see t()
* @ingroup sanitization
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal\Component\Utility\SafeMarkup::format().
*/
function format_string($string, array $args = array()) {
function format_string($string, array $args) {
return SafeMarkup::format($string, $args);
}
@ -456,6 +377,9 @@ function format_string($string, array $args = array()) {
* TRUE if the text is valid UTF-8, FALSE if not.
*
* @see \Drupal\Component\Utility\Unicode::validateUtf8()
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal\Component\Utility\Unicode::validateUtf8().
*/
function drupal_validate_utf8($text) {
return Unicode::validateUtf8($text);
@ -488,10 +412,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
// Use a default value if $message is not set.
if (empty($message)) {
// The exception message is run through
// \Drupal\Component\Utility\SafeMarkup::checkPlain() by
// \Drupal\Core\Utility\Error:decodeException().
$message = '%type: !message in %function (line %line of %file).';
$message = '%type: @message in %function (line %line of %file).';
}
if ($link) {
@ -514,7 +435,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 $message
* @param string|\Drupal\Component\Utility\SafeStringInterface $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.
@ -561,12 +482,15 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE)
$_SESSION['messages'][$type] = array();
}
$new = array(
'safe' => SafeMarkup::isSafe($message),
'message' => (string) $message,
);
if ($repeat || !in_array($new, $_SESSION['messages'][$type])) {
$_SESSION['messages'][$type][] = $new;
// 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);
}
// Do not use strict type checking so that equivalent string and
// SafeStringInterface objects are detected.
if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
$_SESSION['messages'][$type][] = $message;
}
// Mark this page as being uncacheable.
@ -604,18 +528,6 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE)
*/
function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
if ($messages = drupal_set_message()) {
foreach ($messages as $message_type => $message_typed_messages) {
foreach ($message_typed_messages as $key => $message) {
// Because the messages are stored in the session, the safe status of
// the messages also needs to be stored in the session. We retrieve the
// safe status here and determine whether to mark the string as safe or
// let autoescape do its thing. See drupal_set_message().
if ($message['safe']) {
$message['message'] = SafeMarkup::set($message['message']);
}
$messages[$message_type][$key] = $message['message'];
}
}
if ($type) {
if ($clear_queue) {
unset($_SESSION['messages'][$type]);
@ -1042,10 +954,16 @@ function drupal_static_reset($name = NULL) {
/**
* Formats text for emphasized display in a placeholder inside a sentence.
*
* @see \Drupal\Component\Utility\SafeMarkup::placeholder()
* @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.
*
* @see \Drupal\Component\Utility\SafeMarkup::format()
*/
function drupal_placeholder($text) {
return SafeMarkup::placeholder($text);
return '<em class="placeholder">' . Html::escape($text) . '</em>';
}
/**

View file

@ -22,6 +22,7 @@ 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\Renderer;
use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
@ -270,7 +271,7 @@ function valid_email_address($mail) {
* @param $uri
* A plain-text URI that might contain dangerous protocols.
*
* @return
* @return string
* A URI stripped of dangerous protocols and encoded for output to an HTML
* attribute value. Because it is already encoded, it should not be set as a
* value within a $attributes array passed to Drupal\Core\Template\Attribute,
@ -280,10 +281,20 @@ function valid_email_address($mail) {
* \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() instead.
*
* @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols()
* @see \Drupal\Component\Utility\SafeMarkup::checkPlain()
* @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol()
* instead. UrlHelper::stripDangerousProtocols() can be used in conjunction
* with \Drupal\Component\Utility\SafeMarkup::format() and an @variable
* placeholder which will perform the necessary escaping.
* UrlHelper::filterBadProtocol() is functionality equivalent to check_url()
* apart from the fact it is protected from double escaping bugs. Note that
* this method no longer marks its output as safe.
*
*/
function check_url($uri) {
return SafeMarkup::checkPlain(UrlHelper::stripDangerousProtocols($uri));
return Html::escape(UrlHelper::stripDangerousProtocols($uri));
}
/**
@ -366,6 +377,9 @@ function format_size($size, $langcode = NULL) {
* A translated date string in the requested format.
*
* @see \Drupal\Core\Datetime\DateFormatter::format()
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal::service('date.formatter')->format().
*/
function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
return \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode);
@ -487,7 +501,7 @@ function _drupal_add_html_head_link($attributes, $header = FALSE) {
if ($header) {
// Also add a HTTP header "Link:".
$href = '<' . SafeMarkup::checkPlain($attributes['href']) . '>;';
$href = '<' . Html::escape($attributes['href']) . '>;';
unset($attributes['href']);
$element['#attached']['http_header'][] = array('Link', $href . drupal_http_header_attributes($attributes), TRUE);
}
@ -517,7 +531,6 @@ function drupal_js_defaults($data = NULL) {
return array(
'type' => 'file',
'group' => JS_DEFAULT,
'every_page' => FALSE,
'weight' => 0,
'scope' => 'header',
'cache' => TRUE,
@ -642,7 +655,7 @@ function drupal_process_attached(array $elements) {
call_user_func_array('_drupal_add_html_head_link', $args);
break;
case 'http_header':
call_user_func_array('_drupal_add_http_header', $args);
// @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));
@ -1084,8 +1097,9 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
* can be passed in to save another run of
* \Drupal\Core\Render\Element::children().
*
* @return string
* @return string|\Drupal\Component\Utility\SafeStringInterface
* The rendered HTML of all children of the element.
*
* @see drupal_render()
*/
function drupal_render_children(&$element, $children_keys = NULL) {
@ -1098,7 +1112,7 @@ function drupal_render_children(&$element, $children_keys = NULL) {
$output .= drupal_render($element[$key]);
}
}
return SafeMarkup::set($output);
return SafeString::create($output);
}
/**
@ -1196,7 +1210,7 @@ function show(&$element) {
* Retrieves the default properties for the defined element type.
*
* @param $type
* An element type as defined by hook_element_info().
* An element type as defined by an element plugin.
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal::service('element_info')->getInfo() instead.
@ -1209,7 +1223,7 @@ function element_info($type) {
* Retrieves a single property for the defined element type.
*
* @param $type
* An element type as defined by hook_element_info().
* An element type as defined by an element plugin.
* @param $property_name
* The property within the element type that should be returned.
* @param $default
@ -1376,7 +1390,7 @@ function _drupal_flush_css_js() {
*/
function debug($data, $label = NULL, $print_r = TRUE) {
// Print $data contents to string.
$string = SafeMarkup::checkPlain($print_r ? print_r($data, TRUE) : var_export($data, TRUE));
$string = Html::escape($print_r ? print_r($data, TRUE) : var_export($data, TRUE));
// Display values with pre-formatting to increase readability.
$string = '<pre>' . $string . '</pre>';

View file

@ -666,7 +666,6 @@ function db_field_exists($table, $field) {
*
* @param string $table_expression
* An SQL expression, for example "simpletest%" (without the quotes).
* BEWARE: this is not prefixed, the caller should take care of that.
*
* @return array
* Array, both the keys and the values are the matching tables.
@ -905,16 +904,22 @@ function db_drop_unique_key($table, $name) {
* The name of the index.
* @param array $fields
* An array of field names.
* @param array $spec
* The table specification of the table to be altered, as taken from a schema
* definition. See \Drupal\Core\Database\Schema::addIndex() for how to obtain
* this specification.
*
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
* a database connection injected into your service from the container, get
* its schema driver, and call addIndex() on it. E.g.
* $injected_database->schema()->addIndex($table, $name, $fields);
* $injected_database->schema()->addIndex($table, $name, $fields, $spec);
*
* @see hook_schema()
* @see schemaapi
* @see \Drupal\Core\Database\Schema::addIndex()
*/
function db_add_index($table, $name, $fields) {
return Database::getConnection()->schema()->addIndex($table, $name, $fields);
function db_add_index($table, $name, $fields, array $spec) {
return Database::getConnection()->schema()->addIndex($table, $name, $fields, $spec);
}
/**

View file

@ -403,7 +403,7 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
}
/**
* Returns the entity view display associated to a bundle and view mode.
* Returns the entity view display associated with a bundle and view mode.
*
* Use this function when assigning suggested display options for a component
* in a given view mode. Note that they will only be actually used at render
@ -439,24 +439,24 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
* this bundle.
*
* @return \Drupal\Core\Entity\Display\EntityViewDisplayInterface
* The entity view display associated to the view mode.
* The entity view display associated with the view mode.
*
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
* If the display is available in configuration use:
* @code
* @code
* \Drupal::entityManager()->getStorage('entity_view_display')->load($entity_type . '.' . $bundle . '.' . $view_mode);
* @endcode
* @endcode
* When the display is not available in configuration, you can create a new
* EntityViewDisplay object using:
* @code
* $values = ('entity_view_display', array(
* 'targetEntityType' => $entity_type,
* 'bundle' => $bundle,
* 'mode' => $view_mode,
* 'status' => TRUE,
* ));
* \Drupal::entityManager()->getStorage('entity_view_display')->create($values);
* @endcode
* @code
* $values = array(
* 'targetEntityType' => $entity_type,
* 'bundle' => $bundle,
* 'mode' => $view_mode,
* 'status' => TRUE,
* ));
* \Drupal::entityManager()->getStorage('entity_view_display')->create($values);
* @endcode
*
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
* @see \Drupal\Core\Entity\EntityStorageInterface::load()
@ -483,7 +483,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
}
/**
* Returns the entity form display associated to a bundle and form mode.
* Returns the entity form display associated with a bundle and form mode.
*
* The function reads the entity form display object from the current
* configuration, or returns a ready-to-use empty one if no configuration entry
@ -515,7 +515,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
* The form mode.
*
* @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface
* The entity form display associated to the given form mode.
* The entity form display associated with the given form mode.
*
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
* If the entity form display is available in configuration use:

View file

@ -8,6 +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\Utility\Error;
use Symfony\Component\HttpFoundation\Response;
@ -68,7 +69,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
'%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' => Xss::filterAdmin($message),
'@message' => SafeString::create(Xss::filterAdmin($message)),
'%function' => $caller['function'],
'%file' => $caller['file'],
'%line' => $caller['line'],
@ -109,9 +110,9 @@ function error_displayable($error = NULL) {
* Logs a PHP error or exception and displays an error page in fatal cases.
*
* @param $error
* An array with the following keys: %type, !message, %function, %file,
* An array with the following keys: %type, @message, %function, %file,
* %line, severity_level, and backtrace. All the parameters are plain-text,
* with the exception of !message, which needs to be a safe HTML string, and
* with the exception of @message, which needs to be an HTML string, and
* backtrace, which is a standard PHP backtrace.
* @param $fatal
* TRUE if the error is fatal.
@ -130,7 +131,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
// as it uniquely identifies each PHP error.
static $number = 0;
$assertion = array(
$error['!message'],
$error['@message'],
$error['%type'],
array(
'function' => $error['%function'],
@ -154,12 +155,12 @@ function _drupal_log_error($error, $fatal = FALSE) {
// installer.
if (\Drupal::hasService('logger.factory')) {
try {
\Drupal::logger('php')->log($error['severity_level'], '%type: !message in %function (line %line of %file).', $error);
\Drupal::logger('php')->log($error['severity_level'], '%type: @message in %function (line %line of %file).', $error);
}
catch (\Exception $e) {
// We can't log, for example because the database connection is not
// available. At least try to log to PHP error log.
error_log(sprintf('Failed to log error: %type: !message in %function (line %line of %file).', $error['%type'], $error['%function'], $error['%line'], $error['%file']));
error_log(strtr('Failed to log error: %type: @message in %function (line %line of %file).', $error));
}
}
@ -167,7 +168,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(format_string('%type: !message in %function (line %line of %file).', $error))). "\n");
$response->setContent(html_entity_decode(strip_tags(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error))). "\n");
$response->send();
exit;
}
@ -178,7 +179,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(format_string('%type: !message in %function (line %line of %file).', $error));
$response->setContent(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error));
$response->send();
}
exit;
@ -208,20 +209,29 @@ function _drupal_log_error($error, $fatal = FALSE) {
$error['%file'] = substr($error['%file'], $root_length + 1);
}
}
// Should not translate the string to avoid errors producing more errors.
$message = format_string('%type: !message in %function (line %line of %file).', $error);
// Check if verbose error reporting is on.
$error_level = _drupal_get_error_level();
if ($error_level == ERROR_REPORTING_DISPLAY_VERBOSE) {
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);
}
else {
// With verbose logging, we will also include a backtrace.
// First trace is the error itself, already contained in the message.
// While the second trace is the error source and also contained in the
// message, the message doesn't contain argument values, so we output it
// once more in the backtrace.
array_shift($backtrace);
// Generate a backtrace containing only scalar argument values.
$message .= '<pre class="backtrace">' . Error::formatBacktrace($backtrace) . '</pre>';
$error['@backtrace'] = Error::formatBacktrace($backtrace);
$message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
}
}
@ -248,10 +258,11 @@ function _drupal_log_error($error, $fatal = FALSE) {
// An exception must halt script execution.
exit;
}
else {
if ($message) {
if (\Drupal::hasService('session')) {
// Message display is dependent on sessions being available.
drupal_set_message(SafeMarkup::set($message), $class, TRUE);
drupal_set_message($message, $class, TRUE);
}
else {
print $message;

View file

@ -5,11 +5,11 @@
* API for handling file uploads and server file management.
*/
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\PhpStorage\FileStorage;
use Drupal\Component\Utility\Bytes;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\File\FileSystem;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
@ -371,7 +371,7 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS
return drupal_chmod($htaccess_path, 0444);
}
else {
$variables = array('%directory' => $directory, '!htaccess' => '<br />' . nl2br(SafeMarkup::checkPlain($htaccess_lines)));
$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);
return FALSE;
}

View file

@ -206,7 +206,10 @@ function template_preprocess_fieldset(&$variables) {
$variables['children'] = $element['#children'];
$variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL;
$variables['legend']['title'] = (isset($element['#title']) && $element['#title'] !== '') ? Xss::filterAdmin($element['#title']) : '';
if (isset($element['#title']) && $element['#title'] !== '') {
$variables['legend']['title'] = ['#markup' => $element['#title']];
}
$variables['legend']['attributes'] = new Attribute();
$variables['legend_span']['attributes'] = new Attribute();
@ -373,7 +376,7 @@ function template_preprocess_textarea(&$variables) {
Element\RenderElement::setAttributes($element, array('form-textarea'));
$variables['wrapper_attributes'] = new Attribute();
$variables['attributes'] = new Attribute($element['#attributes']);
$variables['value'] = SafeMarkup::checkPlain($element['#value']);
$variables['value'] = $element['#value'];
$variables['resizable'] = !empty($element['#resizable']) ? $element['#resizable'] : NULL;
$variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL;
}
@ -504,7 +507,10 @@ function template_preprocess_form_element(&$variables) {
function template_preprocess_form_element_label(&$variables) {
$element = $variables['element'];
// If title and required marker are both empty, output no label.
$variables['title'] = (isset($element['#title']) && $element['#title'] !== '') ? Xss::filterAdmin($element['#title']) : '';
if (isset($element['#title']) && $element['#title'] !== '') {
$variables['title'] = ['#markup' => $element['#title']];
}
$variables['attributes'] = array();
// Pass elements title_display to template.
@ -770,7 +776,14 @@ function batch_set($batch_definition) {
*
* @param \Drupal\Core\Url|string $redirect
* (optional) Either path or Url object to redirect to when the batch has
* finished processing.
* finished processing. Note that to simply force a batch to (conditionally)
* redirect to a custom location after it is finished processing but to
* otherwise allow the standard form API batch handling to occur, it is not
* necessary to call batch_process() and use this parameter. Instead, make
* the batch 'finished' callback return an instance of
* \Symfony\Component\HttpFoundation\RedirectResponse, which will be used
* automatically by the standard batch processing pipeline (and which takes
* precedence over this parameter).
* @param \Drupal\Core\Url $url
* (optional - should only be used for separate scripts like update.php)
* URL of the batch processing page.

View file

@ -6,7 +6,6 @@ use Drupal\Core\DrupalKernel;
use Drupal\Core\Config\BootstrapConfigStorageFactory;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\Database\Install\TaskException;
use Drupal\Core\Form\FormState;
use Drupal\Core\Installer\Exception\AlreadyInstalledException;
use Drupal\Core\Installer\Exception\InstallerException;
@ -1133,14 +1132,24 @@ function install_database_errors($database, $settings_file) {
// Run tasks associated with the database type. Any errors are caught in the
// calling function.
Database::addConnectionInfo('default', 'default', $database);
try {
db_run_tasks($driver);
}
catch (TaskException $e) {
$errors = db_installer_object($driver)->runTasks();
if (count($errors)) {
$error_message = [
'#type' => 'inline_template',
'#template' => '{% trans %}Resolve all issues below to continue the installation. For help configuring your database server, see the <a href="https://www.drupal.org/getting-started/install">installation handbook</a>, or contact your hosting provider.{% endtrans%}{{ errors }}',
'#context' => [
'errors' => [
'#theme' => 'item_list',
'#items' => $errors,
],
],
];
// These are generic errors, so we do not have any specific key of the
// database connection array to attach them to; therefore, we just put
// them in the error array with standard numeric keys.
$errors[$driver . '][0'] = $e->getMessage();
$errors[$driver . '][0'] = \Drupal::service('renderer')->renderPlain($error_message);
}
}
return $errors;
@ -1590,6 +1599,10 @@ function install_bootstrap_full() {
* The batch definition.
*/
function install_profile_modules(&$install_state) {
// We need to manually trigger the installation of core-provided entity types,
// as those will not be handled by the module installer.
install_core_entity_type_definitions();
$modules = \Drupal::state()->get('install_profile_modules') ?: array();
$files = system_rebuild_module_data();
\Drupal::state()->delete('install_profile_modules');
@ -1629,6 +1642,18 @@ function install_profile_modules(&$install_state) {
return $batch;
}
/**
* Installs entity type definitions provided by core.
*/
function install_core_entity_type_definitions() {
$update_manager = \Drupal::entityDefinitionUpdateManager();
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type) {
if ($entity_type->getProvider() == 'core') {
$update_manager->installEntityType($entity_type);
}
}
}
/**
* Installs themes.
*
@ -1656,12 +1681,6 @@ function install_profile_themes(&$install_state) {
* An array of information about the current installation state.
*/
function install_install_profile(&$install_state) {
// Now that all modules are installed, make sure the entity storage and other
// handlers are up to date with the current entity and field definitions. For
// example, Path module adds a base field to nodes and taxonomy terms after
// those modules are already installed.
\Drupal::service('entity.definition_update_manager')->applyUpdates();
\Drupal::service('module_installer')->install(array(drupal_get_profile()), FALSE);
// Install all available optional config. During installation the module order
// is determined by dependencies. If there are no dependencies between modules
@ -2033,7 +2052,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' => check_url($_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' => UrlHelper::stripDangerousProtocols($_SERVER['SCRIPT_NAME']))),
);
}
else {
@ -2052,7 +2071,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' => check_url($_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' => UrlHelper::stripDangerousProtocols($_SERVER['SCRIPT_NAME']))),
);
}
}
@ -2083,13 +2102,6 @@ function install_check_requirements($install_state) {
'description_default' => t('The default settings file does not exist.'),
'title' => t('Settings file'),
);
$default_files['services.yml'] = array(
'file' => 'services.yml',
'file_default' => 'default.services.yml',
'title_default' => t('Default services file'),
'description_default' => t('The default services file does not exist.'),
'title' => t('Services file'),
);
foreach ($default_files as $default_file_info) {
$readable = FALSE;
@ -2269,11 +2281,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' => check_url(drupal_requirements_url(REQUIREMENT_ERROR)), '!cont' => check_url(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' => UrlHelper::stripDangerousProtocols(drupal_requirements_url(REQUIREMENT_ERROR)), '@cont' => UrlHelper::stripDangerousProtocols(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' => check_url(drupal_requirements_url($severity))));
$build['#suffix'] = t('Check the messages and <a href="@url">try again</a>.', array('@url' => UrlHelper::stripDangerousProtocols(drupal_requirements_url($severity))));
}
return $build;
}

View file

@ -210,7 +210,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
}
$variable_names['$'. $setting] = $setting;
}
$contents = file_get_contents(DRUPAL_ROOT . '/' . $settings_file);
$contents = file_get_contents($settings_file);
if ($contents !== FALSE) {
// Initialize the contents for the settings.php file if it is empty.
if (trim($contents) === '') {
@ -315,7 +315,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
}
// Write the new settings file.
if (file_put_contents(DRUPAL_ROOT . '/' . $settings_file, $buffer) === FALSE) {
if (file_put_contents($settings_file, $buffer) === FALSE) {
throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
}
else {
@ -864,9 +864,11 @@ function install_goto($path) {
* @return
* The URL of the current script, with query parameters modified by the
* passed-in $query. The URL is not sanitized, so it still needs to be run
* through check_url() if it will be used as an HTML attribute value.
* through \Drupal\Component\Utility\UrlHelper::filterBadProtocol() if it will be
* used as an HTML attribute value.
*
* @see drupal_requirements_url()
* @see Drupal\Component\Utility\UrlHelper::filterBadProtocol()
*/
function drupal_current_script_url($query = array()) {
$uri = $_SERVER['SCRIPT_NAME'];
@ -890,10 +892,12 @@ function drupal_current_script_url($query = array()) {
*
* @return
* A URL for attempting to proceed to the next step of the script. The URL is
* not sanitized, so it still needs to be run through check_url() if it will
* be used as an HTML attribute value.
* not sanitized, so it still needs to be run through
* \Drupal\Component\Utility\UrlHelper::filterBadProtocol() if it will be used
* as an HTML attribute value.
*
* @see drupal_current_script_url()
* @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
*/
function drupal_requirements_url($severity) {
$query = array();
@ -1068,19 +1072,6 @@ function install_profile_info($profile, $langcode = 'en') {
return $cache[$profile][$langcode];
}
/**
* Ensures the environment for a Drupal database on a predefined connection.
*
* This will run tasks that check that Drupal can perform all of the functions
* on a database, that Drupal needs. Tasks include simple checks like CREATE
* TABLE to database specific functions like stored procedures and client
* encoding.
*/
function db_run_tasks($driver) {
db_installer_object($driver)->runTasks();
return TRUE;
}
/**
* Returns a database installer object.
*

View file

@ -93,7 +93,7 @@ function menu_list_system_menus() {
}
/**
* Collects the local tasks (tabs), action links, and the root path.
* Collects the local tasks (tabs) for the current route.
*
* @param int $level
* The level of tasks you ask for. Primary tasks are 0, secondary are 1.
@ -101,95 +101,45 @@ function menu_list_system_menus() {
* @return array
* An array containing
* - tabs: Local tasks for the requested level.
* - actions: Action links for the requested level.
* - root_path: The router path for the current page. If the current page is
* a default local task, then this corresponds to the parent tab.
* - route_name: The route name for the current page used to collect the local
* tasks.
*
* @see hook_menu_local_tasks()
* @see hook_menu_local_tasks_alter()
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
*/
function menu_local_tasks($level = 0) {
$data = &drupal_static(__FUNCTION__);
$root_path = &drupal_static(__FUNCTION__ . ':root_path', '');
$empty = array(
'tabs' => array(),
'actions' => array(),
'root_path' => &$root_path,
);
if (!isset($data)) {
// Look for route-based tabs.
$data['tabs'] = array();
$data['actions'] = array();
$route_name = \Drupal::routeMatch()->getRouteName();
if (!\Drupal::request()->attributes->has('exception') && !empty($route_name)) {
$manager = \Drupal::service('plugin.manager.menu.local_task');
$local_tasks = $manager->getTasksBuild($route_name);
foreach ($local_tasks as $level => $items) {
$data['tabs'][$level] = empty($data['tabs'][$level]) ? $items : array_merge($data['tabs'][$level], $items);
}
}
// Allow modules to dynamically add further tasks.
$module_handler = \Drupal::moduleHandler();
foreach ($module_handler->getImplementations('menu_local_tasks') as $module) {
$function = $module . '_menu_local_tasks';
$function($data, $route_name);
}
// Allow modules to alter local tasks.
$module_handler->alter('menu_local_tasks', $data, $route_name);
}
if (isset($data['tabs'][$level])) {
return array(
'tabs' => $data['tabs'][$level],
'actions' => $data['actions'],
'root_path' => $root_path,
);
}
elseif (!empty($data['actions'])) {
return array('actions' => $data['actions']) + $empty;
}
return $empty;
/** @var \Drupal\Core\Menu\LocalTaskManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.menu.local_task');
return $manager->getLocalTasks(\Drupal::routeMatch()->getRouteName(), $level);
}
/**
* Returns the rendered local tasks at the top level.
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
*/
function menu_primary_local_tasks() {
$links = menu_local_tasks(0);
/** @var \Drupal\Core\Menu\LocalTaskManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.menu.local_task');
$links = $manager->getLocalTasks(\Drupal::routeMatch()->getRouteName(), 0);
// Do not display single tabs.
return count(Element::getVisibleChildren($links['tabs'])) > 1 ? $links['tabs'] : '';
}
/**
* Returns the rendered local tasks at the second level.
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
*/
function menu_secondary_local_tasks() {
$links = menu_local_tasks(1);
/** @var \Drupal\Core\Menu\LocalTaskManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.menu.local_task');
$links = $manager->getLocalTasks(\Drupal::routeMatch()->getRouteName(), 1);
// Do not display single tabs.
return count(Element::getVisibleChildren($links['tabs'])) > 1 ? $links['tabs'] : '';
}
/**
* Returns the rendered local actions at the current level.
*/
function menu_get_local_actions() {
$links = menu_local_tasks();
$route_name = Drupal::routeMatch()->getRouteName();
$manager = \Drupal::service('plugin.manager.menu.local_action');
return $manager->getActionsForRoute($route_name) + $links['actions'];
}
/**
* Returns the router path, or the path for a default local task's parent.
*/
function menu_tab_root_path() {
$links = menu_local_tasks();
return $links['root_path'];
}
/**
* Returns a renderable element for the primary and secondary tabs.
*/

View file

@ -250,7 +250,7 @@ function template_preprocess_pager(&$variables) {
}
}
// Add an ellipsis if there are further next pages.
if ($i < $pager_max) {
if ($i < $pager_max + 1) {
$variables['ellipses']['next'] = TRUE;
}
}

View file

@ -20,6 +20,7 @@ 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;
/**
* @defgroup content_flags Content markers
@ -115,7 +116,7 @@ function drupal_theme_rebuild() {
*/
function drupal_find_theme_functions($cache, $prefixes) {
$implementations = [];
$grouped_functions = drupal_group_functions_by_prefix();
$grouped_functions = \Drupal::service('theme.registry')->getPrefixGroupedUserFunctions();
foreach ($cache as $hook => $info) {
foreach ($prefixes as $prefix) {
@ -161,25 +162,6 @@ function drupal_find_theme_functions($cache, $prefixes) {
return $implementations;
}
/**
* Group all user functions by word before first underscore.
*
* @return array
* Functions grouped by the first prefix.
*/
function drupal_group_functions_by_prefix() {
$functions = get_defined_functions();
$grouped_functions = [];
// Splitting user defined functions into groups by the first prefix.
foreach ($functions['user'] as $function) {
list($first_prefix,) = explode('_', $function, 2);
$grouped_functions[$first_prefix][] = $function;
}
return $grouped_functions;
}
/**
* Allows themes and/or theme engines to easily discover overridden templates.
*
@ -507,8 +489,8 @@ function template_preprocess_datetime_wrapper(&$variables) {
}
$variables['required'] = FALSE;
// For required datetime fields a 'form-required' class is appended to the
// label attributes.
// For required datetime fields 'form-required' & 'js-form-required' classes
// are appended to the label attributes.
if (!empty($element['#required'])) {
$variables['required'] = TRUE;
}
@ -594,7 +576,6 @@ function template_preprocess_links(&$variables) {
);
// Convert the attributes array into an Attribute object.
$heading['attributes'] = new Attribute($heading['attributes']);
$heading['text'] = SafeMarkup::checkPlain($heading['text']);
}
$variables['links'] = array();
@ -1158,9 +1139,6 @@ function template_preprocess_maintenance_task_list(&$variables) {
* details.
*/
function template_preprocess(&$variables, $hook, $info) {
// Tell all templates where they are located.
$variables['directory'] = \Drupal::theme()->getActiveTheme()->getPath();
// Merge in variables that don't depend on hook and don't change during a
// single page request.
// Use the advanced drupal_static() pattern, since this is called very often.
@ -1203,6 +1181,9 @@ function _template_preprocess_default_variables() {
// Give modules a chance to alter the default template variables.
\Drupal::moduleHandler()->alter('template_preprocess_default_variables', $variables);
// Tell all templates where they are located.
$variables['directory'] = \Drupal::theme()->getActiveTheme()->getPath();
return $variables;
}
@ -1255,9 +1236,14 @@ function template_preprocess_html(&$variables) {
$site_config = \Drupal::config('system.site');
// Construct page title.
if (isset($variables['page']['#title']) && is_array($variables['page']['#title'])) {
// Do an early render if the title is a render array.
$variables['page']['#title'] = (string) \Drupal::service('renderer')->render($variables['page']['#title']);
}
if (!empty($variables['page']['#title'])) {
$head_title = array(
'title' => trim(strip_tags($variables['page']['#title'])),
// Marking the title as safe since it has had the tags stripped.
'title' => SafeString::create(trim(strip_tags($variables['page']['#title']))),
'name' => $site_config->get('name'),
);
}
@ -1295,7 +1281,7 @@ function template_preprocess_html(&$variables) {
'@token' => $token,
]);
$variables[$type]['#markup'] = $placeholder;
$variables[$type]['#attached']['html_response_placeholders'][$type] = $placeholder;
$variables[$type]['#attached']['html_response_attachment_placeholders'][$type] = $placeholder;
}
}
@ -1325,7 +1311,7 @@ function template_preprocess_page(&$variables) {
$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') ? SafeMarkup::checkPlain($site_config->get('name')) : '');
$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.
@ -1338,14 +1324,6 @@ function template_preprocess_page(&$variables) {
$variables['is_front'] = FALSE;
$variables['db_is_active'] = FALSE;
}
if (!defined('MAINTENANCE_MODE')) {
$variables['action_links'] = menu_get_local_actions();
$variables['tabs'] = menu_local_tabs();
}
else {
$variables['action_links'] = array();
$variables['tabs'] = array();
}
if ($node = \Drupal::routeMatch()->getParameter('node')) {
$variables['node'] = $node;
@ -1490,8 +1468,6 @@ function template_preprocess_region(&$variables) {
* - element: A render element representing the field.
* - attributes: A string containing the attributes for the wrapping div.
* - title_attributes: A string containing the attributes for the title.
* - content_attributes: A string containing the attributes for the content's
* div.
*/
function template_preprocess_field(&$variables, $hook) {
$element = $variables['element'];
@ -1506,13 +1482,24 @@ function template_preprocess_field(&$variables, $hook) {
// Always set the field label - allow themes to decide whether to display it.
// In addition the label should be rendered but hidden to support screen
// readers.
$variables['label'] = SafeMarkup::checkPlain($element['#title']);
$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;
static $default_attributes;
if (!isset($default_attributes)) {
$default_attributes = new Attribute;
}
// Merge attributes when a single-value field has a hidden label.
if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && is_object($element['#items'][0])) {
$variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], (array) $element['#items'][0]->_attributes);
}
// We want other preprocess functions and the theme implementation to have
// fast access to the field item render arrays. The item render array keys
// (deltas) should always be numerically indexed starting from 0, and looping
@ -1556,6 +1543,7 @@ function template_preprocess_field_multiple_value_form(&$variables) {
$order_class = $element['#field_name'] . '-delta-order';
$header_attributes = new Attribute(array('class' => array('label')));
if (!empty($element['#required'])) {
$header_attributes['class'][] = 'js-form-required';
$header_attributes['class'][] = 'form-required';
}
$header = array(
@ -1746,17 +1734,10 @@ function drupal_common_theme() {
'maintenance_task_list' => array(
'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL),
),
'authorize_message' => array(
'variables' => array('message' => NULL, 'success' => TRUE),
'function' => 'theme_authorize_message',
'path' => 'core/includes',
'file' => 'theme.maintenance.inc',
),
'authorize_report' => array(
'variables' => array('messages' => array()),
'function' => 'theme_authorize_report',
'path' => 'core/includes',
'file' => 'theme.maintenance.inc',
'variables' => ['messages' => [], 'attributes' => []],
'includes' => ['core/includes/theme.maintenance.inc'],
'template' => 'authorize-report',
),
// From pager.inc.
'pager' => array(

View file

@ -100,64 +100,37 @@ function _drupal_maintenance_theme() {
}
/**
* Returns HTML for a results report of an operation run by authorize.php.
* Prepares variables for authorize.php operation report templates.
*
* @param $variables
* This report displays the results of an operation run via authorize.php.
*
* Default template: authorize-report.html.twig.
*
* @param array $variables
* An associative array containing:
* - messages: An array of result messages.
*
* @ingroup themeable
*/
function theme_authorize_report($variables) {
$messages = $variables['messages'];
$output = '';
if (!empty($messages)) {
$output .= '<div class="authorize-results">';
foreach ($messages as $heading => $logs) {
$items = array();
function template_preprocess_authorize_report(&$variables) {
$messages = [];
if (!empty($variables['messages'])) {
foreach ($variables['messages'] as $heading => $logs) {
$items = [];
foreach ($logs as $number => $log_message) {
if ($number === '#abort') {
continue;
}
$authorize_message = array(
'#theme' => 'authorize_message',
'#message' => $log_message['message'],
'#success' => $log_message['success'],
);
$items[] = drupal_render($authorize_message);
$class = 'authorize-results__' . ($log_message['success'] ? 'success' : 'failure');
$items[] = [
'#wrapper_attributes' => ['class' => [$class]],
'#markup' => $log_message['message'],
];
}
$item_list = array(
$messages[] = [
'#theme' => 'item_list',
'#items' => $items,
'#title' => $heading,
);
$output .= drupal_render($item_list);
];
}
$output .= '</div>';
}
return $output;
}
/**
* Returns HTML for a single log message from the authorize.php batch operation.
*
* @param $variables
* An associative array containing:
* - message: The log message.
* It's the caller's responsibility to ensure this string contains no
* dangerous HTML such as SCRIPT tags.
* - success: A boolean indicating failure or success.
*
* @ingroup themeable
*/
function theme_authorize_message($variables) {
$message = $variables['message'];
$success = $variables['success'];
if ($success) {
$item = array('data' => array('#markup' => $message), 'class' => array('authorize-results__success'));
}
else {
$item = array('data' => array('#markup' => $message), 'class' => array('authorize-results__failure'));
}
return $item;
$variables['messages'] = $messages;
}

View file

@ -9,7 +9,7 @@
*/
use Drupal\Component\Graph\Graph;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Utility\Error;
@ -188,10 +188,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
$variables = Error::decodeException($e);
unset($variables['backtrace']);
// The exception message is run through
// \Drupal\Component\Utility\SafeMarkup::checkPlain() by
// \Drupal\Core\Utility\Error::decodeException().
$ret['#abort'] = array('success' => FALSE, 'query' => t('%type: !message in %function (line %line of %file).', $variables));
$ret['#abort'] = array('success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables));
}
}
@ -218,30 +215,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
drupal_set_installed_schema_version($module, $number);
}
$context['message'] = 'Updating ' . SafeMarkup::checkPlain($module) . ' module';
}
/**
* Performs entity definition updates, which can trigger schema updates.
*
* @param $context
* The batch context array.
*/
function update_entity_definitions(&$context) {
try {
\Drupal::service('entity.definition_update_manager')->applyUpdates();
}
catch (EntityStorageException $e) {
watchdog_exception('update', $e);
$variables = Error::decodeException($e);
unset($variables['backtrace']);
// The exception message is run through
// \Drupal\Component\Utility\SafeMarkup::checkPlain() by
// \Drupal\Core\Utility\Error::decodeException().
$ret['#abort'] = array('success' => FALSE, 'query' => t('%type: !message in %function (line %line of %file).', $variables));
$context['results']['core']['update_entity_definitions'] = $ret;
$context['results']['#abort'][] = 'update_entity_definitions';
}
$context['message'] = 'Updating ' . Html::escape($module) . ' module';
}
/**