PHP 7.4 fixes

- Fix `Model::activeAttributes()` to access array offset on value of non-string
- Fix incorrect decoding of default binary value for PostgreSQL
- Fix incorrect type-casting of reflection type to string
This commit is contained in:
Alexander Makarov
2019-12-10 15:08:45 +03:00
committed by GitHub
parent c7f07cce94
commit 69b1966b4a
5 changed files with 9 additions and 4 deletions

View File

@ -198,7 +198,7 @@ before_script:
# Disable DEPRECATE messages during PHPUnit initialization on PHP 7.2. To fix them, PHPUnit should be updated to 6.* # Disable DEPRECATE messages during PHPUnit initialization on PHP 7.2. To fix them, PHPUnit should be updated to 6.*
# For Yii2 tests, messages will be enabled by tests/bootstrap.php # For Yii2 tests, messages will be enabled by tests/bootstrap.php
- | - |
if [[ $TRAVIS_PHP_VERSION == 7.2 || $TRAVIS_PHP_VERSION == 7.3 || $TRAVIS_PHP_VERSION == 7.4snapshot || $TRAVIS_PHP_VERSION = nightly ]]; then if [[ $TRAVIS_PHP_VERSION == 7.2 || $TRAVIS_PHP_VERSION == 7.3 || $TRAVIS_PHP_VERSION == 7.4 || $TRAVIS_PHP_VERSION = nightly ]]; then
echo 'Disabled DEPRECATED notifications for PHP >= 7.2'; echo 'Disabled DEPRECATED notifications for PHP >= 7.2';
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> /tmp/php-config.ini; echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> /tmp/php-config.ini;
phpenv config-add /tmp/php-config.ini; phpenv config-add /tmp/php-config.ini;

View File

@ -7,7 +7,9 @@ Yii Framework 2 Change Log
- Bug #17685: Fix invalid db component in `m180523_151638_rbac_updates_indexes_without_prefix` (rvkulikov) - Bug #17685: Fix invalid db component in `m180523_151638_rbac_updates_indexes_without_prefix` (rvkulikov)
- Bug #17694: Fixed Error Handler to clear registered view tags, scripts, and files when rendering error view through action view (bizley) - Bug #17694: Fixed Error Handler to clear registered view tags, scripts, and files when rendering error view through action view (bizley)
- Bug #17701: Throw `BadRequetHttpException` when request params cant be bound to `int` and `float` controller action arguments (brandonkelly) - Bug #17701: Throw `BadRequetHttpException` when request params cant be bound to `int` and `float` controller action arguments (brandonkelly)
- Bug #17723: Fix `Model::activeAttributes()` to access array offset on value of non-string (samdark)
- Bug #17723: Fix incorrect decoding of default binary value for PostgreSQL (samdark)
- Bug #17723: Fix incorrect type-casting of reflection type to string (samdark)
2.0.30 November 19, 2019 2.0.30 November 19, 2019
------------------------ ------------------------

View File

@ -819,7 +819,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
} }
$attributes = array_keys(array_flip($scenarios[$scenario])); $attributes = array_keys(array_flip($scenarios[$scenario]));
foreach ($attributes as $i => $attribute) { foreach ($attributes as $i => $attribute) {
if ($attribute[0] === '!') { if (strncmp($attribute, '!', 1) === 0) {
$attributes[$i] = substr($attribute, 1); $attributes[$i] = substr($attribute, 1);
} }
} }

View File

@ -552,6 +552,8 @@ SQL;
$column->defaultValue = new Expression($column->defaultValue); $column->defaultValue = new Expression($column->defaultValue);
} elseif ($column->type === 'boolean') { } elseif ($column->type === 'boolean') {
$column->defaultValue = ($column->defaultValue === 'true'); $column->defaultValue = ($column->defaultValue === 'true');
} elseif (preg_match("/^B'(.*?)'::/", $column->defaultValue, $matches)) {
$column->defaultValue = bindec($matches[1]);
} elseif (strncasecmp($column->dbType, 'bit', 3) === 0 || strncasecmp($column->dbType, 'varbit', 6) === 0) { } elseif (strncasecmp($column->dbType, 'bit', 3) === 0 || strncasecmp($column->dbType, 'varbit', 6) === 0) {
$column->defaultValue = bindec(trim($column->defaultValue, 'B\'')); $column->defaultValue = bindec(trim($column->defaultValue, 'B\''));
} elseif (preg_match("/^'(.*?)'::/", $column->defaultValue, $matches)) { } elseif (preg_match("/^'(.*?)'::/", $column->defaultValue, $matches)) {

View File

@ -139,7 +139,8 @@ class Controller extends \yii\base\Controller
$type->isBuiltin() && $type->isBuiltin() &&
($params[$name] !== null || !$type->allowsNull()) ($params[$name] !== null || !$type->allowsNull())
) { ) {
switch ((string)$type) { $typeName = PHP_VERSION_ID >= 70100 ? $type->getName() : (string)$type;
switch ($typeName) {
case 'int': case 'int':
$params[$name] = filter_var($params[$name], FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE); $params[$name] = filter_var($params[$name], FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
break; break;