[PR #9526] Make creating test models more straightforward and revert to swallowing exceptions #11681

Closed
opened 2026-01-22 16:11:34 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/9526

State: closed
Merged: Yes


In https://github.com/doctrine/orm/pull/8962, I established that
swallowing exceptions while creating model was bad because it could hide
other helpful exceptions.
As it turns out however, swallowing exceptions is really the way to go
here, because of the performance implication of calling dropSchema(). It
is possible to catch a more precise exception as well, which should
preserve the benefits of not swallowing them.

It looks like I based my grep on the comment inside the catch and today,
I found many other occurrences of this pattern, without the easy to grep
comment.

I decided to fix them as well, but in a lazier way: one no longer has to
remember to call dropSchema in tearDown() now, it is automated.

Here is the grep I used this time: rg --multiline '\} catch \(Exception \$e\) \{\n\s+\}'

TODO

  • fix other 25 occurrences
  • grep for dropSchema and improve tests changed in #8962 as well.
**Original Pull Request:** https://github.com/doctrine/orm/pull/9526 **State:** closed **Merged:** Yes --- In https://github.com/doctrine/orm/pull/8962, I established that swallowing exceptions while creating model was bad because it could hide other helpful exceptions. As it turns out however, swallowing exceptions is really the way to go here, because of the performance implication of calling dropSchema(). It is possible to catch a more precise exception as well, which should preserve the benefits of not swallowing them. It looks like I based my grep on the comment inside the catch and today, I found many other occurrences of this pattern, without the easy to grep comment. I decided to fix them as well, but in a lazier way: one no longer has to remember to call dropSchema in tearDown() now, it is automated. Here is the `grep` I used this time: `rg --multiline '\} catch \(Exception \$e\) \{\n\s+\}'` ## TODO - [x] fix other 25 occurrences - [x] `grep` for `dropSchema` and improve tests changed in #8962 as well.
admin added the pull-request label 2026-01-22 16:11:34 +01:00
admin closed this issue 2026-01-22 16:11:34 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#11681