This commit is contained in:
2020-07-13 17:09:59 +02:00
parent 03559a7b76
commit 3a082e23cc
492 changed files with 4129 additions and 982 deletions
@@ -39,7 +39,7 @@ class Plugin implements AnnotationInterface {
return $value !== NULL;
});
$parsed_values = $this->parse($values);
$this->definition = NestedArray::mergeDeep($defaults, $parsed_values);
$this->definition = NestedArray::mergeDeepArray([$defaults, $parsed_values], TRUE);
}
/**
@@ -26,7 +26,7 @@ class FileSecurity {
* TRUE if the file already exists or was created. FALSE otherwise.
*/
public static function writeHtaccess($directory, $deny_public_access = TRUE, $force = FALSE) {
return self::writeFile($directory, '/.htaccess', self::htaccessLines($deny_public_access), $force);
return self::writeFile($directory, '.htaccess', self::htaccessLines($deny_public_access), $force);
}
/**
@@ -110,7 +110,7 @@ EOF;
* TRUE if the file already exists or was created. FALSE otherwise.
*/
public static function writeWebConfig($directory, $force = FALSE) {
return self::writeFile($directory, '/web.config', self::webConfigLines(), $force);
return self::writeFile($directory, 'web.config', self::webConfigLines(), $force);
}
/**
@@ -152,7 +152,12 @@ EOT;
if (file_exists($file_path) && !$force) {
return TRUE;
}
if (file_exists($directory) && is_writable($directory) && file_put_contents($file_path, $contents)) {
// Writing the file can fail if:
// - concurrent requests are both trying to write at the same time.
// - $directory does not exist or is not writable.
// Testing for these conditions introduces windows for concurrency issues to
// occur.
if (@file_put_contents($file_path, $contents)) {
return @chmod($file_path, 0444);
}
return FALSE;
@@ -222,6 +222,7 @@ class MTimeProtectedFastFileStorage extends FileStorage {
* The directory where the temporary filename will be created.
* @param $prefix
* The prefix of the generated temporary filename.
*
* @return string
* Returns the new temporary filename (with path), or FALSE on failure.
*/
@@ -52,7 +52,7 @@ interface PhpStorageInterface {
public function save($name, $code);
/**
* Whether this is a writeable storage.
* Whether this is a writable storage.
*
* @return bool
*/
@@ -32,6 +32,7 @@ interface DeriverInterface {
*
* @param array $base_plugin_definition
* The definition array of the base plugin.
*
* @return array
* An array of full derivative definitions keyed on derivative id.
*
@@ -249,6 +249,7 @@ class Random {
* Generate paragraphs separated by double new line.
*
* @param int $paragraph_count
*
* @return string
*/
public function paragraphs($paragraph_count = 12) {
@@ -70,7 +70,7 @@ class Xss {
// Defuse all HTML entities.
$string = str_replace('&', '&', $string);
// Change back only well-formed entities in our whitelist:
// Change back only well-formed entities in our list of allowed html tags:
// Decimal numeric entities.
$string = preg_replace('/&#([0-9]+;)/', '&#\1', $string);
// Hexadecimal numeric entities.
@@ -83,7 +83,7 @@ class Xss {
$splitter = function ($matches) use ($html_tags, $class) {
return $class::split($matches[1], $html_tags, $class);
};
// Strip any tags that are not in the whitelist.
// Strip any tags that are not in the list of allowed html tags.
return preg_replace_callback('%
(
<(?=[^a-zA-Z!/]) # a lone <
@@ -161,7 +161,9 @@ class Xss {
$elem = '!--';
}
// When in whitelist mode, an element is disallowed when not listed.
// Defer to the ::needsRemoval() method to decide if the element is to be
// removed. This allows the list of tags to be treated as either a list of
// allowed tags or a list of denied tags.
if ($class::needsRemoval($html_tags, $elem)) {
return '';
}
@@ -188,6 +188,7 @@ class AssetResolver implements AssetResolverInterface {
*
* @param \Drupal\Core\Asset\AttachedAssetsInterface $assets
* The assets attached to the current response.
*
* @return array
* A (possibly optimized) collection of JavaScript assets.
*/
@@ -205,12 +205,18 @@ class BatchBuilder {
* The path should be relative to base_path(), and thus should be built using
* drupal_get_path(). Defaults to {module_name}.module.
*
* The file needs to be set before using ::addOperation(),
* ::setFinishCallback(), or any other function that uses callbacks from the
* file. This is so that PHP knows about the included functions.
*
* @param string $filename
* The path to the file.
*
* @return $this
*/
public function setFile($filename) {
include_once $filename;
$this->file = $filename;
return $this;
}
@@ -26,6 +26,7 @@ class DbCommandBase extends Command {
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* Input object.
*
* @return \Drupal\Core\Database\Connection
*/
protected function getDatabaseConnection(InputInterface $input) {
@@ -70,6 +70,7 @@ class DbDumpCommand extends DbCommandBase {
* The database connection to use.
* @param array $schema_only
* Table patterns for which to only dump the schema, no data.
*
* @return string
* The PHP script.
*/
@@ -105,6 +106,7 @@ class DbDumpCommand extends DbCommandBase {
*
* @param \Drupal\Core\Database\Connection $connection
* The database connection to use.
*
* @return array
* An array of table names.
*/
@@ -269,6 +269,7 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
* Configuration name with variables in square brackets.
* @param mixed $data
* Configuration data for the element.
*
* @return string
* Configuration name with variables replaced.
*/
@@ -778,6 +778,7 @@ abstract class Connection {
*
* @param string $class
* The class for which we want the potentially driver-specific class.
*
* @return string
* The name of the class that should be used for this driver.
*/
@@ -87,6 +87,7 @@ class Schema extends DatabaseSchema {
* The name of the table to create.
* @param $table
* A Schema API table definition array.
*
* @return
* An array of SQL statements to create the table.
*/
@@ -281,6 +281,7 @@ class Connection extends DatabaseConnection {
*
* @param $string
* The string to escape.
*
* @return string
* The escaped string.
*/
@@ -99,6 +99,7 @@ class Schema extends DatabaseSchema {
*
* @param $table_name
* The non-prefixed name of the table.
*
* @return
* An object with two member variables:
* - 'blob_fields' that lists all the blob fields in the table.
@@ -264,6 +265,7 @@ EOD;
* The name of the table to create.
* @param $table
* A Schema API table definition array.
*
* @return
* An array of SQL statements to create the table.
*/
@@ -1074,6 +1076,7 @@ EOD;
*
* @param $data
* String to be hashed.
*
* @return string
* A base-64 encoded sha-256 hash, with + and / replaced with _ and any =
* padding characters removed.
@@ -48,6 +48,7 @@ class Schema extends DatabaseSchema {
* The name of the table to create.
* @param $table
* A Schema API table definition array.
*
* @return
* An array of SQL statements to create the table.
*/
@@ -69,6 +69,7 @@ class Log {
*
* @param $logging_key
* The logging key to fetch.
*
* @return
* An indexed array of all query records for this logging key.
*/
@@ -169,6 +169,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
*
* @param $distinct
* TRUE to flag this query DISTINCT, FALSE to disable it.
*
* @return $this
* The called object.
*/
@@ -188,6 +189,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* automatically based on the $table_alias and $field. The alias will be
* checked for uniqueness, so the requested alias may not be the alias
* that is assigned in all cases.
*
* @return
* The unique alias that was assigned for this field.
*/
@@ -211,6 +213,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* An indexed array of fields present in the specified table that should be
* included in this query. If not specified, $table_alias.* will be generated
* without any aliases.
*
* @return $this
* The called object.
*/
@@ -232,6 +235,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* in all cases.
* @param $arguments
* Any placeholder arguments needed for this expression.
*
* @return
* The unique alias that was assigned for this expression.
*/
@@ -260,6 +264,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* system, for example, when joining the same table more than once.
* @param $arguments
* An array of arguments to replace into the $condition of this join.
*
* @return
* The unique alias that was assigned for this table.
*/
@@ -286,6 +291,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* system, for example, when joining the same table more than once.
* @param $arguments
* An array of arguments to replace into the $condition of this join.
*
* @return
* The unique alias that was assigned for this table.
*/
@@ -312,6 +318,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* system, for example, when joining the same table more than once.
* @param $arguments
* An array of arguments to replace into the $condition of this join.
*
* @return
* The unique alias that was assigned for this table.
*/
@@ -338,6 +345,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* system, for example, when joining the same table more than once.
* @param $arguments
* An array of arguments to replace into the $condition of this join.
*
* @return
* The unique alias that was assigned for this table.
*
@@ -379,6 +387,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* system, for example, when joining the same table more than once.
* @param $arguments
* An array of arguments to replace into the $condition of this join.
*
* @return
* The unique alias that was assigned for this table.
*/
@@ -411,6 +420,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @param $direction
* The direction to sort. Legal values are "ASC" and "DESC". Any other value
* will be converted to "ASC".
*
* @return $this
* The called object.
*/
@@ -449,6 +459,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* range directives that are set.
* @param $length
* The number of records to return from the result set.
*
* @return $this
* The called object.
*/
@@ -474,6 +485,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @param $type
* The type of UNION to add to the query. Defaults to plain
* UNION.
*
* @return $this
* The called object.
*/
@@ -484,6 +496,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
*
* @param $field
* The field on which to group. This should be the field as aliased.
*
* @return $this
* The called object.
*/
@@ -539,6 +552,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* The comparison operator, such as =, <, or >=. It also accepts more complex
* options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array
* = otherwise.
*
* @return \Drupal\Core\Database\Query\ConditionInterface
* The called object.
*/
@@ -216,6 +216,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
* The query.
* @param array|null $args
* An array of arguments. This can be NULL.
*
* @return \PDOStatement
* A PDOStatement object.
*/
@@ -452,6 +452,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
*
* @param \Drupal\Core\Field\FieldDefinitionInterface $definition
* A field definition.
*
* @return array|null
*/
private function fieldHasDisplayOptions(FieldDefinitionInterface $definition) {
@@ -35,6 +35,7 @@ interface ConditionAggregateInterface extends \Countable {
*
* @param $field
* @param string $langcode
*
* @return ConditionInterface
* @see \Drupal\Core\Entity\Query\QueryInterface::exists()
*/
@@ -44,6 +45,7 @@ interface ConditionAggregateInterface extends \Countable {
* Queries for the nonexistence of a field.
*
* @param string $field
*
* @return ConditionInterface
* @see \Drupal\Core\Entity\Query\QueryInterface::notExists()
*/
@@ -107,6 +107,7 @@ interface QueryInterface extends AlterableInterface {
* Name of a field.
* @param $langcode
* Language code (optional).
*
* @return $this
*/
public function exists($field, $langcode = NULL);
@@ -118,6 +119,7 @@ interface QueryInterface extends AlterableInterface {
* Name of a field.
* @param $langcode
* Language code (optional).
*
* @return $this
*/
public function notExists($field, $langcode = NULL);
@@ -144,6 +144,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface {
* The field as passed in by the caller.
* @param string $sql_field
* The sql field as returned by getSqlField.
*
* @return string
* The SQL alias expected in the return value. The dots in $sql_field are
* replaced with underscores and if a default fallback to .value happened,
@@ -373,7 +373,9 @@ class Tables implements TablesInterface {
*
* @param $field_name
* Name of the field.
*
* @return string
*
* @throws \Drupal\Core\Entity\Query\QueryException
*/
protected function ensureFieldTable($index_prefix, &$field, $type, $langcode, $base_table, $entity_id_field, $field_id_field, $delta) {
@@ -193,14 +193,9 @@ class ModuleInstaller implements ModuleInstallerInterface {
}
}
// Update the module handler in order to load the module's code.
// This allows the module to participate in hooks and its existence to
// be discovered by other modules.
// The current ModuleHandler instance is obsolete with the kernel
// rebuild below.
// Update the module handler in order to have the correct module list
// for the kernel update.
$this->moduleHandler->setModuleList($module_filenames);
$this->moduleHandler->load($module);
module_load_install($module);
// Clear the static cache of the "extension.list.module" service to pick
// up the new module, since it merges the installation status of modules
@@ -210,6 +205,10 @@ class ModuleInstaller implements ModuleInstallerInterface {
// Update the kernel to include it.
$this->updateKernel($module_filenames);
// Load the module's .module and .install files.
$this->moduleHandler->load($module);
module_load_install($module);
// Replace the route provider service with a version that will rebuild
// if routes used during installation. This ensures that a module's
// routes are available during installation. This has to occur before
@@ -125,9 +125,10 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* The default value is expressed as a numerically indexed array of items,
* each item being an array of key/value pairs matching the set of 'columns'
* defined by the "field schema" for the field type, as exposed in
* hook_field_schema(). If the number of items exceeds the cardinality of the
* field, extraneous items will be ignored.
* defined by the "field schema" for the field type, as exposed in the class
* implementing \Drupal\Core\Field\FieldItemInterface::schema() method. If the
* number of items exceeds the cardinality of the field, extraneous items will
* be ignored.
*
* This property is overlooked if the $default_value_callback is non-empty.
*
@@ -22,6 +22,7 @@ use Drupal\Core\StreamWrapper\StreamWrapperManager;
*
* @param $uri
* The URI of the file.
*
* @return
* If the user does not have permission to access the file, return -1. If the
* user has permission, return an array with the appropriate headers. If the
+10 -1
View File
@@ -19,6 +19,7 @@ use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\Theme\ThemeManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\FileBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
@@ -957,8 +958,16 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// This value is checked in self::handleInputElement().
$form_state->setInvalidToken(TRUE);
// Ignore all submitted values.
$form_state->setUserInput([]);
$request = $this->requestStack->getCurrentRequest();
// Do not trust any POST data.
$request->request = new ParameterBag();
// Make sure file uploads do not get processed.
$this->requestStack->getCurrentRequest()->files = new FileBag();
$request->files = new FileBag();
// Ensure PHP globals reflect these changes.
$request->overrideGlobals();
}
}
}
@@ -124,10 +124,8 @@ class FormValidator implements FormValidatorInterface {
* {@inheritdoc}
*/
public function setInvalidTokenError(FormStateInterface $form_state) {
$url = $this->requestStack->getCurrentRequest()->getRequestUri();
// Setting this error will cause the form to fail validation.
$form_state->setErrorByName('form_token', $this->t('The form has become outdated. Copy any unsaved work in the form below and then <a href=":link">reload this page</a>.', [':link' => $url]));
$form_state->setErrorByName('form_token', $this->t('The form has become outdated. Press the back button, copy any unsaved work in the form, and then reload the page.'));
}
/**
@@ -1459,6 +1459,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
*
* @param array $definitions
* The new menu link definitions.
*
* @return array
* A list of menu link IDs that no longer exist.
*/
+1 -1
View File
@@ -329,7 +329,7 @@ function hook_menu_local_tasks_alter(&$data, $route_name, \Drupal\Core\Cache\Ref
],
];
// The tab we're adding is dependent on a user's access to add content.
$cacheability->addCacheTags(['user.permissions']);
$cacheability->addCacheContexts(['user.permissions']);
}
/**
@@ -274,9 +274,9 @@
* vectors while allowing a permissive list of HTML tags that are not XSS
* vectors. (For example, <script> and <style> are not allowed.) See
* \Drupal\Component\Utility\Xss::$adminTags for the list of allowed tags. If
* your markup needs any of the tags not in this whitelist, then you can
* implement a theme hook and/or an asset library. Alternatively, you can use
* the key #allowed_tags to alter which tags are filtered.
* your markup needs any of the tags not in this list, then you can implement
* a theme hook and/or an asset library. Alternatively, you can use the key
* #allowed_tags to alter which tags are filtered.
* - #plain_text: Specifies that the array provides text that needs to be
* escaped. This value takes precedence over #markup.
* - #allowed_tags: If #markup is supplied, this can be used to change which
@@ -32,7 +32,7 @@ trait DoTrustedCallbackTrait {
* @param string $error_type
* (optional) The type of error to trigger. One of:
* - TrustedCallbackInterface::THROW_EXCEPTION
* - TrustedCallbackInterface::TRIGGER_DEPRECATION
* - TrustedCallbackInterface::TRIGGER_WARNING
* - TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION
* Defaults to TrustedCallbackInterface::THROW_EXCEPTION.
* @param string $extra_trusted_interface
@@ -45,7 +45,7 @@ interface StreamWrapperInterface extends PhpStreamWrapperInterface {
const READ = 0x0004;
/**
* Wrapper is writeable.
* Wrapper is writable.
*/
const WRITE = 0x0008;
@@ -67,12 +67,12 @@ interface StreamWrapperInterface extends PhpStreamWrapperInterface {
const HIDDEN = 0x000C;
/**
* Hidden, readable and writeable using local files.
* Hidden, readable and writable using local files.
*/
const LOCAL_HIDDEN = 0x000D;
/**
* Visible, readable and writeable.
* Visible, readable and writable.
*/
const WRITE_VISIBLE = 0x001C;
@@ -91,7 +91,7 @@ interface StreamWrapperInterface extends PhpStreamWrapperInterface {
const NORMAL = 0x001C;
/**
* Visible, readable and writeable using local files.
* Visible, readable and writable using local files.
*/
const LOCAL_NORMAL = 0x001D;
@@ -802,6 +802,7 @@ class Registry implements DestructableInterface {
*
* @param $prefixes
* An array of function prefixes by which the list can be limited.
*
* @return array
* Functions grouped by the first prefix.
*/
@@ -58,6 +58,7 @@ interface ThemeManagerInterface {
*
* @param \Drupal\Core\Theme\ActiveTheme $active_theme
* The new active theme.
*
* @return $this
*/
public function setActiveTheme(ActiveTheme $active_theme);
+1 -1
View File
@@ -291,7 +291,7 @@ class Updater {
return $this->postInstallTasks();
}
catch (FileTransferException $e) {
throw new UpdaterFileTransferException("File Transfer failed, reason: '" . strtr($e->getMessage(), $e->arguments)) . "'";
throw new UpdaterFileTransferException("File Transfer failed, reason: '" . strtr($e->getMessage(), $e->arguments) . "'");
}
}
@@ -77,7 +77,7 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface {
$parsed += ['query' => []];
$options += ['query' => []];
$options['query'] = NestedArray::mergeDeep($parsed['query'], $options['query']);
$options['query'] = NestedArray::mergeDeepArray([$parsed['query'], $options['query']], TRUE);
if ($parsed['fragment'] && !$options['fragment']) {
$options['fragment'] = '#' . $parsed['fragment'];
@@ -25,6 +25,7 @@ interface TranslatorInterface {
* The domain for the message or null to use the default.
* @param string|null $locale
* The locale or null to use the default.
*
* @return string
* The translated string.
*