yii2
yii2 copied to clipboard
BaseActiveRecord save method - php docs do not state possible throwing of exception
What steps will reproduce the problem?
- go to vendor/yiisoft/yii2/db/BaseActiveRecord.php
- check [at]throws attribute in php docs
- check insert() method php docs in ActiveRecord.php,
- check update() method php docs in BaseActiveRecord.php
What is the expected result?
- expected to contain [at]throws StaleObjectException, Exception or Throwable as update(), insert() methods could throw these
- in case save() should not throw an exception, catch needed for update(), insert() methods
What do you get instead?
- no [at]throws statement stated
- or missing catch statements in save()
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.49.4 |
| PHP version | |
| Operating system | Linux |
save() method - BaseActiveRecord
insert() method - ActiveRecord
update() method - BaseActiveRecord
Should be added to phpdoc, indeed. Do you have time for a pull request?
Should be added to phpdoc, indeed. Do you have time for a pull request?
hey! i have time for a pr. Btw what do you think about catching the exceptions inside of save(). as otherwise each user of save() needs to create a try catch, which bloats up that user's abstraction layer unnecessarily?
for phpdoc see https://github.com/yiisoft/yii2/pull/20146
about catching the exceptions inside of save(): I think this should/can not be done, as exceptions thrown within save() can be (or are) used to handle use cases like https://github.com/yiisoft/yii2/issues/8392 or https://github.com/yiisoft/yii2/issues/20253
ok, thank you.