DDC-2783: EntityManager#transactional() support for non-truthy values #3480

Closed
opened 2026-01-22 14:20:40 +01:00 by admin · 8 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 7, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user chebba:

The problem:
Any response from transactional callback which is evaluated to *false* (empty array, empty string, 0, null, etc) becomes true

$return = call*user*func($func, $this);

$this->flush();
$this->conn->commit();

return $return ?: true;

There is the old resolved issue DDC-1336, which describes this behavior.
@return tag is clear now.

@return mixed Returns the non-empty value returned from the closure or true instead

But this logic is blowing mind and leading to unexpectable results. The expected behavior is just return callback result, i don't see any good use cases for current implementation.

It requires a BC break. Can the deprecation process be started to change this behaviour in few major releases?

Originally created by @doctrinebot on GitHub (Nov 7, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user chebba: The problem: Any response from transactional callback which is evaluated to **false\* (empty array, empty string, 0, null, etc) becomes *true** ``` $return = call*user*func($func, $this); $this->flush(); $this->conn->commit(); return $return ?: true; ``` There is the old resolved issue [DDC-1336](http://www.doctrine-project.org/jira/browse/DDC-1336), which describes this behavior. `@return` tag is clear now. ``` @return mixed Returns the non-empty value returned from the closure or true instead ``` But this logic is blowing mind and leading to unexpectable results. The expected behavior is just return callback result, i don't see any good use cases for current implementation. It requires a BC break. Can the deprecation process be started to change this behaviour in few major releases?
admin added the ImprovementBC Break labels 2026-01-22 14:20:40 +01:00
admin closed this issue 2026-01-22 14:20:40 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 7, 2013):

Comment created by stof:

I agree that this makes the method hard to use. And I don't undertstand why it would replace the return value.

What was the intention for this Benjamin ?

@doctrinebot commented on GitHub (Nov 7, 2013): Comment created by stof: I agree that this makes the method hard to use. And I don't undertstand why it would replace the return value. What was the intention for this Benjamin ?
Author
Owner

@doctrinebot commented on GitHub (Apr 18, 2014):

Comment created by @guilhermeblanco:

[stof] [beberlei] I'm considering to remove the ternary and always return the callback result.
What do you think? It seems like a minor BC break, but would like to get more feedback around this.

@doctrinebot commented on GitHub (Apr 18, 2014): Comment created by @guilhermeblanco: [<sub>stof] [</sub>beberlei] I'm considering to remove the ternary and always return the callback result. What do you think? It seems like a minor BC break, but would like to get more feedback around this.
Author
Owner

@doctrinebot commented on GitHub (Apr 18, 2014):

Comment created by @ocramius:

[~guilhermeblanco] this was already refused before because of the BC break.

@doctrinebot commented on GitHub (Apr 18, 2014): Comment created by @ocramius: [~guilhermeblanco] this was already refused before because of the BC break.
Author
Owner

@fracz commented on GitHub (Nov 28, 2016):

Is there any chance to change this strange behavior?

@fracz commented on GitHub (Nov 28, 2016): Is there any chance to change this strange behavior?
Author
Owner

@Majkl578 commented on GitHub (Nov 28, 2016):

@fracz Yes, it's aready been done for 3.0 in #6147.
Ping @Ocramius, this could be marked as BC break & done & 3.0 milestone, I guess?

@Majkl578 commented on GitHub (Nov 28, 2016): @fracz Yes, it's aready been done for 3.0 in #6147. Ping @Ocramius, this could be marked as BC break & done & 3.0 milestone, I guess?
Author
Owner

@lcobucci commented on GitHub (Nov 28, 2016):

@fracz did you see #6147?

@lcobucci commented on GitHub (Nov 28, 2016): @fracz did you see #6147?
Author
Owner

@fracz commented on GitHub (Nov 28, 2016):

I have not. Thank you for rapid response!

@fracz commented on GitHub (Nov 28, 2016): I have not. Thank you for rapid response!
Author
Owner

@Ocramius commented on GitHub (Nov 29, 2016):

Closing as per #6147 👍

@Ocramius commented on GitHub (Nov 29, 2016): Closing as per #6147 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3480