Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -34,7 +34,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
function _batch_page(Request $request) {
$batch = &batch_get();
if (!($request_id = $request->get('id'))) {
if (!($request_id = $request->query->get('id'))) {
return FALSE;
}
@ -61,7 +61,7 @@ function _batch_page(Request $request) {
}
}
$op = $request->get('op', '');
$op = $request->query->get('op', '');
switch ($op) {
case 'start':
case 'do_nojs':

View file

@ -1,4 +1,5 @@
<?php
/**
* @file
* Functions that need to be loaded on every Drupal request.
@ -11,6 +12,7 @@ use Drupal\Component\Utility\Unicode;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Render\Markup;
use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\Test\TestDatabase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Utility\Error;
@ -599,7 +601,7 @@ function _drupal_exception_handler_additional($exception, $exception2) {
* @param string $new_prefix
* Internal use only. A new prefix to be stored.
*
* @return string|FALSE
* @return string|false
* Either the simpletest prefix (the string "simpletest" followed by any
* number of digits) or FALSE if the user agent does not contain a valid
* HMAC and timestamp.
@ -622,7 +624,7 @@ 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("/^simple(\w+\d+):(.+):(.+):(.+)$/", $user_agent, $matches)) {
list(, $prefix, $time, $salt, $hmac) = $matches;
$check_string = $prefix . ':' . $time . ':' . $salt;
// Read the hash salt prepared by drupal_generate_test_ua().
@ -630,7 +632,8 @@ function drupal_valid_test_ua($new_prefix = NULL) {
// handlers are set up. While Drupal's error handling may be properly
// configured on production sites, the server's PHP error_reporting may not.
// Ensure that no information leaks on production sites.
$key_file = DRUPAL_ROOT . '/sites/simpletest/' . substr($prefix, 10) . '/.htkey';
$test_db = new TestDatabase($prefix);
$key_file = DRUPAL_ROOT . '/' . $test_db->getTestSitePath() . '/.htkey';
if (!is_readable($key_file)) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
@ -640,11 +643,15 @@ function drupal_valid_test_ua($new_prefix = NULL) {
$key = $private_key . filectime(__FILE__) . fileinode(__FILE__);
$time_diff = REQUEST_TIME - $time;
$test_hmac = Crypt::hmacBase64($check_string, $key);
// Since we are making a local request a 5 second time window is allowed,
// Since we are making a local request a 600 second time window is allowed,
// and the HMAC must match.
if ($time_diff >= 0 && $time_diff <= 5 && $hmac === $test_hmac) {
if ($time_diff >= 0 && $time_diff <= 600 && $hmac === $test_hmac) {
$test_prefix = $prefix;
}
else {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden (SIMPLETEST_USER_AGENT invalid)');
exit;
}
}
return $test_prefix;
}
@ -657,7 +664,8 @@ function drupal_generate_test_ua($prefix) {
if (!isset($key) || $last_prefix != $prefix) {
$last_prefix = $prefix;
$key_file = DRUPAL_ROOT . '/sites/simpletest/' . substr($prefix, 10) . '/.htkey';
$test_db = new TestDatabase($prefix);
$key_file = DRUPAL_ROOT . '/' . $test_db->getTestSitePath() . '/.htkey';
// When issuing an outbound HTTP client request from within an inbound test
// request, then the outbound request has to use the same User-Agent header
// as the inbound request. A newly generated private key for the same test
@ -682,7 +690,7 @@ 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);
return 'simple' . $check_string . ':' . Crypt::hmacBase64($check_string, $key);
}
/**

View file

@ -464,7 +464,7 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
* 'bundle' => $bundle,
* 'mode' => $view_mode,
* 'status' => TRUE,
* ));
* );
* \Drupal::entityTypeManager()
* ->getStorage('entity_view_display')
* ->create($values);
@ -475,7 +475,7 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
*/
function entity_get_display($entity_type, $bundle, $view_mode) {
// Try loading the display from configuration.
$display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $view_mode);
$display = EntityViewDisplay::load($entity_type . '.' . $bundle . '.' . $view_mode);
// If not found, create a fresh display object. We do not preemptively create
// new entity_view_display configuration entries for each existing entity type
@ -555,7 +555,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
*/
function entity_get_form_display($entity_type, $bundle, $form_mode) {
// Try loading the entity from configuration.
$entity_form_display = entity_load('entity_form_display', $entity_type . '.' . $bundle . '.' . $form_mode);
$entity_form_display = EntityFormDisplay::load($entity_type . '.' . $bundle . '.' . $form_mode);
// If not found, create a fresh entity object. We do not preemptively create
// new entity form display configuration entries for each existing entity type

View file

@ -80,6 +80,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
'%line' => $caller['line'],
'severity_level' => $severity_level,
'backtrace' => $backtrace,
'@backtrace_string' => (new \Exception())->getTraceAsString(),
), $recoverable || $to_string);
}
}
@ -116,9 +117,9 @@ function error_displayable($error = NULL) {
*
* @param $error
* 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 an HTML string, and
* backtrace, which is a standard PHP backtrace.
* %line, @backtrace_string, severity_level, and backtrace. All the parameters
* are plain-text, 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:
* - An exception is thrown and not caught by something else.
@ -163,18 +164,18 @@ 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) @backtrace_string.', $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(strtr('Failed to log error: %type: @message in %function (line %line of %file).', $error));
error_log(strtr('Failed to log error: %type: @message in %function (line %line of %file). @backtrace_string', $error));
}
}
// Log fatal errors, so developers can find and debug them.
if ($fatal) {
error_log(sprintf('%s: %s in %s on line %d', $error['%type'], $error['@message'], $error['%file'], $error['%line']));
error_log(sprintf('%s: %s in %s on line %d %s', $error['%type'], $error['@message'], $error['%file'], $error['%line'], $error['@backtrace_string']));
}
if (PHP_SAPI === 'cli') {

View file

@ -5,11 +5,13 @@
* API for handling file uploads and server file management.
*/
use Drupal\Component\FileSystem\FileSystem as ComponentFileSystem;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\PhpStorage\FileStorage;
use Drupal\Component\Utility\Bytes;
use Drupal\Core\File\FileSystem;
use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\Core\StreamWrapper\PrivateStream;
@ -978,7 +980,7 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
* @param $options
* An associative array of additional options, with the following elements:
* - 'nomask': The preg_match() regular expression for files to be excluded.
* There is no default.
* Defaults to the 'file_scan_ignore_directories' setting.
* - 'callback': The callback function to call for each match. There is no
* default callback.
* - 'recurse': When TRUE, the directory scan will recurse the entire tree
@ -1011,6 +1013,18 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
$dir_has_slash = (substr($dir, -1) === '/');
}
// Allow directories specified in settings.php to be ignored. You can use this
// to not check for files in common special-purpose directories. For example,
// node_modules and bower_components. Ignoring irrelevant directories is a
// performance boost.
if (!isset($options['nomask'])) {
$ignore_directories = Settings::get('file_scan_ignore_directories', []);
array_walk($ignore_directories, function(&$value) {
$value = preg_quote($value, '/');
});
$default_nomask = '/^' . implode('|', $ignore_directories) . '$/';
}
$options['key'] = in_array($options['key'], array('uri', 'filename', 'name')) ? $options['key'] : 'uri';
$files = array();
// Avoid warnings when opendir does not have the permissions to open a
@ -1019,7 +1033,10 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
if ($handle = @opendir($dir)) {
while (FALSE !== ($filename = readdir($handle))) {
// Skip this file if it matches the nomask or starts with a dot.
if ($filename[0] != '.' && !(isset($options['nomask']) && preg_match($options['nomask'], $filename))) {
if ($filename[0] != '.'
&& !(isset($options['nomask']) && preg_match($options['nomask'], $filename))
&& !(!empty($default_nomask) && preg_match($default_nomask, $filename))
) {
if ($depth == 0 && $dir_has_slash) {
$uri = "$dir$filename";
}
@ -1173,7 +1190,7 @@ function file_directory_temp() {
if (empty($temporary_directory)) {
// Needs set up.
$config = \Drupal::configFactory()->getEditable('system.file');
$temporary_directory = file_directory_os_temp();
$temporary_directory = ComponentFileSystem::getOsTemporaryDirectory();
if (empty($temporary_directory)) {
// If no directory has been found default to 'files/tmp'.
@ -1198,34 +1215,12 @@ function file_directory_temp() {
*
* @return mixed
* A string containing the path to the temporary directory.
*
* @deprecated in Drupal 8.3.x-dev, will be removed before Drupal 9.0.0.
* Use \Drupal\Component\FileSystem\FileSystem::getOsTemporaryDirectory().
*/
function file_directory_os_temp() {
$directories = array();
// Has PHP been set with an upload_tmp_dir?
if (ini_get('upload_tmp_dir')) {
$directories[] = ini_get('upload_tmp_dir');
}
// Operating system specific dirs.
if (substr(PHP_OS, 0, 3) == 'WIN') {
$directories[] = 'c:\\windows\\temp';
$directories[] = 'c:\\winnt\\temp';
}
else {
$directories[] = '/tmp';
}
// PHP may be able to find an alternative tmp directory.
$directories[] = sys_get_temp_dir();
foreach ($directories as $directory) {
if (is_dir($directory) && is_writable($directory)) {
// Both sys_get_temp_dir() and ini_get('upload_tmp_dir') can return paths
// with a trailing directory separator.
return rtrim($directory, DIRECTORY_SEPARATOR);
}
}
return FALSE;
return ComponentFileSystem::getOsTemporaryDirectory();
}
/**

View file

@ -254,6 +254,7 @@ 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'] : '';
$variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL;
// Suppress error messages.
$variables['errors'] = NULL;
@ -592,7 +593,8 @@ function template_preprocess_form_element_label(&$variables) {
* // 1 (or no value explicitly set) means the operation is finished
* // and the batch processing can continue to the next operation.
*
* $nodes = entity_load_multiple_by_properties('node', array('uid' => $uid, 'type' => $type));
* $nodes = \Drupal::entityTypeManager()->getStorage('node')
* ->loadByProperties(['uid' => $uid, 'type' => $type]);
* $node = reset($nodes);
* $context['results'][] = $node->id() . ' : ' . SafeMarkup::checkPlain($node->label());
* $context['message'] = SafeMarkup::checkPlain($node->label());

View file

@ -1580,7 +1580,7 @@ function install_download_additional_translations_operations(&$install_state) {
\Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
$langcode = $install_state['parameters']['langcode'];
if (!($language = entity_load('configurable_language', $langcode))) {
if (!($language = ConfigurableLanguage::load($langcode))) {
// Create the language if not already shipped with a profile.
$language = ConfigurableLanguage::createFromLangcode($langcode);
}

View file

@ -504,7 +504,7 @@ function drupal_install_config_directories() {
// Bail out using a similar error message as in system_requirements().
if (!file_prepare_directory($config_directories[CONFIG_SYNC_DIRECTORY], FILE_CREATE_DIRECTORY)
&& !file_exists($config_directories[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(
throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory 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',
)));

View file

@ -707,7 +707,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
// Initialize master language list.
if (!isset($languages)) {
// Initialize local language list cache.
$languages = array();
$languages = array();
// Fill in master language list based on current configuration.
$default = \Drupal::languageManager()->getDefaultLanguage();