Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -10,9 +10,11 @@ use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Render\Markup;
use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Utility\Error;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Minimum supported version of PHP.
@ -293,7 +295,7 @@ function drupal_get_path($type, $name) {
* @ingroup sanitization
*/
function t($string, array $args = array(), array $options = array()) {
return \Drupal::translation()->translate($string, $args, $options);
return new TranslatableMarkup($string, $args, $options);
}
/**
@ -442,7 +444,7 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE)
}
// Convert strings which are safe to the simplest Markup objects.
if (!($message instanceof Markup) && SafeMarkup::isSafe($message)) {
if (!($message instanceof Markup) && $message instanceof MarkupInterface) {
$message = Markup::create((string) $message);
}
@ -619,9 +621,9 @@ function drupal_valid_test_ua($new_prefix = NULL) {
// string.
$http_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
$user_agent = isset($_COOKIE['SIMPLETEST_USER_AGENT']) ? $_COOKIE['SIMPLETEST_USER_AGENT'] : $http_user_agent;
if (isset($user_agent) && preg_match("/^(simpletest\d+);(.+);(.+);(.+)$/", $user_agent, $matches)) {
if (isset($user_agent) && preg_match("/^(simpletest\d+):(.+):(.+):(.+)$/", $user_agent, $matches)) {
list(, $prefix, $time, $salt, $hmac) = $matches;
$check_string = $prefix . ';' . $time . ';' . $salt;
$check_string = $prefix . ':' . $time . ':' . $salt;
// Read the hash salt prepared by drupal_generate_test_ua().
// This function is called before settings.php is read and Drupal's error
// handlers are set up. While Drupal's error handling may be properly
@ -678,8 +680,8 @@ function drupal_generate_test_ua($prefix) {
}
// Generate a moderately secure HMAC based on the database credentials.
$salt = uniqid('', TRUE);
$check_string = $prefix . ';' . time() . ';' . $salt;
return $check_string . ';' . Crypt::hmacBase64($check_string, $key);
$check_string = $prefix . ':' . time() . ':' . $salt;
return $check_string . ':' . Crypt::hmacBase64($check_string, $key);
}
/**

View file

@ -15,7 +15,6 @@ use Drupal\Component\Utility\SortArray;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Render\Markup;
use Drupal\Core\Render\Renderer;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\PhpStorage\PhpStorageFactory;
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
@ -578,7 +577,7 @@ function drupal_process_states(&$elements) {
// element available, setting #attributes does not make sense, but a wrapper
// is available, so setting #wrapper_attributes makes it work.
$key = ($elements['#type'] == 'item') ? '#wrapper_attributes' : '#attributes';
$elements[$key]['data-drupal-states'] = JSON::encode($elements['#states']);
$elements[$key]['data-drupal-states'] = Json::encode($elements['#states']);
}
/**
@ -1271,7 +1270,7 @@ function drupal_get_updaters() {
if (!isset($updaters)) {
$updaters = \Drupal::moduleHandler()->invokeAll('updater_info');
\Drupal::moduleHandler()->alter('updater_info', $updaters);
uasort($updaters, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
uasort($updaters, array(SortArray::class, 'sortByWeightElement'));
}
return $updaters;
}
@ -1291,7 +1290,7 @@ function drupal_get_filetransfer_info() {
if (!isset($info)) {
$info = \Drupal::moduleHandler()->invokeAll('filetransfer_info');
\Drupal::moduleHandler()->alter('filetransfer_info', $info);
uasort($info, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
uasort($info, array(SortArray::class, 'sortByWeightElement'));
}
return $info;
}

View file

@ -6,6 +6,8 @@
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
/**
* Clears the entity render cache for all entity types.
@ -468,7 +470,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
// configuration entries are only created when a display object is explicitly
// configured and saved.
if (!$display) {
$display = entity_create('entity_view_display', array(
$display = EntityViewDisplay::create(array(
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $view_mode,
@ -544,7 +546,7 @@ function entity_get_form_display($entity_type, $bundle, $form_mode) {
// configuration entries are only created when an entity form display is
// explicitly configured and saved.
if (!$entity_form_display) {
$entity_form_display = entity_create('entity_form_display', array(
$entity_form_display = EntityFormDisplay::create(array(
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $form_mode,

View file

@ -120,10 +120,10 @@ function error_displayable($error = NULL) {
* with the exception of @message, which needs to be an HTML string, and
* backtrace, which is a standard PHP backtrace.
* @param bool $fatal
* TRUE for:
* TRUE for:
* - An exception is thrown and not caught by something else.
* - A recoverable fatal error, which is a fatal error.
* Non-recoverable fatal errors cannot be logged by Drupal.
* Non-recoverable fatal errors cannot be logged by Drupal.
*/
function _drupal_log_error($error, $fatal = FALSE) {
$is_installer = drupal_installation_attempted();

View file

@ -630,7 +630,8 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
// Allow potentially insecure uploads for very savvy users and admin
if (!\Drupal::config('system.file')->get('allow_insecure_uploads')) {
// Remove any null bytes. See http://php.net/manual/en/security.filesystem.nullbytes.php
// Remove any null bytes. See
// http://php.net/manual/security.filesystem.nullbytes.php
$filename = str_replace(chr(0), '', $filename);
$whitelist = array_unique(explode(' ', strtolower(trim($extensions))));

View file

@ -192,7 +192,7 @@ function template_preprocess_fieldset(&$variables) {
$element = $variables['element'];
Element::setAttributes($element, array('id'));
Element\RenderElement::setAttributes($element);
$variables['attributes'] = $element['#attributes'];
$variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : array();
$variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL;
$variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL;
$variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL;
@ -204,7 +204,13 @@ function template_preprocess_fieldset(&$variables) {
}
$variables['legend']['attributes'] = new Attribute();
$variables['legend_span']['attributes'] = new Attribute();
// Add 'visually-hidden' class to legend span.
if ($variables['title_display'] == 'invisible') {
$variables['legend_span']['attributes'] = new Attribute(array('class' => 'visually-hidden'));
}
else {
$variables['legend_span']['attributes'] = new Attribute();
}
if (!empty($element['#description'])) {
$description_id = $element['#attributes']['id'] . '--description';

View file

@ -1,5 +1,10 @@
<?php
/**
* @file
* API functions for installing Drupal.
*/
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Config\BootstrapConfigStorageFactory;
@ -28,11 +33,6 @@ use Symfony\Component\Routing\Route;
use Drupal\user\Entity\User;
use GuzzleHttp\Exception\RequestException;
/**
* @file
* API functions for installing Drupal.
*/
/**
* Do not run the task during the current installation request.
*
@ -418,13 +418,6 @@ function install_begin_request($class_loader, &$install_state) {
$container->get('string_translation')
->addTranslator($container->get('string_translator.file_translation'));
// Set the default language to the selected language, if any.
if (isset($install_state['parameters']['langcode'])) {
$default_language = new Language(array('id' => $install_state['parameters']['langcode']));
$container->get('language.default')->set($default_language);
\Drupal::translation()->setDefaultLangcode($install_state['parameters']['langcode']);
}
// Add list of all available profiles to the installation state.
$listing = new ExtensionDiscovery($container->get('app.root'));
$listing->setProfileDirectories(array());
@ -443,6 +436,19 @@ function install_begin_request($class_loader, &$install_state) {
}
}
// Use the language from the profile configuration, if available, to override
// the language previously set in the parameters.
if (isset($install_state['profile_info']['distribution']['langcode'])) {
$install_state['parameters']['langcode'] = $install_state['profile_info']['distribution']['langcode'];
}
// Set the default language to the selected language, if any.
if (isset($install_state['parameters']['langcode'])) {
$default_language = new Language(array('id' => $install_state['parameters']['langcode']));
$container->get('language.default')->set($default_language);
\Drupal::translation()->setDefaultLangcode($install_state['parameters']['langcode']);
}
// Override the module list with a minimal set of modules.
$module_handler = \Drupal::moduleHandler();
if (!$module_handler->moduleExists('system')) {
@ -987,7 +993,7 @@ function install_display_output($output, $install_state) {
$default_headers = array(
'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
'Cache-Control' => 'no-cache, must-revalidate, post-check=0, pre-check=0',
'Cache-Control' => 'no-cache, must-revalidate',
'ETag' => '"' . REQUEST_TIME . '"',
);
$response->headers->add($default_headers);
@ -1077,7 +1083,7 @@ function install_verify_completed_task() {
* Verifies that settings.php specifies a valid database connection.
*
* @param string $site_path
* The site path.
* The site path.
*
* @return bool
* TRUE if there are no database errors.
@ -1133,23 +1139,6 @@ function install_database_errors($database, $settings_file) {
Database::addConnectionInfo('default', 'default', $database);
$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'] = \Drupal::service('renderer')->renderPlain($error_message);
}
}
return $errors;
}
@ -1388,7 +1377,7 @@ function install_retrieve_file($uri, $destination) {
* Checks if the localization server can be contacted.
*
* @param string $uri
* The URI to contact.
* The URI to contact.
*
* @return string
* TRUE if the URI was contacted successfully, FALSE if not.
@ -1955,7 +1944,7 @@ function install_check_requirements($install_state) {
$profile = $install_state['parameters']['profile'];
// Check the profile requirements.
$requirements = drupal_check_profile($profile, $install_state);
$requirements = drupal_check_profile($profile);
if ($install_state['settings_verified']) {
return $requirements;

View file

@ -715,11 +715,11 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
* Creates a directory with the specified permissions.
*
* @param $file
* The name of the directory to create;
* The name of the directory to create;
* @param $mask
* The permissions of the directory to create.
* The permissions of the directory to create.
* @param $message
* (optional) Whether to output messages. Defaults to TRUE.
* (optional) Whether to output messages. Defaults to TRUE.
*
* @return
* TRUE/FALSE whether or not the directory was successfully created.
@ -764,11 +764,11 @@ function drupal_install_mkdir($file, $mask, $message = TRUE) {
* 0700 and get the correct value of 0500.
*
* @param $file
* The name of the file with permissions to fix.
* The name of the file with permissions to fix.
* @param $mask
* The desired permissions for the file.
* The desired permissions for the file.
* @param $message
* (optional) Whether to output messages. Defaults to TRUE.
* (optional) Whether to output messages. Defaults to TRUE.
*
* @return
* TRUE/FALSE whether or not we were able to fix the file's permissions.
@ -921,13 +921,11 @@ function drupal_requirements_url($severity) {
*
* @param string $profile
* Name of installation profile to check.
* @param array $install_state
* The current state in the install process.
*
* @return array
* Array of the installation profile's requirements.
*/
function drupal_check_profile($profile, array $install_state) {
function drupal_check_profile($profile) {
$info = install_profile_info($profile);
// Collect requirement testing results.

View file

@ -169,6 +169,7 @@ function pager_get_query_parameters() {
* one page.
* - #parameters: An associative array of query string parameters to append
* to the pager links.
* - #route_parameters: An associative array of the route parameters.
* - #quantity: The number of pages in the list.
*/
function template_preprocess_pager(&$variables) {
@ -176,6 +177,7 @@ function template_preprocess_pager(&$variables) {
$parameters = $variables['pager']['#parameters'];
$quantity = $variables['pager']['#quantity'];
$route_name = $variables['pager']['#route_name'];
$route_parameters = isset($variables['pager']['#route_parameters']) ? $variables['pager']['#route_parameters'] : [];
global $pager_page_array, $pager_total;
// Nothing to do if there is only one page.
@ -218,7 +220,7 @@ function template_preprocess_pager(&$variables) {
$options = array(
'query' => pager_query_add_page($parameters, $element, 0),
);
$items['first']['href'] = \Drupal::url($route_name, [], $options);
$items['first']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[0])) {
$items['first']['text'] = $tags[0];
}
@ -227,7 +229,7 @@ function template_preprocess_pager(&$variables) {
$options = array(
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
);
$items['previous']['href'] = \Drupal::url($route_name, [], $options);
$items['previous']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[1])) {
$items['previous']['text'] = $tags[1];
}
@ -243,7 +245,7 @@ function template_preprocess_pager(&$variables) {
$options = array(
'query' => pager_query_add_page($parameters, $element, $i - 1),
);
$items['pages'][$i]['href'] = \Drupal::url($route_name, [], $options);
$items['pages'][$i]['href'] = \Drupal::url($route_name, $route_parameters, $options);
if ($i == $pager_current) {
$variables['current'] = $i;
}
@ -260,7 +262,7 @@ function template_preprocess_pager(&$variables) {
$options = array(
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
);
$items['next']['href'] = \Drupal::url($route_name, [], $options);
$items['next']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[3])) {
$items['next']['text'] = $tags[3];
}
@ -269,7 +271,7 @@ function template_preprocess_pager(&$variables) {
$options = array(
'query' => pager_query_add_page($parameters, $element, $pager_max - 1),
);
$items['last']['href'] = \Drupal::url($route_name, [], $options);
$items['last']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[4])) {
$items['last']['text'] = $tags[4];
}

View file

@ -1,9 +1,5 @@
<?php
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;
/**
* @file
* Functions to aid in the creation of sortable tables.
@ -13,6 +9,10 @@ use Drupal\Component\Utility\UrlHelper;
* column.
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;
/**
* Initializes the table sort context.
*/

View file

@ -11,7 +11,6 @@
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\Core\Config\Config;
@ -94,6 +93,21 @@ function theme_get_registry($complete = TRUE) {
}
}
/**
* Returns an array of default theme features.
*
* @see \Drupal\Core\Extension\ThemeHandler::$defaultFeatures
*/
function _system_default_theme_features() {
return array(
'favicon',
'logo',
'node_user_picture',
'comment_user_picture',
'comment_user_verification',
);
}
/**
* Forces the system to rebuild the theme registry.
*
@ -401,7 +415,7 @@ function theme_render_and_autoescape($arg) {
$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
// http://php.net/manual/language.oop5.magic.php#object.tostring so
// we also support a toString method.
elseif (method_exists($arg, 'toString')) {
$return = $arg->toString();
@ -413,7 +427,7 @@ function theme_render_and_autoescape($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);
return $return instanceof MarkupInterface ? $return : Html::escape($return);
}
// This is a normal render array, which is safe by definition, with special
@ -568,9 +582,8 @@ function template_preprocess_datetime_wrapper(&$variables) {
*
* @param array $variables
* An associative array containing:
* - links: An associative array of links to be themed. The key for each link
* is used as its CSS class. Each link should be itself an array, with the
* following elements:
* - links: An array of links to be themed. Each link should be itself an
* array, with the following elements:
* - title: The link text.
* - url: (optional) The url object to link to. If omitted, no a tag is
* printed out.

View file

@ -29,26 +29,25 @@ function unicode_requirements() {
'value' => $libraries[$library],
'severity' => $severities[$library],
);
$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="http://php.net/mbstring">PHP mbstring extension</a> for improved Unicode support.');
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="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
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="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
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="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
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="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
break;
}