[PR #1392] transactional() wrapper corrupts return values #9449

Open
opened 2026-01-22 16:04:21 +01:00 by admin · 0 comments
Owner

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

State: closed
Merged: No


The EntityManager::transactional() method has undocumented behavior, which unexpectedly rewrites all false-ish return values into true before passing them on:

$result = $this->_em->transactional(function (){
    return array();
}
assert(is_array($result)); // Fails

I think there's a very strong case to be made that this is undesirable, however it's been in existence for a few years now (since DDC-1125) and it's very likely at least a few users have code that relies on the undocumented behavior.

This PR represents the most direct fix, but as a practical matter we may want to improve the documentation instead. If that is the decision, I'd be happy to create a separate PR for documentation changes.

**Original Pull Request:** https://github.com/doctrine/orm/pull/1392 **State:** closed **Merged:** No --- The EntityManager::transactional() method has undocumented behavior, which unexpectedly rewrites all `false`-ish return values into `true` before passing them on: ``` $result = $this->_em->transactional(function (){ return array(); } assert(is_array($result)); // Fails ``` I think there's a very strong case to be made that this is undesirable, **however** it's been in existence for a few years now (since DDC-1125) and it's very likely at least a few users have code that _relies_ on the undocumented behavior. This PR represents the most direct fix, but as a practical matter we may want to improve the documentation instead. If that is the decision, I'd be happy to create a separate PR for documentation changes.
admin added the pull-request label 2026-01-22 16:04:21 +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#9449