Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713

This commit is contained in:
Pantheon Automation 2016-05-04 14:35:41 -07:00 committed by Greg Anderson
parent c0a0d5a94c
commit 9eae24d844
669 changed files with 3873 additions and 1553 deletions

View file

@ -11,7 +11,7 @@ Drupal 8.1.0, 2016-04-20
* Added Symfony Polyfill Iconv 1.1.0.
* Added paragonie/random_compat 1.4.1.
- Updated vendor libraries:
* Updated to Symfony 2.8.4.
* Updated to the last 2.x minor version of Symfony: 2.8 (2.8.4).
* Updated to CKEditor 4.5.8.
* Updated to Modernizr 3.3.1.
- Added modules:
@ -34,12 +34,13 @@ Drupal 8.1.0, 2016-04-20
reducing the code needed to extend them.
* Simplified Migrate API by replacing migration configuration entities with
migration plugins.
* Added support for entity types to specify translatable plural labels.
* Added a revision log interface and trait for revisionable entity types.
* Added key field definitions to ContentEntityBase, reducing code from
child classes.
* Added generic route providers for add-page and add-form entity routes,
reducing the code needed to define an entity type.
* Various improvements for defining entity types:
* Added support for entity types to specify translatable plural labels.
* Added a revision log interface and trait for revisionable entity types.
* Added key field definitions to ContentEntityBase, reducing code from
child classes.
* Added generic route providers for add-page and add-form entity routes,
reducing the code needed to define an entity type.
- Testing improvements:
* Added support for automated JavaScript testing.
* Added verbose output for BrowserTestBase.
@ -414,8 +415,8 @@ Drupal 7.0, 2011-01-05
are available.
- OpenID:
* Added support for Gmail and Google Apps for Domain identifiers. Users can
now login with their user@example.com identifier when example.com is powered
by Google.
now log in with their user@example.com identifier when example.com is
powered by Google.
* Made the OpenID module more pluggable.
- Added code registry:
* Using the registry, modules declare their includable files via their .info file,

View file

@ -314,6 +314,7 @@ Database Logging module
- Khalid Baheyeldin 'kbahey' https://www.drupal.org/u/kbahey
DateTime module
- Jonathan Hedstrom 'jhedstrom' https://www.drupal.org/u/jhedstrom
- Matthew Donadio 'mpdonadio' https://www.drupal.org/u/mpdonadio
Dynamic Page Cache module

View file

@ -140,10 +140,8 @@
"Drupal\\Component\\": "lib/Drupal/Component",
"Drupal\\Driver\\": "../drivers/lib/Drupal/Driver"
},
"files": [
"lib/Drupal.php"
],
"classmap": [
"lib/Drupal.php",
"lib/Drupal/Component/Utility/Timer.php",
"lib/Drupal/Component/Utility/Unicode.php",
"lib/Drupal/Core/Database/Database.php",

View file

@ -80,6 +80,11 @@ services:
arguments: ['@request_stack']
tags:
- { name: cache.context }
cache_context.url.path.parent:
class: Drupal\Core\Cache\Context\PathParentCacheContext
arguments: ['@request_stack']
tags:
- { name: cache.context }
cache_context.url.query_args:
class: Drupal\Core\Cache\Context\QueryArgsCacheContext
arguments: ['@request_stack']

View file

@ -623,7 +623,7 @@ function drupal_valid_test_ua($new_prefix = 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)) {
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

View file

@ -14,6 +14,7 @@ use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SortArray;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Render\Element\Link;
use Drupal\Core\Render\Markup;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\PhpStorage\PhpStorageFactory;
@ -748,7 +749,7 @@ function drupal_clear_js_cache() {
* Use \Drupal\Core\Render\Element\Link::preRenderLink().
*/
function drupal_pre_render_link($element) {
return Element\Link::preRenderLink($element);
return Link::preRenderLink($element);
}
/**

View file

@ -7,6 +7,7 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\RenderElement;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
@ -29,7 +30,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
function template_preprocess_select(&$variables) {
$element = $variables['element'];
Element::setAttributes($element, array('id', 'name', 'size'));
Element\RenderElement::setAttributes($element, array('form-select'));
RenderElement::setAttributes($element, array('form-select'));
$variables['attributes'] = $element['#attributes'];
$variables['options'] = form_select_options($element);
@ -191,7 +192,7 @@ function form_get_options($element, $key) {
function template_preprocess_fieldset(&$variables) {
$element = $variables['element'];
Element::setAttributes($element, array('id'));
Element\RenderElement::setAttributes($element);
RenderElement::setAttributes($element);
$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;
@ -376,7 +377,7 @@ function template_preprocess_form(&$variables) {
function template_preprocess_textarea(&$variables) {
$element = $variables['element'];
Element::setAttributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
Element\RenderElement::setAttributes($element, array('form-textarea'));
RenderElement::setAttributes($element, array('form-textarea'));
$variables['wrapper_attributes'] = new Attribute();
$variables['attributes'] = new Attribute($element['#attributes']);
$variables['value'] = $element['#value'];

View file

@ -7,7 +7,6 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Config\BootstrapConfigStorageFactory;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\Form\FormState;
@ -489,8 +488,7 @@ function install_begin_request($class_loader, &$install_state) {
// Ensure that the active configuration is empty before installation starts.
if ($install_state['config_verified'] && empty($task)) {
$config = BootstrapConfigStorageFactory::get()->listAll();
if (!empty($config)) {
if (count($kernel->getConfigStorage()->listAll())) {
$task = NULL;
throw new AlreadyInstalledException($container->get('string_translation'));
}
@ -1799,7 +1797,7 @@ function install_check_translations($langcode, $server_pattern) {
$writable = FALSE;
// @todo: Make this configurable.
$site_path = \Drupal::service('site.path');
$files_directory = $site_path . '/files';
$files_directory = $site_path . '/files';
$translations_directory = $site_path . '/files/translations';
$translations_directory_exists = FALSE;
$online = FALSE;

View file

@ -515,7 +515,7 @@ function drupal_install_config_directories() {
// 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';
$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);
}

View file

@ -580,20 +580,29 @@ function template_preprocess_datetime_wrapper(&$variables) {
*
* Default template: links.html.twig.
*
* Unfortunately links templates duplicate the "active" class handling of l()
* and LinkGenerator::generate() because it needs to be able to set the "active"
* class not on the links themselves ("a" tags), but on the list items ("li"
* tags) that contain the links. This is necessary for CSS to be able to style
* list items differently when the link is active, since CSS does not yet allow
* one to style list items only if it contains a certain element with a certain
* class. I.e. we cannot yet convert this jQuery selector to a CSS selector:
* jQuery('li:has("a.is-active")')
*
* @param array $variables
* An associative array containing:
* - 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.
* - url: (optional) The \Drupal\Core\Url object to link to. If omitted, no
* anchor tag is printed out.
* - attributes: (optional) Attributes for the anchor, or for the <span>
* tag used in its place if no 'href' is supplied. If element 'class' is
* included, it must be an array of one or more class names.
* If the 'href' element is supplied, the entire link array is passed to
* l() as its $options parameter.
* - attributes: A keyed array of attributes for the UL containing the
* list of links.
* - attributes: A keyed array of attributes for the <ul> containing the list
* of links.
* - set_active_class: (optional) Whether each link should compare the
* route_name + route_parameters or href (path), language and query options
* to the current URL, to determine whether the link is "active". If so, an
@ -622,15 +631,6 @@ function template_preprocess_datetime_wrapper(&$variables) {
* http://juicystudio.com/article/screen-readers-display-none.php and
* http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
*
* Unfortunately links templates duplicate the "active" class handling of l()
* and LinkGenerator::generate() because it needs to be able to set the "active"
* class not on the links themselves ("a" tags), but on the list items ("li"
* tags) that contain the links. This is necessary for CSS to be able to style
* list items differently when the link is active, since CSS does not yet allow
* one to style list items only if it contains a certain element with a certain
* class. I.e. we cannot yet convert this jQuery selector to a CSS selector:
* jQuery('li:has("a.is-active")')
*
* @see \Drupal\Core\Utility\LinkGenerator
* @see \Drupal\Core\Utility\LinkGenerator::generate()
* @see system_page_attachments()
@ -1052,6 +1052,7 @@ function template_preprocess_table(&$variables) {
* render properties for all nested child lists.
* - title: A title to be prepended to the list.
* - list_type: The type of list to return (e.g. "ul", "ol").
* - wrapper_attributes: HTML attributes to be applied to the list wrapper.
*
* @see https://www.drupal.org/node/1842756
*/
@ -1264,7 +1265,7 @@ function template_preprocess_html(&$variables) {
// Add a variable for the root path. This can be used to create a class and
// theme the page depending on the current path (e.g. node, admin, user) as
// well as more specific data like path-frontpage.
$is_front_page = \Drupal::service('path.matcher')->isFrontPage();
$is_front_page = \Drupal::service('path.matcher')->isFrontPage();
if ($is_front_page) {
$variables['root_path'] = FALSE;
@ -1527,7 +1528,7 @@ function template_preprocess_field(&$variables, $hook) {
static $default_attributes;
if (!isset($default_attributes)) {
$default_attributes = new Attribute;
$default_attributes = new Attribute();
}
// Merge attributes when a single-value field has a hidden label.

View file

@ -81,7 +81,7 @@ class Drupal {
/**
* The current system version.
*/
const VERSION = '8.1.0';
const VERSION = '8.1.1';
/**
* Core API compatibility.

View file

@ -15,9 +15,9 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
/**
* This property was based from Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @license http://framework.zend.com/license/new-bsd New BSD License
*
* A map of characters to be replaced through strtr.
*
@ -75,9 +75,9 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
/**
* This method was based from Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @license http://framework.zend.com/license/new-bsd New BSD License
*
* Canonicalize the extension name to a service name.
*

View file

@ -116,7 +116,7 @@ class DateTimePlus {
* date even if some values are missing.
*
* @param array $date_parts
* An array of date parts, like ('year' => 2014, 'month => 4).
* An array of date parts, like ('year' => 2014, 'month' => 4).
* @param mixed $timezone
* (optional) \DateTimeZone object, time zone string or NULL. NULL uses the
* default system time zone. Defaults to NULL.

View file

@ -169,4 +169,3 @@ class Diff {
return $this->edits;
}
}

View file

@ -73,7 +73,7 @@ class DiffFormatter {
$context = $edit->orig;
}
else {
if (! is_array($block)) {
if (!is_array($block)) {
$context = array_slice($context, sizeof($context) - $nlead);
$x0 = $xi - sizeof($context);
$y0 = $yi - sizeof($context);

View file

@ -181,7 +181,7 @@ class DiffEngine {
}
}
$this->lcs = 0;
$this->seq[0]= $yoff - 1;
$this->seq[0] = $yoff - 1;
$this->in_seq = array();
$ymids[0] = array();
@ -190,11 +190,11 @@ class DiffEngine {
for ($chunk = 0; $chunk < $nchunks; $chunk++) {
if ($chunk > 0) {
for ($i = 0; $i <= $this->lcs; $i++) {
$ymids[$i][$chunk-1] = $this->seq[$i];
$ymids[$i][$chunk - 1] = $this->seq[$i];
}
}
$x1 = $xoff + (int)(($numer + ($xlim-$xoff)*$chunk) / $nchunks);
$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
for ( ; $x < $x1; $x++) {
$line = $flip ? $this->yv[$x] : $this->xv[$x];
if (empty($ymatches[$line])) {
@ -206,12 +206,12 @@ class DiffEngine {
if (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
$this::USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k-1];
$ymids[$k] = $ymids[$k - 1];
break;
}
}
while (list ($junk, $y) = each($matches)) {
if ($y > $this->seq[$k-1]) {
if ($y > $this->seq[$k - 1]) {
$this::USE_ASSERTS && assert($y < $this->seq[$k]);
// Optimization: this is a common case:
// next match is just replacing previous match.
@ -222,7 +222,7 @@ class DiffEngine {
elseif (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
$this::USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k-1];
$ymids[$k] = $ymids[$k - 1];
}
}
}
@ -363,7 +363,7 @@ class DiffEngine {
while ($j < $other_len && $other_changed[$j]) {
$j++;
}
while ($i < $len && ! $changed[$i]) {
while ($i < $len && !$changed[$i]) {
$this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
$i++;
$j++;

View file

@ -56,4 +56,3 @@ class MappedDiff extends Diff {
}
}
}

View file

@ -86,4 +86,3 @@ class YamlDiscovery implements DiscoverableInterface {
}
}

View file

@ -219,7 +219,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
if (!$item) {
return;
}
$header = new PoHeader;
$header = new PoHeader();
$header->setFromString(trim($item->getTranslation()));
$this->_header = $header;
}

View file

@ -50,7 +50,7 @@ class FileStorage implements PhpStorageInterface {
$path = $this->getFullPath($name);
$directory = dirname($path);
if ($this->ensureDirectory($directory)) {
$htaccess_path = $directory . '/.htaccess';
$htaccess_path = $directory . '/.htaccess';
if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines())) {
@chmod($htaccess_path, 0444);
}
@ -126,7 +126,7 @@ EOF;
*/
protected function ensureDirectory($directory, $mode = 0777) {
if ($this->createDirectory($directory, $mode)) {
$htaccess_path = $directory . '/.htaccess';
$htaccess_path = $directory . '/.htaccess';
if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines())) {
@chmod($htaccess_path, 0444);
}

View file

@ -163,9 +163,9 @@ class FormattableMarkup implements MarkupInterface, \Countable {
* wrapped in quotes:
* @code
* // Secure (with quotes):
* $this->placeholderFormat('<a href=":url">@variable</a>', [':url' => $url, @variable => $variable]);
* $this->placeholderFormat('<a href=":url">@variable</a>', [':url' => $url, '@variable' => $variable]);
* // Insecure (without quotes):
* $this->placeholderFormat('<a href=:url>@variable</a>', [':url' => $url, @variable => $variable]);
* $this->placeholderFormat('<a href=:url>@variable</a>', [':url' => $url, '@variable' => $variable]);
* @endcode
* When ":variable" comes from arbitrary user input, the result is secure,
* but not guaranteed to be a valid URL (which means the resulting output

View file

@ -139,7 +139,7 @@ class Random {
* @return string
*/
public function word($length) {
mt_srand((double) microtime()*1000000);
mt_srand((double) microtime() * 1000000);
$vowels = array("a", "e", "i", "o", "u");
$cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",

View file

@ -19,7 +19,6 @@ class UrlHelper {
/**
* Parses an array into a valid, rawurlencoded query string.
*
*
* rawurlencode() is RFC3986 compliant, and as a consequence RFC3987
* compliant. The latter defines the required format of "URLs" in HTML5.
* urlencode() is almost the same as rawurlencode(), except that it encodes

View file

@ -83,7 +83,7 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable
* will be TRUE.
*/
public static function forbiddenIf($condition) {
return $condition ? static::forbidden(): static::neutral();
return $condition ? static::forbidden() : static::neutral();
}
/**

View file

@ -71,4 +71,3 @@ class DataCommand implements CommandInterface {
}
}

View file

@ -34,4 +34,3 @@ class AppRootFactory {
}
}

View file

@ -6,4 +6,3 @@ namespace Drupal\Core\Archiver;
* Defines an exception class for Drupal\Core\Archiver\ArchiverInterface.
*/
class ArchiverException extends \Exception {}

View file

@ -70,7 +70,7 @@ class Zip implements ArchiverInterface {
*/
public function listContents() {
$files = array();
for ($i=0; $i < $this->zip->numFiles; $i++) {
for ($i = 0; $i < $this->zip->numFiles; $i++) {
$files[] = $this->zip->getNameIndex($i);
}
return $files;

View file

@ -214,7 +214,7 @@ class AssetResolver implements AssetResolverInterface {
// hook_library_info_alter(). Additionally add the current language to
// support translation of JavaScript files via hook_js_alter().
$libraries_to_load = $this->getLibrariesToLoad($assets);
$cid = 'js:' . $theme_info->getName() . ':' . $this->languageManager->getCurrentLanguage()->getId() . ':' . Crypt::hashBase64(serialize($libraries_to_load)) . (int) (count($assets->getSettings()) > 0) . (int) $optimize;
$cid = 'js:' . $theme_info->getName() . ':' . $this->languageManager->getCurrentLanguage()->getId() . ':' . Crypt::hashBase64(serialize($libraries_to_load) . serialize($assets->getLibraries())) . (int) (count($assets->getSettings()) > 0) . (int) $optimize;
if ($cached = $this->cache->get($cid)) {
list($js_assets_header, $js_assets_footer, $settings, $settings_in_header) = $cached->data;

View file

@ -12,8 +12,8 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface {
*
* Puts multiple items into the same group if they are groupable and if they
* are for the same 'media' and 'browsers'. Items of the 'file' type are
* groupable if their 'preprocess' flag is TRUE, items of the 'inline' type
* are always groupable, and items of the 'external' type are never groupable.
* groupable if their 'preprocess' flag is TRUE, and items of the 'external'
* type are never groupable.
*
* Also ensures that the process of grouping items does not change their
* relative order. This requirement may result in multiple groups for the same
@ -55,11 +55,6 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface {
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['media'], $item['browsers']) : FALSE;
break;
case 'inline':
// Always group inline items.
$group_keys = array($item['type'], $item['media'], $item['browsers']);
break;
case 'external':
// Do not group external items.
$group_keys = FALSE;

View file

@ -133,16 +133,6 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface {
}
break;
case 'inline':
// We don't do any caching for inline CSS assets.
$data = '';
foreach ($css_group['items'] as $css_asset) {
$data .= $this->optimizer->optimize($css_asset);
}
unset($css_assets[$order]['data']['items']);
$css_assets[$order]['data'] = $data;
break;
case 'external':
// We don't do any aggregation and hence also no caching for external
// CSS assets.

View file

@ -20,19 +20,14 @@ class CssOptimizer implements AssetOptimizerInterface {
* {@inheritdoc}
*/
public function optimize(array $css_asset) {
if (!in_array($css_asset['type'], array('file', 'inline'))) {
throw new \Exception('Only file or inline CSS assets can be optimized.');
if ($css_asset['type'] != 'file') {
throw new \Exception('Only file CSS assets can be optimized.');
}
if ($css_asset['type'] === 'file' && !$css_asset['preprocess']) {
if (!$css_asset['preprocess']) {
throw new \Exception('Only file CSS assets with preprocessing enabled can be optimized.');
}
if ($css_asset['type'] === 'file') {
return $this->processFile($css_asset);
}
else {
return $this->processCss($css_asset['data'], $css_asset['preprocess']);
}
return $this->processFile($css_asset);
}
/**
@ -241,14 +236,14 @@ class CssOptimizer implements AssetOptimizerInterface {
/**
* Prefixes all paths within a CSS file for processFile().
*
* @param array $matches
* An array of matches by a preg_replace_callback() call that scans for
* url() references in CSS files, except for external or absolute ones.
*
* Note: the only reason this method is public is so color.module can call it;
* it is not on the AssetOptimizerInterface, so future refactorings can make
* it protected.
*
* @param array $matches
* An array of matches by a preg_replace_callback() call that scans for
* url() references in CSS files, except for external or absolute ones.
*
* @return string
* The file path.
*/

View file

@ -12,8 +12,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface {
*
* Puts multiple items into the same group if they are groupable and if they
* are for the same browsers. Items of the 'file' type are groupable if their
* 'preprocess' flag is TRUE. Items of the 'inline', 'settings', or 'external'
* type are not groupable.
* 'preprocess' flag is TRUE. Items of the 'external' type are not groupable.
*
* Also ensures that the process of grouping items does not change their
* relative order. This requirement may result in multiple groups for the same
@ -43,9 +42,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface {
break;
case 'external':
case 'setting':
case 'inline':
// Do not group external, settings, and inline items.
// Do not group external items.
$group_keys = FALSE;
break;
}

View file

@ -138,10 +138,8 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface {
break;
case 'external':
case 'setting':
case 'inline':
// We don't do any aggregation and hence also no caching for external,
// setting or inline JS assets.
// We don't do any aggregation and hence also no caching for external
// JS assets.
$uri = $js_group['items'][0]['data'];
$js_assets[$order]['data'] = $uri;
break;

View file

@ -68,7 +68,7 @@ class JsCollectionRenderer implements AssetCollectionRendererInterface {
'type' => 'application/json',
'data-drupal-selector' => 'drupal-settings-json',
);
$element['#value'] = Json::encode($js_asset['data']);
$element['#value'] = Json::encode($js_asset['data']);
break;
case 'file':

View file

@ -16,7 +16,7 @@ class JsOptimizer implements AssetOptimizerInterface {
if ($js_asset['type'] !== 'file') {
throw new \Exception('Only file JavaScript assets can be optimized.');
}
if ($js_asset['type'] === 'file' && !$js_asset['preprocess']) {
if (!$js_asset['preprocess']) {
throw new \Exception('Only file JavaScript assets with preprocessing enabled can be optimized.');
}

View file

@ -0,0 +1,41 @@
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
/**
* Defines a cache context service for path parents.
*
* Cache context ID: 'url.path.parent'.
*
* This allows for caching based on the path, excluding everything after the
* last forward slash.
*/
class PathParentCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('Parent path');
}
/**
* {@inheritdoc}
*/
public function getContext() {
$request = $this->requestStack->getCurrentRequest();
$path_elements = explode('/', trim($request->getPathInfo(), '/'));
array_pop($path_elements);
return implode('/', $path_elements);
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}

View file

@ -49,4 +49,3 @@ class ConfigCrudEvent extends Event {
}
}

View file

@ -272,7 +272,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
// $this->configFactoryOverrides, add cache keys for each.
$keys[] = 'global_overrides';
foreach($this->configFactoryOverrides as $override) {
$keys[] = $override->getCacheSuffix();
$keys[] = $override->getCacheSuffix();
}
return $keys;
}

View file

@ -484,14 +484,17 @@ class ConfigImporter {
*/
public function doSyncStep($sync_step, &$context) {
if (!is_array($sync_step) && method_exists($this, $sync_step)) {
\Drupal::service('config.installer')->setSyncing(TRUE);
$this->$sync_step($context);
}
elseif (is_callable($sync_step)) {
\Drupal::service('config.installer')->setSyncing(TRUE);
call_user_func_array($sync_step, array(&$context, $this));
}
else {
throw new \InvalidArgumentException('Invalid configuration synchronization step');
}
\Drupal::service('config.installer')->setSyncing(FALSE);
}
/**
@ -778,7 +781,6 @@ class ConfigImporter {
// Set the config installer to use the sync directory instead of the
// extensions own default config directories.
\Drupal::service('config.installer')
->setSyncing(TRUE)
->setSourceStorage($this->storageComparer->getSourceStorage());
if ($type == 'module') {
$this->moduleInstaller->$op(array($name), FALSE);
@ -805,8 +807,6 @@ class ConfigImporter {
}
$this->setProcessedExtension($type, $op, $name);
\Drupal::service('config.installer')
->setSyncing(FALSE);
}
/**

View file

@ -100,4 +100,3 @@ class ConfigModuleOverridesEvent extends Event {
return $this;
}
}

View file

@ -17,10 +17,10 @@ use Drupal\Component\Utility\SortArray;
* The configuration dependency value is structured like this:
* @code
* array(
* 'config => array(
* 'config' => array(
* // An array of configuration entity object names. Recalculated on save.
* ),
* 'content => array(
* 'content' => array(
* // An array of content entity configuration dependency names. The default
* // format is "ENTITY_TYPE_ID:BUNDLE:UUID". Recalculated on save.
* ),
@ -165,7 +165,7 @@ class ConfigDependencyManager {
// If checking content, module, or theme dependencies, discover which
// entities are dependent on the entities that have a direct dependency.
foreach ($dependent_entities as $entity) {
$entities_to_check[] = $entity->getConfigDependencyName();
$entities_to_check[] = $entity->getConfigDependencyName();
}
}
$dependencies = array_merge($this->createGraphConfigEntityDependencies($entities_to_check), $dependent_entities);
@ -291,10 +291,10 @@ class ConfigDependencyManager {
* The configuration dependencies. The array is structured like this:
* @code
* array(
* 'config => array(
* 'config' => array(
* // An array of configuration entity object names.
* ),
* 'content => array(
* 'content' => array(
* // An array of content entity configuration dependency names. The default
* // format is "ENTITY_TYPE_ID:BUNDLE:UUID".
* ),

View file

@ -382,8 +382,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
* {@inheritdoc}
*/
public function importCreate($name, Config $new_config, Config $old_config) {
$entity = $this->createFromStorageRecord($new_config->get());
$entity->setSyncing(TRUE);
$entity = $this->_doCreateFromStorageRecord($new_config->get(), TRUE);
$entity->save();
return TRUE;
}
@ -425,6 +424,27 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
* {@inheritdoc}
*/
public function createFromStorageRecord(array $values) {
return $this->_doCreateFromStorageRecord($values);
}
/**
* Helps create a configuration entity from storage values.
*
* Allows the configuration entity storage to massage storage values before
* creating an entity.
*
* @param array $values
* The array of values from the configuration storage.
* @param bool $is_syncing
* Is the configuration entity being created as part of a config sync.
*
* @return ConfigEntityInterface
* The configuration entity.
*
* @see \Drupal\Core\Config\Entity\ConfigEntityStorageInterface::createFromStorageRecord()
* @see \Drupal\Core\Config\Entity\ImportableEntityStorageInterface::importCreate()
*/
protected function _doCreateFromStorageRecord(array $values, $is_syncing = FALSE) {
// Assign a new UUID if there is none yet.
if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) {
$values[$this->uuidKey] = $this->uuidService->generate();
@ -432,6 +452,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
$data = $this->mapFromStorageRecords(array($values));
$entity = current($data);
$entity->original = clone $entity;
$entity->setSyncing($is_syncing);
$entity->enforceIsNew();
$entity->postCreate($this);
@ -439,6 +460,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
// entity object, for instance to fill-in default values.
$this->invokeHook('create', $entity);
return $entity;
}
/**

View file

@ -132,4 +132,3 @@ class ExtensionInstallStorage extends InstallStorage {
return $this->folders;
}
}

View file

@ -60,13 +60,13 @@ abstract class StorableConfigBase extends ConfigBase {
/**
* Saves the configuration object.
*
* Must invalidate the cache tags associated with the configuration object.
*
* @param bool $has_trusted_data
* Set to TRUE if the configuration data has already been checked to ensure
* it conforms to schema. Generally this is only used during module and
* theme installation.
*
* Must invalidate the cache tags associated with the configuration object.
*
* @return $this
*
* @see \Drupal\Core\Config\ConfigInstaller::createConfiguration()
@ -191,7 +191,7 @@ abstract class StorableConfigBase extends ConfigBase {
// we have to special case the meaning of an empty string for numeric
// types. In PHP this would be casted to a 0 but for the purposes of
// configuration we need to treat this as a NULL.
$empty_value = $value === '' && ($element instanceof IntegerInterface || $element instanceof FloatInterface);
$empty_value = $value === '' && ($element instanceof IntegerInterface || $element instanceof FloatInterface);
if ($value === NULL || $empty_value) {
$value = NULL;

View file

@ -68,7 +68,7 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes
return $controller;
}
elseif (method_exists($controller, '__invoke')) {
return new $controller;
return new $controller();
}
}

View file

@ -11,4 +11,3 @@ namespace Drupal\Core\Database;
* developers should account for it separately.
*/
interface DatabaseException { }

View file

@ -12,4 +12,4 @@ class Select extends QuerySelect {
// SQLite does not support FOR UPDATE so nothing to do.
return $this;
}
}
}

View file

@ -22,8 +22,8 @@ class Log {
*
* array(
* $logging_key = array(
* array(query => '', args => array(), caller => '', target => '', time => 0),
* array(query => '', args => array(), caller => '', target => '', time => 0),
* array('query' => '', 'args' => array(), 'caller' => '', 'target' => '', 'time' => 0),
* array('query' => '', 'args' => array(), 'caller' => '', 'target' => '', 'time' => 0),
* ),
* );
*

View file

@ -819,7 +819,7 @@ class Select extends Query implements SelectInterface {
// Don't use the AS keyword for table aliases, as some
// databases don't support it (e.g., Oracle).
$query .= $table_string . ' ' . $this->connection->escapeTable($table['alias']);
$query .= $table_string . ' ' . $this->connection->escapeTable($table['alias']);
if (!empty($table['condition'])) {
$query .= ' ON ' . $table['condition'];

View file

@ -234,12 +234,12 @@ class DateFormatter implements DateFormatterInterface {
switch ($value) {
case 'y':
$interval_output = $this->formatPlural($interval->y, '1 year', '@count years', array(), array('langcode' => $options['langcode']));
$max_age = min($max_age, 365*86400);
$max_age = min($max_age, 365 * 86400);
break;
case 'm':
$interval_output = $this->formatPlural($interval->m, '1 month', '@count months', array(), array('langcode' => $options['langcode']));
$max_age = min($max_age, 30*86400);
$max_age = min($max_age, 30 * 86400);
break;
case 'd':
@ -252,7 +252,7 @@ class DateFormatter implements DateFormatterInterface {
$interval_output .= $this->formatPlural($weeks, '1 week', '@count weeks', array(), array('langcode' => $options['langcode']));
$days -= $weeks * 7;
$granularity--;
$max_age = min($max_age, 7*86400);
$max_age = min($max_age, 7 * 86400);
}
if ((!$output || $weeks > 0) && $granularity > 0 && $days > 0) {

View file

@ -531,4 +531,3 @@ class DateHelper {
}
}

View file

@ -70,4 +70,3 @@ abstract class DateElementBase extends FormElement {
}
}

View file

@ -61,7 +61,12 @@ class Datelist extends DateElementBase {
unset($input['ampm']);
}
$timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL;
$date = DrupalDateTime::createFromArray($input, $timezone);
try {
$date = DrupalDateTime::createFromArray($input, $timezone);
}
catch (\Exception $e) {
$form_state->setError($element, t('Selected combination of day and month is not valid.'));
}
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
static::incrementRound($date, $increment);
}
@ -88,7 +93,7 @@ class Datelist extends DateElementBase {
break;
case 'hour':
$format = in_array('ampm', $element['#date_part_order']) ? 'g': 'G';
$format = in_array('ampm', $element['#date_part_order']) ? 'g' : 'G';
break;
case 'minute':
@ -218,7 +223,7 @@ class Datelist extends DateElementBase {
break;
case 'hour':
$format = in_array('ampm', $element['#date_part_order']) ? 'g': 'G';
$format = in_array('ampm', $element['#date_part_order']) ? 'g' : 'G';
$options = $date_helper->hours($format, $element['#required']);
$title = t('Hour');
break;
@ -318,8 +323,8 @@ class Datelist extends DateElementBase {
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
$form_state->setValueForElement($element, $date);
}
// If the input is invalid, set an error.
else {
// If the input is invalid and an error doesn't exist, set one.
elseif ($form_state->getError($element) === NULL) {
$form_state->setError($element, t('The %field date is invalid.', array('%field' => !empty($element['#title']) ? $element['#title'] : '')));
}
}

View file

@ -50,7 +50,7 @@ class ProxyServicesPass implements CompilerPassInterface {
$root_namespace_dir = $namespaces[$root_namespace];
}
$message =<<<EOF
$message = <<<EOF
Missing proxy class '$proxy_class' for lazy service '$service_id'.
Use the following command to generate the proxy class:

View file

@ -1,4 +1,5 @@
<?php
// @codingStandardsIgnoreFile
namespace Drupal\Core\DependencyInjection;

View file

@ -1,4 +1,5 @@
<?php
// @codingStandardsIgnoreFile
namespace Drupal\Core\DependencyInjection;

View file

@ -2,6 +2,7 @@
namespace Drupal\Core;
use Drupal\Component\Assertion\Handle;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper;
@ -18,6 +19,7 @@ use Drupal\Core\Http\TrustedHostsRequestFactory;
use Drupal\Core\Language\Language;
use Drupal\Core\Site\Settings;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\HttpFoundation\RedirectResponse;
@ -750,11 +752,20 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
/**
* Returns the container cache key based on the environment.
*
* The 'environment' consists of:
* - The kernel environment string.
* - The Drupal version constant.
* - The deployment identifier from settings.php. This allows custom
* deployments to force a container rebuild.
* - The operating system running PHP. This allows compiler passes to optimize
* services for different operating systems.
* - The paths to any additional container YAMLs from settings.php.
*
* @return string
* The cache key used for the service container.
*/
protected function getContainerCacheKey() {
$parts = array('service_container', $this->environment, \Drupal::VERSION, Settings::get('deployment_identifier'), serialize(Settings::get('container_yamls')));
$parts = array('service_container', $this->environment, \Drupal::VERSION, Settings::get('deployment_identifier'), PHP_OS, serialize(Settings::get('container_yamls')));
return implode(':', $parts);
}
@ -914,11 +925,15 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
assert_options(ASSERT_ACTIVE, TRUE);
// Now synchronize PHP 5 and 7's handling of assertions as much as
// possible.
\Drupal\Component\Assertion\Handle::register();
Handle::register();
// Log fatal errors to the test site directory.
ini_set('log_errors', 1);
ini_set('error_log', DRUPAL_ROOT . '/sites/simpletest/' . substr($test_prefix, 10) . '/error.log');
// Ensure that a rewritten settings.php is used if opcache is on.
ini_set('opcache.validate_timestamps', 'on');
ini_set('opcache.revalidate_freq', 0);
}
else {
// Ensure that no other code defines this.
@ -965,7 +980,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
&& Settings::get('class_loader_auto_detect', TRUE)
&& extension_loaded('apc')) {
$prefix = Settings::getApcuPrefix('class_loader', $this->root);
$apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader($prefix, $this->classLoader);
$apc_loader = new ApcClassLoader($prefix, $this->classLoader);
$this->classLoader->unregister();
$apc_loader->register();
$this->classLoader = $apc_loader;
@ -1204,7 +1219,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
foreach ($this->serviceProviderClasses as $origin => $classes) {
foreach ($classes as $name => $class) {
if (!is_object($class)) {
$this->serviceProviders[$origin][$name] = new $class;
$this->serviceProviders[$origin][$name] = new $class();
}
else {
$this->serviceProviders[$origin][$name] = $class;

View file

@ -23,4 +23,3 @@ class EntityListController extends ControllerBase {
}
}

View file

@ -55,7 +55,7 @@ interface EntityFormDisplayInterface extends EntityDisplayInterface {
* // For 'single-value' widgets:
* '#theme' => 'field_multiple_value_form',
* '#cardinality' => The field cardinality,
* '#cardinality_multiple => TRUE if the field can contain multiple
* '#cardinality_multiple' => TRUE if the field can contain multiple
* items, FALSE otherwise.
* // One sub-array per copy of the widget, keyed by delta.
* 0 => array(

View file

@ -121,7 +121,7 @@ class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
*/
public function createHandlerInstance($class, EntityTypeInterface $definition = null) {
public function createHandlerInstance($class, EntityTypeInterface $definition = NULL) {
return $this->container->get('entity_type.manager')->createHandlerInstance($class, $definition);
}

View file

@ -305,7 +305,7 @@ abstract class QueryBase implements QueryInterface {
*/
public function tableSort(&$headers) {
// If 'field' is not initialized, the header columns aren't clickable.
foreach ($headers as $key =>$header) {
foreach ($headers as $key => $header) {
if (is_array($header) && isset($header['specifier'])) {
$headers[$key]['field'] = '';
}

View file

@ -80,10 +80,21 @@ class Tables implements TablesInterface {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
$field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
for ($key = 0; $key <= $count; $key ++) {
// If there is revision support and only the current revision is being
// queried then use the revision id. Otherwise, the entity id will do.
if (($revision_key = $entity_type->getKey('revision')) && $all_revisions) {
for ($key = 0; $key <= $count; $key++) {
// This can either be the name of an entity base field or a configurable
// field.
$specifier = $specifiers[$key];
if (isset($field_storage_definitions[$specifier])) {
$field_storage = $field_storage_definitions[$specifier];
}
else {
$field_storage = FALSE;
}
// If there is revision support, only the current revisions are being
// queried, and the field is revisionable then use the revision id.
// Otherwise, the entity id will do.
if (($revision_key = $entity_type->getKey('revision')) && $all_revisions && $field_storage && $field_storage->isRevisionable()) {
// This contains the relevant SQL field to be used when joining entity
// tables.
$entity_id_field = $revision_key;
@ -95,15 +106,6 @@ class Tables implements TablesInterface {
$entity_id_field = $entity_type->getKey('id');
$field_id_field = 'entity_id';
}
// This can either be the name of an entity base field or a configurable
// field.
$specifier = $specifiers[$key];
if (isset($field_storage_definitions[$specifier])) {
$field_storage = $field_storage_definitions[$specifier];
}
else {
$field_storage = FALSE;
}
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = $this->entityManager->getStorage($entity_type_id)->getTableMapping();
@ -152,11 +154,18 @@ class Tables implements TablesInterface {
// finds the property first. The data table is preferred, which is why
// it gets added before the base table.
$entity_tables = array();
if ($data_table = $all_revisions ? $entity_type->getRevisionDataTable() : $entity_type->getDataTable()) {
if ($all_revisions && $field_storage && $field_storage->isRevisionable()) {
$data_table = $entity_type->getRevisionDataTable();
$entity_base_table = $entity_type->getRevisionTable();
}
else {
$data_table = $entity_type->getDataTable();
$entity_base_table = $entity_type->getBaseTable();
}
if ($data_table) {
$this->sqlQuery->addMetaData('simple_query', FALSE);
$entity_tables[$data_table] = $this->getTableMapping($data_table, $entity_type_id);
}
$entity_base_table = $all_revisions ? $entity_type->getRevisionTable() : $entity_type->getBaseTable();
$entity_tables[$entity_base_table] = $this->getTableMapping($entity_base_table, $entity_type_id);
$sql_column = $specifier;
@ -203,7 +212,7 @@ class Tables implements TablesInterface {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
$field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
// Add the new entity base table using the table and sql column.
$join_condition= '%alias.' . $entity_type->getKey('id') . " = $table.$sql_column";
$join_condition = '%alias.' . $entity_type->getKey('id') . " = $table.$sql_column";
$base_table = $this->sqlQuery->leftJoin($entity_type->getBaseTable(), NULL, $join_condition);
$propertyDefinitions = array();
$key++;

View file

@ -201,7 +201,7 @@ class DefaultTableMapping implements TableMappingInterface {
$field_name = $storage_definition->getName();
if ($this->allowsSharedTableStorage($storage_definition)) {
$column_name = count($storage_definition->getColumns()) == 1 ? $field_name : $field_name . '__' . $property_name;
$column_name = count($storage_definition->getColumns()) == 1 ? $field_name : $field_name . '__' . $property_name;
}
elseif ($this->requiresDedicatedTableStorage($storage_definition)) {
$column_name = !in_array($property_name, $this->getReservedColumns()) ? $field_name . '_' . $property_name : $property_name;

View file

@ -1174,7 +1174,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$vid = $id;
}
$original = !empty($entity->original) ? $entity->original: NULL;
$original = !empty($entity->original) ? $entity->original : NULL;
// Determine which fields should be actually stored.
$definitions = $this->entityManager->getFieldDefinitions($entity_type, $bundle);

View file

@ -1263,7 +1263,9 @@ function hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query
* Act on entities being assembled before rendering.
*
* @param &$build
* A renderable array representing the entity content.
* A renderable array representing the entity content. The module may add
* elements to $build prior to rendering. The structure of $build is a
* renderable array as expected by drupal_render().
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
* @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
@ -1272,10 +1274,6 @@ function hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query
* @param $view_mode
* The view mode the entity is rendered in.
*
* The module may add elements to $build prior to rendering. The
* structure of $build is a renderable array as expected by
* drupal_render().
*
* @see hook_entity_view_alter()
* @see hook_ENTITY_TYPE_view()
*
@ -1297,7 +1295,9 @@ function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $en
* Act on entities of a particular type being assembled before rendering.
*
* @param &$build
* A renderable array representing the entity content.
* A renderable array representing the entity content. The module may add
* elements to $build prior to rendering. The structure of $build is a
* renderable array as expected by drupal_render().
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
* @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
@ -1306,10 +1306,6 @@ function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $en
* @param $view_mode
* The view mode the entity is rendered in.
*
* The module may add elements to $build prior to rendering. The
* structure of $build is a renderable array as expected by
* drupal_render().
*
* @see hook_ENTITY_TYPE_view_alter()
* @see hook_entity_view()
*

View file

@ -68,4 +68,3 @@ class EntityRouteProviderSubscriber implements EventSubscriberInterface {
}
}

View file

@ -84,4 +84,3 @@ abstract class ExecutablePluginBase extends ContextAwarePluginBase implements Ex
return $this;
}
}

View file

@ -60,4 +60,3 @@ interface InfoParserInterface {
public function parse($filename);
}

View file

@ -82,4 +82,3 @@ interface ModuleInstallerInterface {
public function validateUninstall(array $module_list);
}

View file

@ -894,6 +894,9 @@ function hook_updater_info_alter(&$updaters) {
* Module dependencies do not belong to these installation requirements,
* but should be defined in the module's .info.yml file.
*
* During installation (when $phase == 'install'), if you need to load a class
* from your module, you'll need to include the class file directly.
*
* The 'runtime' phase is not limited to pure installation requirements
* but can also be used for more general status information like maintenance
* tasks and security issues.

View file

@ -25,6 +25,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implements ContainerFactoryPluginInterface {
/**
* The number of times this formatter allows rendering the same entity.
*
* @var int
*/
const RECURSIVE_RENDER_LIMIT = 20;
/**
* The logger factory.
*
@ -47,7 +54,19 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
protected $entityDisplayRepository;
/**
* Constructs a StringFormatter instance.
* An array of counters for the recursive rendering protection.
*
* Each counter takes into account all the relevant information about the
* field and the referenced entity that is being rendered.
*
* @see \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter::viewElements()
*
* @var array
*/
protected static $recursiveRenderDepth = [];
/**
* Constructs a EntityReferenceEntityFormatter instance.
*
* @param string $plugin_id
* The plugin_id for the formatter.
@ -141,15 +160,35 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
$elements = array();
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
// Protect ourselves from recursive rendering.
static $depth = 0;
$depth++;
if ($depth > 20) {
$this->loggerFactory->get('entity')->error('Recursive rendering detected when rendering entity @entity_type @entity_id. Aborting rendering.', array('@entity_type' => $entity->getEntityTypeId(), '@entity_id' => $entity->id()));
return $elements;
}
if ($entity->id()) {
// Due to render caching and delayed calls, the viewElements() method
// will be called later in the rendering process through a '#pre_render'
// callback, so we need to generate a counter that takes into account
// all the relevant information about this field and the referenced
// entity that is being rendered.
$recursive_render_id = $items->getFieldDefinition()->getTargetEntityTypeId()
. $items->getFieldDefinition()->getTargetBundle()
. $items->getName()
. $entity->id();
if (isset(static::$recursiveRenderDepth[$recursive_render_id])) {
static::$recursiveRenderDepth[$recursive_render_id]++;
}
else {
static::$recursiveRenderDepth[$recursive_render_id] = 1;
}
// Protect ourselves from recursive rendering.
if (static::$recursiveRenderDepth[$recursive_render_id] > static::RECURSIVE_RENDER_LIMIT) {
$this->loggerFactory->get('entity')->error('Recursive rendering detected when rendering entity %entity_type: %entity_id, using the %field_name field on the %bundle_name bundle. Aborting rendering.', [
'%entity_type' => $entity->getEntityTypeId(),
'%entity_id' => $entity->id(),
'%field_name' => $items->getName(),
'%bundle_name' => $items->getFieldDefinition()->getTargetBundle(),
]);
return $elements;
}
$view_builder = $this->entityTypeManager->getViewBuilder($entity->getEntityTypeId());
$elements[$delta] = $view_builder->view($entity, $view_mode, $entity->language()->getId());
@ -164,7 +203,6 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
// This is an "auto_create" item.
$elements[$delta] = array('#markup' => $entity->label());
}
$depth = 0;
}
return $elements;

View file

@ -120,4 +120,3 @@ class BooleanItem extends FieldItemBase implements OptionsProviderInterface {
return $values;
}
}

View file

@ -1032,7 +1032,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// Assign a decimal placeholder weight to preserve original array order.
if (!isset($element[$key]['#weight'])) {
$element[$key]['#weight'] = $count/1000;
$element[$key]['#weight'] = $count / 1000;
}
else {
// If one of the child elements has a weight then we will need to sort

View file

@ -56,8 +56,8 @@ class TrustedHostsRequestFactory {
*
* @return \Symfony\Component\HttpFoundation\Request
* A new request object.
**/
public function createRequest(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) {
*/
public function createRequest(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = NULL) {
if (empty($server['HTTP_HOST']) || ($server['HTTP_HOST'] === 'localhost' && $this->host !== 'localhost')) {
$server['HTTP_HOST'] = $this->host;
}

View file

@ -78,7 +78,7 @@ class SelectLanguageForm extends FormBase {
),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => 'Save and continue',
'#button_type' => 'primary',

View file

@ -72,7 +72,7 @@ class SelectProfileForm extends FormBase {
$form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : '';
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#button_type' => 'primary',

View file

@ -131,7 +131,7 @@ class SiteConfigureForm extends ConfigFormBase {
// distract from the message that the Drupal installation has completed
// successfully.)
$post_params = $this->getRequest()->request->all();
if (empty($post_params) && (!drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
if (empty($post_params) && (!drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions')), 'warning');
}

View file

@ -33,4 +33,17 @@ class InstallerKernel extends DrupalKernel {
$this->configStorage = NULL;
}
/**
* Returns the active configuration storage used during early install.
*
* This override changes the visibility so that the installer can access
* config storage before the container is properly built.
*
* @return \Drupal\Core\Config\StorageInterface
* The config storage.
*/
public function getConfigStorage() {
return parent::getConfigStorage();
}
}

View file

@ -14,4 +14,3 @@ class KeyValueExpirableFactory extends KeyValueFactory implements KeyValueExpira
const DEFAULT_SETTING = 'keyvalue_expirable_default';
}

View file

@ -75,4 +75,3 @@ class KeyValueFactory implements KeyValueFactoryInterface {
}
}

View file

@ -19,4 +19,3 @@ interface KeyValueFactoryInterface {
public function get($collection);
}

View file

@ -178,7 +178,7 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
* {@inheritdoc}
*/
public function getDefinitions() {
$definitions = parent::getDefinitions();
$definitions = parent::getDefinitions();
$count = 0;
foreach ($definitions as &$definition) {

View file

@ -2,6 +2,8 @@
namespace Drupal\Core\PageCache;
use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod;
use Drupal\Core\PageCache\RequestPolicy\NoSessionOpen;
use Drupal\Core\Session\SessionConfigurationInterface;
/**
@ -20,8 +22,8 @@ class DefaultRequestPolicy extends ChainRequestPolicy {
* The session configuration.
*/
public function __construct(SessionConfigurationInterface $session_configuration) {
$this->addPolicy(new RequestPolicy\CommandLineOrUnsafeMethod());
$this->addPolicy(new RequestPolicy\NoSessionOpen($session_configuration));
$this->addPolicy(new CommandLineOrUnsafeMethod());
$this->addPolicy(new NoSessionOpen($session_configuration));
}
}

View file

@ -42,4 +42,3 @@ class DenyNoCacheRoutes implements ResponsePolicyInterface {
}
}

View file

@ -187,7 +187,7 @@ class PhpassHashedPassword implements PasswordInterface {
} while (--$count);
$len = strlen($hash);
$output = $setting . $this->base64Encode($hash, $len);
$output = $setting . $this->base64Encode($hash, $len);
// $this->base64Encode() of a 16 byte MD5 will always be 22 characters.
// $this->base64Encode() of a 64 byte sha512 will always be 86 characters.
$expected = 12 + ceil((8 * $len) / 6);

View file

@ -64,4 +64,3 @@ class QueueFactory implements ContainerAwareInterface {
return $this->queues[$name];
}
}

View file

@ -17,7 +17,7 @@ use Drupal\Core\Render\Element;
* $form['actions'] = array('#type' => 'actions');
* $form['actions']['submit'] = array(
* '#type' => 'submit',
* '#value' => t('Save'),
* '#value' => $this->t('Save'),
* );
* @endcode
*

View file

@ -72,10 +72,9 @@ class Button extends FormElement {
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #attributes, #button_type, #name, #value.
*
* The #button_type property accepts any value, though core themes have CSS that
* styles the following button_types appropriately: 'primary', 'danger'.
* Properties used: #attributes, #button_type, #name, #value. The
* #button_type property accepts any value, though core themes have CSS that
* styles the following button_types appropriately: 'primary', 'danger'.
*
* @return array
* The $element with prepared variables ready for input.html.twig.

View file

@ -15,7 +15,7 @@ use Drupal\Core\Render\Element;
* @code
* $form['copy'] = array(
* '#type' => 'checkbox',
* '#title' => t('Send me a copy'),
* '#title' => $this->t('Send me a copy'),
* );
* @endcode
*

View file

@ -17,8 +17,8 @@ use Drupal\Core\Form\FormStateInterface;
* @code
* $form['high_school']['tests_taken'] = array(
* '#type' => 'checkboxes',
* '#options' => array('SAT' => t('SAT'), 'ACT' => t('ACT'))),
* '#title' => t('What standardized tests did you take?'),
* '#options' => array('SAT' => $this->t('SAT'), 'ACT' => $this->t('ACT'))),
* '#title' => $this->t('What standardized tests did you take?'),
* ...
* );
* @endcode

View file

@ -16,7 +16,7 @@ use Drupal\Component\Utility\Color as ColorUtility;
* @code
* $form['color'] = array(
* '#type' => 'color',
* '#title' => 'Color',
* '#title' => $this->t('Color'),
* '#default_value' => '#ffffff',
* );
* @endcode

View file

@ -15,7 +15,7 @@ use Drupal\Core\Form\FormStateInterface;
* @code
* $form['needs_accommodation'] = array(
* '#type' => 'checkbox',
* '#title' => 'Need Special Accommodations?',
* '#title' => $this->t('Need Special Accommodations?'),
* );
*
* $form['accommodation'] = array(
@ -32,7 +32,7 @@ use Drupal\Core\Form\FormStateInterface;
*
* $form['accommodation']['diet'] = array(
* '#type' => 'textfield',
* '#title' => t('Dietary Restrictions'),
* '#title' => $this->t('Dietary Restrictions'),
* );
* @endcode
*

View file

@ -15,7 +15,7 @@ use Drupal\Core\Render\Element;
* @code
* $form['expiration'] = array(
* '#type' => 'date',
* '#title' => t('Content expiration'),
* '#title' => $this->t('Content expiration'),
* '#default_value' => array('year' => 2020, 'month' => 2, 'day' => 15,)
* );
* @endcode
@ -76,11 +76,9 @@ class Date extends FormElement {
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #options, #description, #required,
* #attributes, #id, #name, #type, #min, #max, #step, #value, #size.
*
* Note: The input "name" attribute needs to be sanitized before output, which
* is currently done by initializing Drupal\Core\Template\Attribute with
* all the attributes.
* #attributes, #id, #name, #type, #min, #max, #step, #value, #size. The
* #name property will be sanitized before output. This is currently done by
* initializing Drupal\Core\Template\Attribute with all the attributes.
*
* @return array
* The $element with prepared variables ready for #theme 'input__date'.

View file

@ -20,12 +20,12 @@ use Drupal\Core\Render\Element;
* @code
* $form['author'] = array(
* '#type' => 'details',
* '#title' => 'Author',
* '#title' => $this->t('Author'),
* );
*
* $form['author']['name'] = array(
* '#type' => 'textfield',
* '#title' => t('Name'),
* '#title' => $this->t('Name'),
* );
* @endcode
*

View file

@ -15,7 +15,7 @@ use Drupal\Core\Render\Element;
* @code
* $form['email'] = array(
* '#type' => 'email',
* '#title' => t('Email'),
* '#title' => $this->t('Email'),
* );
* @end
*

View file

@ -9,12 +9,12 @@ namespace Drupal\Core\Render\Element;
* @code
* $form['author'] = array(
* '#type' => 'fieldset',
* '#title' => 'Author',
* '#title' => $this->t('Author'),
* );
*
* $form['author']['name'] = array(
* '#type' => 'textfield',
* '#title' => t('Name'),
* '#title' => $this->t('Name'),
* );
* @endcode
*

View file

@ -21,7 +21,7 @@ use Drupal\Component\Utility\Number as NumberUtility;
* @code
* $form['quantity'] = array(
* '#type' => 'number',
* '#title' => t('Quantity'),
* '#title' => $this->t('Quantity'),
* );
* @endcode
*

View file

@ -12,7 +12,7 @@ use Drupal\Core\Render\Element;
* @code
* $form['pass'] = array(
* '#type' => 'password',
* '#title => t('Password'),
* '#title' => $this->t('Password'),
* '#size' => 25,
* );
* @endcode

View file

@ -14,7 +14,7 @@ use Drupal\Core\Form\FormStateInterface;
* @code
* $form['pass'] = array(
* '#type' => 'password_confirm',
* '#title' => t('Password'),
* '#title' => $this->t('Password'),
* '#size' => 25,
* );
* @endcode
@ -65,7 +65,7 @@ class PasswordConfirm extends FormElement {
* Expand a password_confirm field into two text boxes.
*/
public static function processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form) {
$element['pass1'] = array(
$element['pass1'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
@ -73,7 +73,7 @@ class PasswordConfirm extends FormElement {
'#attributes' => array('class' => array('password-field', 'js-password-field')),
'#error_no_message' => TRUE,
);
$element['pass2'] = array(
$element['pass2'] = array(
'#type' => 'password',
'#title' => t('Confirm password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],

Some files were not shown because too many files have changed in this diff Show more