DDC-3712: [GH-1392] transactional() wrapper corrupts return values #4556

Closed
opened 2026-01-22 14:44:42 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 23, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of DHager:

Url: https://github.com/doctrine/doctrine2/pull/1392

Message:

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.

Originally created by @doctrinebot on GitHub (Apr 23, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of DHager: Url: https://github.com/doctrine/doctrine2/pull/1392 Message: 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](http://www.doctrine-project.org/jira/browse/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 Bug label 2026-01-22 14:44:42 +01:00
admin closed this issue 2026-01-22 14:44:42 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 15, 2015):

Comment created by @ocramius:

This issue cannot be fixed in 2.x, and requires a change/rewrite for 3.0 instead.

@doctrinebot commented on GitHub (Jul 15, 2015): Comment created by @ocramius: This issue cannot be fixed in 2.x, and requires a change/rewrite for 3.0 instead.
Author
Owner

@doctrinebot commented on GitHub (Jul 15, 2015):

Issue was closed with resolution "Can't Fix"

@doctrinebot commented on GitHub (Jul 15, 2015): Issue was closed with resolution "Can't Fix"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4556