yiisoft / yii2-mongodb

Yii 2 MongoDB extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
326 stars 191 forks source link

Generator trim validator causes exception in PHP8.3 #373

Closed Dorkdomain closed 3 months ago

Dorkdomain commented 3 months ago

What steps will reproduce the problem?

Using mongo-gii, try to Preview a MongoModel.

What's expected?

Correct execution

What do you get instead?

PHP Deprecated Warning 'yii\base\ErrorException' with message 'trim(): Passing null to parameter #1 ($string) of type string is deprecated'

in /vendor/yiisoft/yii2/validators/FilterValidator.php:81

PHP Deprecated Warning 'yii\base\ErrorException' with message 'strtolower(): Passing null to parameter #1 ($string) of type string is deprecated'

in /vendor/yiisoft/yii2-gii/src/Generator.php:499

Additional info

gii used to have the same error,url :https://github.com/yiisoft/yii2-gii/issues/505 But mongo-gii was forgotten to fix the bug

Q A
Yii version 2.0.49.3
Yii MongoDB version 3.0.1
MongoDB server version 5.0.6
PHP version 8.3.8
samdark commented 3 months ago

What do you have in your model validation rules? I'm interested in "filter".

Dorkdomain commented 3 months ago

您的模型验证规则中有什么?我对“过滤器”感兴趣。

[$this->attributes(), 'trim'],

That's the only rule. All the other rules are [safe]

Dorkdomain commented 3 months ago

Please referring to this link, https://github.com/yiisoft/yii2-gii/commit/c9efc088cd7003353125b2a2cc696d4b1028eafc ,I think they are the same bug。 I have tried to modify the local source code according to this code, and it is already running correctly。

samdark commented 3 months ago

Thanks for reporting. Do you have time for a pull request?

Dorkdomain commented 3 months ago

Thanks for reporting. Do you have time for a pull request?

I haven't done pull requests before, I tried my best and hope to help.