mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-15 06:40:59 +08:00
Fix #18269: Fix integer safe attribute to work properly in yii\base\Model
This commit is contained in:

committed by
GitHub

parent
b680494d6b
commit
e348c0f460
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
|||||||
2.0.38 under development
|
2.0.38 under development
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
- Bug #18269: Fix integer safe attribute to work properly in `yii\base\Model` (Ladone)
|
||||||
- Enh #18236: Allow `yii\filters\RateLimiter` to accept a closure function for the `$user` property in order to assign values on runtime (nadar)
|
- Enh #18236: Allow `yii\filters\RateLimiter` to accept a closure function for the `$user` property in order to assign values on runtime (nadar)
|
||||||
- Bug #18233: Add PHP 8 support (samdark)
|
- Bug #18233: Add PHP 8 support (samdark)
|
||||||
- Bug #18239: Fix support of no-extension files for `FileValidator::validateExtension()` (darkdef)
|
- Bug #18239: Fix support of no-extension files for `FileValidator::validateExtension()` (darkdef)
|
||||||
|
@ -798,7 +798,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
|||||||
}
|
}
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach ($scenarios[$scenario] as $attribute) {
|
foreach ($scenarios[$scenario] as $attribute) {
|
||||||
if ($attribute[0] !== '!' && !in_array('!' . $attribute, $scenarios[$scenario])) {
|
if (strncmp($attribute, '!', 1) !== 0 && !in_array('!' . $attribute, $scenarios[$scenario])) {
|
||||||
$attributes[] = $attribute;
|
$attributes[] = $attribute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,18 @@ class ModelTest extends TestCase
|
|||||||
$this->assertTrue($speaker->isAttributeSafe('firstName'));
|
$this->assertTrue($speaker->isAttributeSafe('firstName'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsAttributeSafeForIntegerAttribute()
|
||||||
|
{
|
||||||
|
$model = new RulesModel();
|
||||||
|
$model->rules = [
|
||||||
|
[
|
||||||
|
[123456], 'safe',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->assertTrue($model->isAttributeSafe(123456));
|
||||||
|
}
|
||||||
|
|
||||||
public function testSafeScenarios()
|
public function testSafeScenarios()
|
||||||
{
|
{
|
||||||
$model = new RulesModel();
|
$model = new RulesModel();
|
||||||
|
Reference in New Issue
Block a user