Skip to content

BaseActiveRecord save method behaviour #20111

Open
@zebraf1

Description

@zebraf1

When calling save() on a model object, it hints that it returns true or false whether save succeeded. It does not hint any exceptions are thrown, however it calls insert() or update() which can throw db\Exception or Throwable.
So when the database configuration is wrong or database is not responsing then an Exception is thrown from save() and causes an unexpected error.

Either:
a) the exceptions should be caught within save(), logged and returns false
b) PHP doc for save() needs to be updated with [at]throws statement, so IDE's can detect it needs exception handling

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions