Skip to content

Commit

Permalink
Merge branch 'master' into fix_behaviors_attachment
Browse files Browse the repository at this point in the history
# Conflicts:
#	framework/base/Component.php
#	tests/framework/base/ComponentTest.php
  • Loading branch information
erickskrauch committed Aug 14, 2024
2 parents 4b75427 + 34d2396 commit 05a8fbe
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 22 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/ci-mssql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:

jobs:
tests:
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql }}
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql.version }}

env:
EXTENSIONS: pdo, pdo_sqlsrv
Expand All @@ -21,37 +21,45 @@ jobs:
strategy:
fail-fast: false
matrix:
php:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4

mssql:
- version: server:2022-latest
mssql-tool: /opt/mssql-tools18/bin/sqlcmd -C

include:
- php: 7.4
mssql: server:2017-latest
mssql:
version: server:2017-latest
mssql-tool: /opt/mssql-tools/bin/sqlcmd
- php: 8.0
mssql: server:2019-latest
- php: 8.1
mssql: server:2019-latest
- php: 8.2
mssql: server:2022-latest
- php: 8.3
mssql: server:2022-latest
- php: 8.4
mssql: server:2022-latest
mssql:
version: server:2019-latest
mssql-tool: /opt/mssql-tools18/bin/sqlcmd -C

services:
mssql:
image: mcr.microsoft.com/mssql/${{ matrix.mssql }}
image: mcr.microsoft.com/mssql/${{ matrix.mssql.version }}
env:
SA_PASSWORD: YourStrong!Passw0rd
ACCEPT_EULA: Y
MSSQL_PID: Developer
ports:
- 1433:1433
options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3
options: --name=mssql --health-cmd="${{ matrix.mssql.mssql-tool }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create MS SQL Database
run: docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest'
run: docker exec -i mssql ${{ matrix.mssql.mssql-tool }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest'

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
Expand Down
10 changes: 10 additions & 0 deletions docs/guide-ja/db-active-record.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,16 @@ Customer::deleteAll(['status' => Customer::STATUS_INACTIVE]);
> - [[yii\db\ActiveRecord::updateCounters()]]
> - [[yii\db\ActiveRecord::updateAllCounters()]]
> Note: パフォーマンスを考慮して、DI(依存注入) はデフォルトではサポートされていません。必要であれば、
> [[Yii::createObject()]] によってクラスのインスタンス生成をするように [[yii\db\ActiveRecord::instantiate()|instantiate()]] メソッドをオーバーライドして、サポートを追加することが出来ます。
>
> ```php
> public static function instantiate($row)
> {
> return Yii::createObject(static::class);
> }
> ```
### データをリフレッシュする際のライフサイクル <span id="refreshing-data-life-cycle"></span>
[[yii\db\ActiveRecord::refresh()|refresh()]] を呼んでアクティブ・レコード・インスタンスをリフレッシュする際は、リフレッシュが成功してメソッドが `true` を返すと
Expand Down
2 changes: 1 addition & 1 deletion docs/guide-ru/db-active-record.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ $customer->loadDefaultValues();
Можно также использовать условия для столбцов JSON:

```php
$query->andWhere(['=', 'json', new ArrayExpression(['foo' => 'bar'])
$query->andWhere(['=', 'json', new ArrayExpression(['foo' => 'bar'])])
```
Дополнительные сведения о системе построения выражений см. [Query Builder – добавление пользовательских условий и выражений](db-query-builder.md#adding-custom-conditions-and-expressions)

Expand Down
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Yii Framework 2 Change Log
------------------------

- Bug #20232: Fix regression introduced in `GHSA-cjcc-p67m-7qxm` while attaching behavior defined by `__class` array key (erickskrauch)
- Bug #20231: Fix regression introduced in #20167 in `yii\validators\FileValidator` (bizley)

2.0.51 July 18, 2024
--------------------
Expand Down
2 changes: 1 addition & 1 deletion framework/validators/FileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function validateAttribute($model, $attribute)
{
$files = $this->filterFiles(is_array($model->$attribute) ? $model->$attribute : [$model->$attribute]);
$filesCount = count($files);
if ($filesCount === 0 && $this->minFiles > 0) {
if ($filesCount === 0) {
$this->addError($model, $attribute, $this->uploadRequired);

return;
Expand Down
16 changes: 10 additions & 6 deletions tests/framework/validators/FileValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ public function testValidateAttributeMultiple()
]);
$m = FakedValidationModel::createWithAttributes(['attr_files' => 'path']);
$val->validateAttribute($m, 'attr_files');
$this->assertFalse($m->hasErrors('attr_files'));
$this->assertTrue($m->hasErrors('attr_files'));
$m = FakedValidationModel::createWithAttributes(['attr_files' => []]);
$val->validateAttribute($m, 'attr_files');
$this->assertFalse($m->hasErrors('attr_files'));
$this->assertTrue($m->hasErrors('attr_files'));
$this->assertSame($val->uploadRequired, current($m->getErrors('attr_files')));

$m = FakedValidationModel::createWithAttributes(
[
Expand Down Expand Up @@ -334,7 +335,7 @@ public function testValidateArrayAttributeWithMinMaxOneAndOneFile()
'type' => 'image/png',
],
]
)[0];
)[0]; // <-- only one file
$model = FakedValidationModel::createWithAttributes(['attr_images' => [$files]]);

$validator->validateAttribute($model, 'attr_images');
Expand Down Expand Up @@ -422,15 +423,17 @@ public function testValidateAttribute()
$val->validateAttribute($m, 'attr_files');
$this->assertFalse($m->hasErrors());
$val->validateAttribute($m, 'attr_files_empty');
$this->assertFalse($m->hasErrors('attr_files_empty'));
$this->assertTrue($m->hasErrors('attr_files_empty'));
$this->assertSame($val->uploadRequired, current($m->getErrors('attr_files_empty')));

// single File with skipOnEmpty = false
$val = new FileValidator(['skipOnEmpty' => false]);
$m = $this->createModelForAttributeTest();
$val->validateAttribute($m, 'attr_files');
$this->assertFalse($m->hasErrors());
$val->validateAttribute($m, 'attr_files_empty');
$this->assertFalse($m->hasErrors('attr_files_empty'));
$this->assertTrue($m->hasErrors('attr_files_empty'));
$this->assertSame($val->uploadRequired, current($m->getErrors('attr_files_empty')));
$m = $this->createModelForAttributeTest();

// too big
Expand Down Expand Up @@ -689,7 +692,8 @@ public function testValidateMimeTypeCaseInsensitive($mask, $fileMimeType, $expec
$this->assertEquals($expected, $validator->validate($file), sprintf('Mime type validate fail: "%s" / "%s"', $mask, $fileMimeType));
}

public function mimeTypeCaseInsensitive() {
public function mimeTypeCaseInsensitive()
{
return [
['Image/*', 'image/jp2', true],
['image/*', 'Image/jp2', true],
Expand Down

0 comments on commit 05a8fbe

Please sign in to comment.