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

This commit is contained in:
Pantheon Automation 2017-02-02 16:28:38 -08:00 committed by Greg Anderson
parent db56c09587
commit f1e72395cb
588 changed files with 26857 additions and 2777 deletions

View file

@ -44,7 +44,7 @@ abstract class AbstractComparisonValidator extends ConstraintValidator
// the DateTime constructor:
// http://php.net/manual/en/datetime.formats.php
if (is_string($comparedValue)) {
if ($value instanceof \DatetimeImmutable) {
if ($value instanceof \DateTimeImmutable) {
// If $value is immutable, convert the compared value to a
// DateTimeImmutable too
$comparedValue = new \DatetimeImmutable($comparedValue);

View file

@ -23,8 +23,6 @@ class Callback extends Constraint
{
/**
* @var string|callable
*
* @since 2.4
*/
public $callback;

View file

@ -74,8 +74,10 @@ class CardSchemeValidator extends ConstraintValidator
'/^6[0-9]{11,18}$/',
),
// All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.
// October 2016 MasterCard numbers can also start with 222100 through 272099.
'MASTERCARD' => array(
'/^5[1-5][0-9]{14}$/',
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
),
// All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.
'VISA' => array(

View file

@ -24,8 +24,6 @@ use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
* let {@link getCompositeOption()} return the name of the property which
* contains the nested constraints.
*
* @since 2.6
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class Composite extends Constraint

View file

@ -56,8 +56,8 @@ class EmailValidator extends ConstraintValidator
}
if ($constraint->strict) {
if (!class_exists('\Egulias\EmailValidator\EmailValidator')) {
throw new RuntimeException('Strict email validation requires egulias/email-validator');
if (!class_exists('\Egulias\EmailValidator\EmailValidator') || interface_exists('\Egulias\EmailValidator\Validation\EmailValidation')) {
throw new RuntimeException('Strict email validation requires egulias/email-validator:~1.2');
}
$strictValidator = new \Egulias\EmailValidator\EmailValidator();

View file

@ -88,20 +88,22 @@ class File extends Constraint
private function normalizeBinaryFormat($maxSize)
{
$sizeInt = (int) $maxSize;
if (ctype_digit((string) $maxSize)) {
$this->maxSize = (int) $maxSize;
$this->maxSize = $sizeInt;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
} elseif (preg_match('/^\d++k$/i', $maxSize)) {
$this->maxSize = $maxSize * 1000;
$this->maxSize = $sizeInt * 1000;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
} elseif (preg_match('/^\d++M$/i', $maxSize)) {
$this->maxSize = $maxSize * 1000000;
$this->maxSize = $sizeInt * 1000000;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
} elseif (preg_match('/^\d++Ki$/i', $maxSize)) {
$this->maxSize = $maxSize << 10;
$this->maxSize = $sizeInt << 10;
$this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat;
} elseif (preg_match('/^\d++Mi$/i', $maxSize)) {
$this->maxSize = $maxSize << 20;
$this->maxSize = $sizeInt << 20;
$this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat;
} else {
throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size', $this->maxSize));

View file

@ -19,7 +19,7 @@ use Symfony\Component\Validator\Exception\OutOfBoundsException;
* When validating a group sequence, each group will only be validated if all
* of the previous groups in the sequence succeeded. For example:
*
* $validator->validate($address, null, new GroupSequence('Basic', 'Strict'));
* $validator->validate($address, null, new GroupSequence(array('Basic', 'Strict')));
*
* In the first step, all constraints that belong to the group "Basic" will be
* validated. If none of the constraints fail, the validator will then validate

View file

@ -21,7 +21,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
* @author Michael Schummel
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @link http://www.michael-schummel.de/2007/10/05/iban-prufung-mit-php/
* @see http://www.michael-schummel.de/2007/10/05/iban-prufung-mit-php/
*/
class IbanValidator extends ConstraintValidator
{
@ -34,7 +34,7 @@ class IbanValidator extends ConstraintValidator
* a BBAN (Basic Bank Account Number) which has a fixed length per country and,
* included within it, a bank identifier with a fixed position and a fixed length per country
*
* @link http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
* @see http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
*
* @var array
*/

View file

@ -144,14 +144,14 @@ class IsbnValidator extends ConstraintValidator
// If we test the length before the loop, we get an ERROR_TOO_SHORT
// when actually an ERROR_INVALID_CHARACTERS is wanted, e.g. for
// "0-45122_5244" (typo)
if (!isset($isbn{$i})) {
if (!isset($isbn[$i])) {
return Isbn::TOO_SHORT_ERROR;
}
if ('X' === $isbn{$i}) {
if ('X' === $isbn[$i]) {
$digit = 10;
} elseif (ctype_digit($isbn{$i})) {
$digit = $isbn{$i};
} elseif (ctype_digit($isbn[$i])) {
$digit = $isbn[$i];
} else {
return Isbn::INVALID_CHARACTERS_ERROR;
}
@ -159,7 +159,7 @@ class IsbnValidator extends ConstraintValidator
$checkSum += $digit * (10 - $i);
}
if (isset($isbn{$i})) {
if (isset($isbn[$i])) {
return Isbn::TOO_LONG_ERROR;
}
@ -190,11 +190,11 @@ class IsbnValidator extends ConstraintValidator
$checkSum = 0;
for ($i = 0; $i < 13; $i += 2) {
$checkSum += $isbn{$i};
$checkSum += $isbn[$i];
}
for ($i = 1; $i < 12; $i += 2) {
$checkSum += $isbn{$i}
$checkSum += $isbn[$i]
* 3;
}

View file

@ -48,7 +48,7 @@ class IssnValidator extends ConstraintValidator
// 1234-567X
// ^
if (isset($canonical{4}) && '-' === $canonical{4}) {
if (isset($canonical[4]) && '-' === $canonical[4]) {
// remove hyphen
$canonical = substr($canonical, 0, 4).substr($canonical, 5);
} elseif ($constraint->requireHyphen) {
@ -121,7 +121,7 @@ class IssnValidator extends ConstraintValidator
// 1234567X
// ^ digit, x or X
if (!ctype_digit($canonical{7}) && 'x' !== $canonical{7} && 'X' !== $canonical{7}) {
if (!ctype_digit($canonical[7]) && 'x' !== $canonical[7] && 'X' !== $canonical[7]) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -139,7 +139,7 @@ class IssnValidator extends ConstraintValidator
// 1234567X
// ^ case-sensitive?
if ($constraint->caseSensitive && 'x' === $canonical{7}) {
if ($constraint->caseSensitive && 'x' === $canonical[7]) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -156,14 +156,14 @@ class IssnValidator extends ConstraintValidator
}
// Calculate a checksum. "X" equals 10.
$checkSum = 'X' === $canonical{7}
|| 'x' === $canonical{7}
$checkSum = 'X' === $canonical[7]
|| 'x' === $canonical[7]
? 10
: $canonical{7};
: $canonical[7];
for ($i = 0; $i < 7; ++$i) {
// Multiply the first digit by 8, the second by 7, etc.
$checkSum += (8 - $i) * $canonical{$i};
$checkSum += (8 - $i) * $canonical[$i];
}
if (0 !== $checkSum % 11) {

View file

@ -40,13 +40,10 @@ class LengthValidator extends ConstraintValidator
$stringValue = (string) $value;
if ('UTF8' === $charset = strtoupper($constraint->charset)) {
$charset = 'UTF-8'; // iconv on Windows requires "UTF-8" instead of "UTF8"
if (!$invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset)) {
$length = mb_strlen($stringValue, $constraint->charset);
}
$length = @iconv_strlen($stringValue, $charset);
$invalidCharset = false === $length;
if ($invalidCharset) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->charsetMessage)

View file

@ -81,7 +81,7 @@ class LuhnValidator extends ConstraintValidator
// ^ ^ ^ ^ ^ ^
// = 7 + 9 + 7 + 9 + 7 + 3
for ($i = $length - 1; $i >= 0; $i -= 2) {
$checkSum += $value{$i};
$checkSum += $value[$i];
}
// Starting with the second last digit and walking left, double every
@ -91,7 +91,7 @@ class LuhnValidator extends ConstraintValidator
// ^ ^ ^ ^ ^
// = 1+8 + 4 + 6 + 1+6 + 2
for ($i = $length - 2; $i >= 0; $i -= 2) {
$checkSum += array_sum(str_split($value{$i} * 2));
$checkSum += array_sum(str_split($value[$i] * 2));
}
if (0 === $checkSum || 0 !== $checkSum % 10) {

View file

@ -56,7 +56,7 @@ class Regex extends Constraint
* Pattern is also ignored if match=false since the pattern should
* then be reversed before application.
*
* @link http://dev.w3.org/html5/spec/single-page.html#the-pattern-attribute
* @see http://dev.w3.org/html5/spec/single-page.html#the-pattern-attribute
*
* @return string|null
*/

View file

@ -17,8 +17,6 @@ use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
/**
* @Annotation
*
* @since 2.5
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class Traverse extends Constraint

View file

@ -25,13 +25,13 @@ class UrlValidator extends ConstraintValidator
(%s):// # protocol
(([\pL\pN-]+:)?([\pL\pN-]+)@)? # basic auth
(
([\pL\pN\pS-\.])+(\.?([\pL]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
| # or
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address
| # or
([\pL\pN\pS-\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
| # or
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address
| # or
\[
(?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1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9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,5}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,6}(?:(?:[0-9a-f]{1,4})))?::))))
\] # a IPv6 address
\] # an IPv6 address
)
(:[0-9]+)? # a port (optional)
(/?|/\S+|\?\S*|\#\S*) # a /, nothing, a / with something, a query or a fragment

View file

@ -81,6 +81,10 @@ class UuidValidator extends ConstraintValidator
return;
}
if (!$constraint instanceof Uuid) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Uuid');
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
@ -114,7 +118,7 @@ class UuidValidator extends ConstraintValidator
for ($i = 0; $i < $l; ++$i) {
// Check length
if (!isset($trimmed{$i})) {
if (!isset($trimmed[$i])) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -133,7 +137,7 @@ class UuidValidator extends ConstraintValidator
// Hyphens must occur every fifth position
// xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx
// ^ ^ ^ ^ ^ ^ ^
if ('-' === $trimmed{$i}) {
if ('-' === $trimmed[$i]) {
if ($i !== $h) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
@ -162,7 +166,7 @@ class UuidValidator extends ConstraintValidator
}
// Check characters
if (!ctype_xdigit($trimmed{$i})) {
if (!ctype_xdigit($trimmed[$i])) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -180,7 +184,7 @@ class UuidValidator extends ConstraintValidator
}
// Check length again
if (isset($trimmed{$i})) {
if (isset($trimmed[$i])) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -209,7 +213,7 @@ class UuidValidator extends ConstraintValidator
for ($i = 0; $i < self::STRICT_LENGTH; ++$i) {
// Check length
if (!isset($value{$i})) {
if (!isset($value[$i])) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -228,24 +232,18 @@ class UuidValidator extends ConstraintValidator
// Check hyphen placement
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
// ^ ^ ^ ^
if ('-' === $value{$i}) {
if ('-' === $value[$i]) {
if ($i !== $h) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter(
'{{ value }}',
$this->formatValue($value)
)
->setCode(Uuid::INVALID_HYPHEN_PLACEMENT_ERROR)
->addViolation();
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Uuid::INVALID_HYPHEN_PLACEMENT_ERROR)
->addViolation();
} else {
$this->buildViolation($constraint->message)
->setParameter(
'{{ value }}',
$this->formatValue($value)
)
->setCode(Uuid::INVALID_HYPHEN_PLACEMENT_ERROR)
->addViolation();
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Uuid::INVALID_HYPHEN_PLACEMENT_ERROR)
->addViolation();
}
return;
@ -261,7 +259,7 @@ class UuidValidator extends ConstraintValidator
}
// Check characters
if (!ctype_xdigit($value{$i})) {
if (!ctype_xdigit($value[$i])) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -296,7 +294,7 @@ class UuidValidator extends ConstraintValidator
}
// Check length again
if (isset($value{$i})) {
if (isset($value[$i])) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -311,7 +309,7 @@ class UuidValidator extends ConstraintValidator
}
// Check version
if (!in_array($value{self::STRICT_VERSION_POSITION}, $constraint->versions)) {
if (!in_array($value[self::STRICT_VERSION_POSITION], $constraint->versions)) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
@ -329,7 +327,7 @@ class UuidValidator extends ConstraintValidator
// 0b10xx
// & 0b1100 (12)
// = 0b1000 (8)
if ((hexdec($value{self::STRICT_VARIANT_POSITION}) & 12) !== 8) {
if ((hexdec($value[self::STRICT_VARIANT_POSITION]) & 12) !== 8) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))