Skip to content

Commit 05a8fbe

Browse files
committed
Merge branch 'master' into fix_behaviors_attachment
# Conflicts: # framework/base/Component.php # tests/framework/base/ComponentTest.php
2 parents 4b75427 + 34d2396 commit 05a8fbe

File tree

6 files changed

+45
-22
lines changed

6 files changed

+45
-22
lines changed

.github/workflows/ci-mssql.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ concurrency:
1010

1111
jobs:
1212
tests:
13-
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql }}
13+
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql.version }}
1414

1515
env:
1616
EXTENSIONS: pdo, pdo_sqlsrv
@@ -21,37 +21,45 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24+
php:
25+
- 7.4
26+
- 8.0
27+
- 8.1
28+
- 8.2
29+
- 8.3
30+
- 8.4
31+
32+
mssql:
33+
- version: server:2022-latest
34+
mssql-tool: /opt/mssql-tools18/bin/sqlcmd -C
35+
2436
include:
2537
- php: 7.4
26-
mssql: server:2017-latest
38+
mssql:
39+
version: server:2017-latest
40+
mssql-tool: /opt/mssql-tools/bin/sqlcmd
2741
- php: 8.0
28-
mssql: server:2019-latest
29-
- php: 8.1
30-
mssql: server:2019-latest
31-
- php: 8.2
32-
mssql: server:2022-latest
33-
- php: 8.3
34-
mssql: server:2022-latest
35-
- php: 8.4
36-
mssql: server:2022-latest
42+
mssql:
43+
version: server:2019-latest
44+
mssql-tool: /opt/mssql-tools18/bin/sqlcmd -C
3745

3846
services:
3947
mssql:
40-
image: mcr.microsoft.com/mssql/${{ matrix.mssql }}
48+
image: mcr.microsoft.com/mssql/${{ matrix.mssql.version }}
4149
env:
4250
SA_PASSWORD: YourStrong!Passw0rd
4351
ACCEPT_EULA: Y
4452
MSSQL_PID: Developer
4553
ports:
4654
- 1433:1433
47-
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
55+
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
4856

4957
steps:
5058
- name: Checkout
5159
uses: actions/checkout@v4
5260

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

5664
- name: Install PHP with extensions
5765
uses: shivammathur/setup-php@v2

docs/guide-ja/db-active-record.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,16 @@ Customer::deleteAll(['status' => Customer::STATUS_INACTIVE]);
650650
> - [[yii\db\ActiveRecord::updateCounters()]]
651651
> - [[yii\db\ActiveRecord::updateAllCounters()]]
652652
653+
> Note: パフォーマンスを考慮して、DI(依存注入) はデフォルトではサポートされていません。必要であれば、
654+
> [[Yii::createObject()]] によってクラスのインスタンス生成をするように [[yii\db\ActiveRecord::instantiate()|instantiate()]] メソッドをオーバーライドして、サポートを追加することが出来ます。
655+
>
656+
> ```php
657+
> public static function instantiate($row)
658+
> {
659+
> return Yii::createObject(static::class);
660+
> }
661+
> ```
662+
653663
### データをリフレッシュする際のライフサイクル <span id="refreshing-data-life-cycle"></span>
654664
655665
[[yii\db\ActiveRecord::refresh()|refresh()]] を呼んでアクティブ・レコード・インスタンスをリフレッシュする際は、リフレッシュが成功してメソッドが `true` を返すと

docs/guide-ru/db-active-record.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ $customer->loadDefaultValues();
537537
Можно также использовать условия для столбцов JSON:
538538

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

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Yii Framework 2 Change Log
55
------------------------
66

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

910
2.0.51 July 18, 2024
1011
--------------------

framework/validators/FileValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function validateAttribute($model, $attribute)
209209
{
210210
$files = $this->filterFiles(is_array($model->$attribute) ? $model->$attribute : [$model->$attribute]);
211211
$filesCount = count($files);
212-
if ($filesCount === 0 && $this->minFiles > 0) {
212+
if ($filesCount === 0) {
213213
$this->addError($model, $attribute, $this->uploadRequired);
214214

215215
return;

tests/framework/validators/FileValidatorTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ public function testValidateAttributeMultiple()
115115
]);
116116
$m = FakedValidationModel::createWithAttributes(['attr_files' => 'path']);
117117
$val->validateAttribute($m, 'attr_files');
118-
$this->assertFalse($m->hasErrors('attr_files'));
118+
$this->assertTrue($m->hasErrors('attr_files'));
119119
$m = FakedValidationModel::createWithAttributes(['attr_files' => []]);
120120
$val->validateAttribute($m, 'attr_files');
121-
$this->assertFalse($m->hasErrors('attr_files'));
121+
$this->assertTrue($m->hasErrors('attr_files'));
122+
$this->assertSame($val->uploadRequired, current($m->getErrors('attr_files')));
122123

123124
$m = FakedValidationModel::createWithAttributes(
124125
[
@@ -334,7 +335,7 @@ public function testValidateArrayAttributeWithMinMaxOneAndOneFile()
334335
'type' => 'image/png',
335336
],
336337
]
337-
)[0];
338+
)[0]; // <-- only one file
338339
$model = FakedValidationModel::createWithAttributes(['attr_images' => [$files]]);
339340

340341
$validator->validateAttribute($model, 'attr_images');
@@ -422,15 +423,17 @@ public function testValidateAttribute()
422423
$val->validateAttribute($m, 'attr_files');
423424
$this->assertFalse($m->hasErrors());
424425
$val->validateAttribute($m, 'attr_files_empty');
425-
$this->assertFalse($m->hasErrors('attr_files_empty'));
426+
$this->assertTrue($m->hasErrors('attr_files_empty'));
427+
$this->assertSame($val->uploadRequired, current($m->getErrors('attr_files_empty')));
426428

427429
// single File with skipOnEmpty = false
428430
$val = new FileValidator(['skipOnEmpty' => false]);
429431
$m = $this->createModelForAttributeTest();
430432
$val->validateAttribute($m, 'attr_files');
431433
$this->assertFalse($m->hasErrors());
432434
$val->validateAttribute($m, 'attr_files_empty');
433-
$this->assertFalse($m->hasErrors('attr_files_empty'));
435+
$this->assertTrue($m->hasErrors('attr_files_empty'));
436+
$this->assertSame($val->uploadRequired, current($m->getErrors('attr_files_empty')));
434437
$m = $this->createModelForAttributeTest();
435438

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

692-
public function mimeTypeCaseInsensitive() {
695+
public function mimeTypeCaseInsensitive()
696+
{
693697
return [
694698
['Image/*', 'image/jp2', true],
695699
['image/*', 'Image/jp2', true],

0 commit comments

Comments
 (0)