Merge branch 'master' into master

This commit is contained in:
Roberto Braga
2023-07-11 10:07:02 +02:00
committed by GitHub
18 changed files with 355 additions and 243 deletions

View File

@ -4,7 +4,7 @@ on: [push, pull_request]
env:
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
PHPUNIT_EXCLUDE_GROUP: mssql,oci,wincache,xcache,zenddata,cubrid
PHPUNIT_EXCLUDE_GROUP: db,wincache,xcache,zenddata
XDEBUG_MODE: coverage, develop
concurrency:
@ -14,89 +14,94 @@ concurrency:
jobs:
phpunit:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: yiitest
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:9.6
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: yiitest
ports:
- 5432:5432
options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2]
include:
- php: 5.4
coverage: none
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 5.5
coverage: none
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 5.6
coverage: none
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 7.0
coverage: none
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 7.1
coverage: none
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 7.2
coverage: none
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 7.3
coverage: none
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 7.4
coverage: xdebug
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 8.0
coverage: none
extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 8.1
coverage: none
extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
os: ubuntu-latest
- php: 8.2
extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
coverage: none
os: ubuntu-latest
steps:
- name: Generate french locale
- name: Generate french locale.
run: sudo locale-gen fr_FR.UTF-8
- name: Checkout
- name: Checkout.
uses: actions/checkout@v3
- name: Install PHP
- name: Install PHP.
uses: shivammathur/setup-php@v2
with:
coverage: ${{ matrix.coverage }}
extensions: ${{ matrix.extensions }}
ini-values: apc.enabled=1,apc.shm_size=32M,apc.enable_cli=1, date.timezone='UTC', session.save_path="${{ runner.temp }}"
php-version: ${{ matrix.php }}
tools: pecl
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached, mysql, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, sqlite
ini-values: date.timezone='UTC', session.save_path="${{ runner.temp }}"
- name: Install Memcached
- name: Install Memcached.
uses: niden/actions-memcached@v7
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
- name: Install dependencies.
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: PHP Unit tests
- name: Run tests with PHPUnit.
if: matrix.php < '7.4' || matrix.php >= '8.1'
run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --colors=always
npm:
name: NPM 6 on ubuntu-latest
runs-on: ubuntu-latest
- name: Run tests with PHPUnit.
if: matrix.php == '8.0'
run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --colors=always
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
- name: Run tests with PHPUnit and generate coverage.
if: matrix.php == '7.4'
run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --coverage-clover=coverage.xml --colors=always
- name: Upload coverage to Codecov.
if: matrix.php == '7.4'
uses: codecov/codecov-action@v3
with:
php-version: 7.2
ini-values: session.save_path=${{ runner.temp }}
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: Install node.js
uses: actions/setup-node@v1
with:
node-version: 6
- name: Tests
run: |
npm install
npm test
# env:
# CI: true
file: ./coverage.xml

View File

@ -3,6 +3,7 @@ on:
- push
name: ci-mssql
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@ -12,37 +13,22 @@ jobs:
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql }}
env:
key: cache
EXTENSIONS: pdo, pdo_sqlsrv
XDEBUG_MODE: coverage, develop
runs-on: ubuntu-latest
strategy:
matrix:
include:
- php: 7.0
extensions: pdo, pdo_sqlsrv-5.8.1
mssql: server:2017-latest
- php: 7.1
extensions: pdo, pdo_sqlsrv-5.8.1
mssql: server:2017-latest
- php: 7.2
extensions: pdo, pdo_sqlsrv-5.8.1
mssql: server:2017-latest
- php: 7.3
extensions: pdo, pdo_sqlsrv-5.8.1
mssql: server:2017-latest
- php: 7.4
extensions: pdo, pdo_sqlsrv
mssql: server:2017-latest
- php: 7.4
extensions: pdo, pdo_sqlsrv
mssql: server:2019-latest
- php: 8.0
extensions: pdo, pdo_sqlsrv
mssql: server:2017-latest
- php: 8.0
extensions: pdo, pdo_sqlsrv
mssql: server:2019-latest
- php: 8.1
mssql: server:2019-latest
- php: 8.2
mssql: server:2022-latest
services:
mssql:
@ -65,42 +51,28 @@ jobs:
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
coverage: xdebug
extensions: ${{ env.EXTENSIONS }}
ini-values: date.timezone='UTC'
php-version: ${{ matrix.php }}
tools: composer:v2, pecl
- name: Determine composer cache directory on Linux
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Update composer
run: composer self-update
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install dependencies with composer php 8.0
if: matrix.php == '8.0'
run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Run MSSQL tests with PHPUnit and generate coverage.
if: matrix.php == '7.4'
run: vendor/bin/phpunit --group mssql --coverage-clover=coverage.xml --colors=always
- name: PHP Unit tests for PHP 7.1
run: vendor/bin/phpunit --coverage-clover=coverage.clover --group mssql --colors=always
if: matrix.php == '7.1'
- name: Run tests with phpunit without coverage
- name: Run MSSQL tests with PHPUnit.
if: matrix.php > '7.4'
run: vendor/bin/phpunit --group mssql --colors=always
- name: Code coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
if: matrix.php == '7.1'
continue-on-error: true # if is fork
- name: Upload coverage to Codecov.
if: matrix.php == '7.4'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

View File

@ -3,16 +3,17 @@ on:
- push
name: ci-mysql
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: PHP ${{ matrix.php-version }}-mysql-${{ matrix.mysql-version }}
name: PHP ${{ matrix.php }}-mysql-${{ matrix.mysql }}
env:
extensions: curl, intl, pdo, pdo_mysql
key: cache-v1
XDEBUG_MODE: coverage, develop
runs-on: ${{ matrix.os }}
@ -21,15 +22,19 @@ jobs:
os:
- ubuntu-latest
php-version:
php:
- 7.4
- 8.0
- 8.1
- 8.2
mysql-version:
mysql:
- 5.7
- latest
services:
mysql:
image: mysql:${{ matrix.mysql-version }}
image: mysql:${{ matrix.mysql }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: yiitest
@ -38,46 +43,31 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
- name: Checkout.
uses: actions/checkout@v3
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Install PHP with extensions
- name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.extensions }}
coverage: xdebug
extensions: ${{ env.EXTENSIONS }}
ini-values: date.timezone='UTC'
coverage: pcov
php-version: ${{ matrix.php }}
tools: composer:v2, pecl
- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
- name: Install dependencies with composer
- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Run mysql tests with phpunit
- name: Run MySQL tests with PHPUnit and generate coverage.
if: matrix.php == '7.4'
run: vendor/bin/phpunit --group mysql --coverage-clover=coverage.xml --colors=always
- name: Run MySQL tests with PHPUnit.
if: matrix.php > '7.4'
run: vendor/bin/phpunit --group mysql --colors=always
- name: Upload coverage to Codecov.
if: matrix.php == '7.4'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

36
.github/workflows/ci-node.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: build-node
on: [push, pull_request]
env:
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: NPM 6 on ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Checkout.
uses: actions/checkout@v3
- name: Install dependencies.
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: Install JQuery `3.6.*@stable` for tests.
run: composer require "bower-asset/jquery:3.6.*@stable"
- name: Install node.js.
uses: actions/setup-node@v1
with:
node-version: 6
- name: Tests.
run: |
npm install
npm test

View File

@ -3,6 +3,7 @@ on:
- push
name: ci-oracle
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@ -13,7 +14,7 @@ jobs:
env:
extensions: oci8, pdo, pdo_oci
key: cache-v1
XDEBUG_MODE: coverage, develop
runs-on: ${{ matrix.os }}
@ -33,52 +34,28 @@ jobs:
options: --name=oci
steps:
- name: Checkout
- name: Checkout.
uses: actions/checkout@v3
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Install PHP with extensions
- name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
coverage: xdebug
extensions: ${{ env.EXTENSIONS }}
ini-values: date.timezone='UTC'
coverage: pcov
php-version: ${{ matrix.php }}
tools: composer:v2, pecl
- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Update composer.
run: composer self-update
- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: PHP Unit tests
run: vendor/bin/phpunit --coverage-clover=coverage.clover --group oci --colors=always
- name: Run Oracle tests with PHPUnit and generate coverage.
run: vendor/bin/phpunit --group oci --coverage-clover=coverage.xml --colors=always
- name: Code coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
continue-on-error: true # if is fork
- name: Upload coverage to Codecov.
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

View File

@ -3,16 +3,17 @@ on:
- push
name: ci-pgsql
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: PHP ${{ matrix.php-version }}-pgsql-${{ matrix.pgsql-version }}
name: PHP ${{ matrix.php }}-pgsql-${{ matrix.pgsql }}
env:
extensions: curl, intl, pdo, pdo_pgsql
key: cache-v1
XDEBUG_MODE: coverage, develop
runs-on: ${{ matrix.os }}
@ -21,19 +22,22 @@ jobs:
os:
- ubuntu-latest
php-version:
php:
- 7.4
- 8.0
- 8.1
pgsql-version:
pgsql:
- 10
- 11
- 12
- 13
- 14
- 15
services:
postgres:
image: postgres:${{ matrix.pgsql-version }}
image: postgres:${{ matrix.pgsql }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
@ -43,46 +47,34 @@ jobs:
options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
- name: Checkout.
uses: actions/checkout@v3
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.extensions }}
coverage: xdebug
extensions: ${{ env.EXTENSIONS }}
ini-values: date.timezone='UTC'
coverage: pcov
php-version: ${{ matrix.php }}
tools: composer:v2, pecl
- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Update composer.
run: composer self-update
- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
- name: Install dependencies with composer
- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Run pgsql tests with phpunit
- name: Run Pgsql tests with PHPUnit and generate coverage.
if: matrix.php == '7.4'
run: vendor/bin/phpunit --group pgsql --coverage-clover=coverage.xml --colors=always
- name: Run Pgsql tests with PHPUnit.
if: matrix.php > '7.4'
run: vendor/bin/phpunit --group pgsql --colors=always
- name: Upload coverage to Codecov.
if: matrix.php == '7.4'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

63
.github/workflows/ci-sqlite.yml vendored Normal file
View File

@ -0,0 +1,63 @@
on:
- pull_request
- push
name: ci-sqlite
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: PHP ${{ matrix.php }}-sqlite
env:
EXTENSIONS: pdo, pdo_sqlite, sqlite3
XDEBUG_MODE: coverage, develop
runs-on: ubuntu-latest
strategy:
matrix:
os:
- ubuntu-latest
php:
- 7.4
- 8.0
- 8.1
- 8.2
steps:
- name: Checkout.
uses: actions/checkout@v3
- name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
extensions: ${{ env.EXTENSIONS }}
ini-values: date.timezone='UTC'
php-version: ${{ matrix.php }}
tools: composer:v2, pecl
- name: Update composer.
run: composer self-update
- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Run SQLite tests with PHPUnit and generate coverage.
if: matrix.php == '7.4'
run: vendor/bin/phpunit --group sqlite --coverage-clover=coverage.xml --colors=always
- name: Run SQLite tests with PHPUnit.
if: matrix.php > '7.4'
run: vendor/bin/phpunit --group sqlite --colors=always
- name: Upload coverage to Codecov.
if: matrix.php == '7.4'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

View File

@ -4,10 +4,12 @@ Yii Framework 2 Change Log
2.0.49 under development
------------------------
- Bug #19857: Fix AttributeTypecastBehavior::resetOldAttributes() causes "class has no attribute named" InvalidArgumentException (uaoleg)
- Bug #18859: Fix `yii\web\Controller::bindInjectedParams()` to not throw error when argument of `ReflectionUnionType` type is passed (bizley)
- Enh #19841: Allow jQuery 3.7 to be installed (wouter90)
- Enh #19853: Added support for default value for `\yii\helpers\Console::select()` (rhertogh)
- Bug #19868: Added whitespace sanitation for tests, due to updates in ICU 72 (schmunk42)
- Enh #19884: Added support Enums in Query Builder (sk1t0n)
2.0.48.1 May 24, 2023

View File

@ -366,7 +366,10 @@ class AttributeTypecastBehavior extends Behavior
$this->resetOldAttributes();
}
private function resetOldAttributes()
/**
* Resets the old values of the named attributes.
*/
protected function resetOldAttributes()
{
if ($this->attributeTypes === null) {
return;
@ -375,7 +378,9 @@ class AttributeTypecastBehavior extends Behavior
$attributes = array_keys($this->attributeTypes);
foreach ($attributes as $attribute) {
$this->owner->setOldAttribute($attribute, $this->owner->{$attribute});
if ($this->owner->canSetOldAttribute($attribute)) {
$this->owner->setOldAttribute($attribute, $this->owner->{$attribute});
}
}
}
}

View File

@ -576,13 +576,24 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
*/
public function setOldAttribute($name, $value)
{
if (isset($this->_oldAttributes[$name]) || $this->hasAttribute($name)) {
if ($this->canSetOldAttribute($name)) {
$this->_oldAttributes[$name] = $value;
} else {
throw new InvalidArgumentException(get_class($this) . ' has no attribute named "' . $name . '".');
}
}
/**
* Returns if the old named attribute can be set.
* @param string $name the attribute name
* @return bool whether the old attribute can be set
* @see setOldAttribute()
*/
public function canSetOldAttribute($name)
{
return (isset($this->_oldAttributes[$name]) || $this->hasAttribute($name));
}
/**
* Marks an attribute dirty.
* This method may be called to force updating a record when calling [[update()]],

View File

@ -377,6 +377,13 @@ class Command extends Component
$this->pendingParams[$name] = [$value->getValue(), $value->getType()];
$this->params[$name] = $value->getValue();
} else {
if (version_compare(PHP_VERSION, '8.1.0') >= 0) {
if ($value instanceof \BackedEnum) {
$value = $value->value;
} elseif ($value instanceof \UnitEnum) {
$value = $value->name;
}
}
$type = $schema->getPdoType($value);
$this->pendingParams[$name] = [$value, $type];
$this->params[$name] = $value;
@ -631,15 +638,15 @@ class Command extends Component
*
* The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'),
* where name stands for a column name which will be properly quoted by the method, and definition
* stands for the column type which must contain an abstract DB type.
*
* stands for the column type which must contain an abstract DB type.
*
* The method [[QueryBuilder::getColumnType()]] will be called
* to convert the abstract column types to physical ones. For example, `string` will be converted
* as `varchar(255)`, and `string not null` becomes `varchar(255) not null`.
*
* If a column is specified with definition only (e.g. 'PRIMARY KEY (name, type)'), it will be directly
* inserted into the generated SQL.
*
*
* Example usage:
* ```php
* Yii::$app->db->createCommand()->createTable('post', [
@ -647,7 +654,7 @@ class Command extends Component
* 'title' => 'string',
* 'text' => 'text',
* 'column_name double precision null default null',
* ]);
* ]);
* ```
*
* @param string $table the name of the table to be created. The name will be properly quoted by the method.

View File

@ -21,7 +21,6 @@
<file>framework/web/ResponseFormatterInterface.php</file>
<file>framework/.phpstorm.meta.php</file>
<directory suffix="Exception.php">framework/base</directory>
<directory suffix=".php">framework/db/mssql</directory>
<directory suffix=".php">framework/bootstrap</directory>
</blacklist>
</filter>

View File

@ -23,7 +23,7 @@ class ApcCacheTest extends CacheTestCase
*/
protected function getCacheInstance()
{
if (!extension_loaded('apc')) {
if (!extension_loaded('apc') && !extension_loaded('apcu')) {
$this->markTestSkipped('APC not installed. Skipping.');
} elseif ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) {
$this->markTestSkipped('APC cli is not enabled. Skipping.');
@ -33,7 +33,9 @@ class ApcCacheTest extends CacheTestCase
$this->markTestSkipped('APC is installed but not enabled. Skipping.');
}
if ($this->_cacheInstance === null) {
if ($this->_cacheInstance === null && PHP_VERSION_ID >= 70400) {
$this->_cacheInstance = new ApcCache(['useApcu' => true]);
} elseif ($this->_cacheInstance === null) {
$this->_cacheInstance = new ApcCache();
}

View File

@ -1525,4 +1525,23 @@ SQL;
$db->createCommand()->setSql("SELECT :p1")->bindValues([':p1' => [2, \PDO::PARAM_STR]]);
$this->assertTrue(true);
}
public function testBindValuesSupportsEnums()
{
if (version_compare(PHP_VERSION, '8.1.0') >= 0) {
$db = $this->getConnection();
$command = $db->createCommand();
$command->setSql('SELECT :p1')->bindValues([':p1' => enums\Status::ACTIVE]);
$this->assertSame('ACTIVE', $command->params[':p1']);
$command->setSql('SELECT :p1')->bindValues([':p1' => enums\StatusTypeString::ACTIVE]);
$this->assertSame('active', $command->params[':p1']);
$command->setSql('SELECT :p1')->bindValues([':p1' => enums\StatusTypeInt::ACTIVE]);
$this->assertSame(1, $command->params[':p1']);
} else {
$this->markTestSkipped('Enums are not supported in PHP < 8.1');
}
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace yiiunit\framework\db\enums;
enum Status
{
case ACTIVE;
case INACTIVE;
}

View File

@ -0,0 +1,9 @@
<?php
namespace yiiunit\framework\db\enums;
enum StatusTypeInt: int
{
case ACTIVE = 1;
case INACTIVE = 0;
}

View File

@ -0,0 +1,9 @@
<?php
namespace yiiunit\framework\db\enums;
enum StatusTypeString: string
{
case ACTIVE = 'active';
case INACTIVE = 'inactive';
}

View File

@ -119,7 +119,12 @@ class DeadLockTest extends \yiiunit\framework\db\mysql\ConnectionTest
. ($logContent ? ". Shared children log:\n$logContent" : '')
);
}
$this->assertEquals(1, $deadlockHitCount, "exactly one child must hit deadlock; shared children log:\n" . $logContent);
if (version_compare($this->getConnection()->getSchema()->getServerVersion(), '8.0', '<')) {
$this->assertEquals(1, $deadlockHitCount, "exactly one child must hit deadlock; shared children log:\n" . $logContent);
} else {
$this->assertEquals(0, $deadlockHitCount, "exactly zero children must hit deadlock; shared children log:\n" . $logContent);
}
}
/**