Skip to content

Commit 8737b4b

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.5
Conflicts: system/Autoloader/Autoloader.php
2 parents e371c09 + a87fd14 commit 8737b4b

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"phpunit/phpcov": "^8.2",
3333
"phpunit/phpunit": "^9.1",
3434
"predis/predis": "^1.1 || ^2.0",
35-
"rector/rector": "1.0.2",
35+
"rector/rector": "1.0.3",
3636
"vimeo/psalm": "^5.0"
3737
},
3838
"replace": {

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
3131
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
3232
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
33+
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
3334
use Rector\Config\RectorConfig;
3435
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
3536
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
@@ -189,6 +190,7 @@
189190
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
190191
$rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class);
191192
$rectorConfig->rule(SingleInArrayToCompareRector::class);
193+
$rectorConfig->rule(VersionCompareFuncCallToConstantRector::class);
192194

193195
$rectorConfig
194196
->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [

system/BaseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ protected function shouldUpdate($row): bool
765765
{
766766
$id = $this->getIdValue($row);
767767

768-
return ! ($id === null || $id === []);
768+
return ! ($id === null || $id === [] || $id === '');
769769
}
770770

771771
/**

tests/system/Models/SaveModelTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ public function testSaveNewRecordObject(): void
4444
$this->seeInDatabase('job', ['name' => 'Magician']);
4545
}
4646

47+
/**
48+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/8613
49+
*/
50+
public function testSaveNewRecordArrayWithEmptyStringId(): void
51+
{
52+
$this->createModel(JobModel::class);
53+
54+
$data = [
55+
'id' => '',
56+
'name' => 'Magician',
57+
'description' => 'Makes peoples things dissappear.',
58+
];
59+
60+
$this->model->save($data);
61+
62+
$this->seeInDatabase('job', ['name' => 'Magician']);
63+
}
64+
4765
public function testSaveNewRecordArray(): void
4866
{
4967
$this->createModel(JobModel::class);

0 commit comments

Comments
 (0)