Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2783

EntityManager::transactional empty values as true

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Git Master
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All

      Description

      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?

        Activity

        Hide
        Christophe Coevoet added a comment -

        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 ?

        Show
        Christophe Coevoet added a comment - 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 ?
        Hide
        Guilherme Blanco added a comment -

        Christophe Coevoet Benjamin Eberlei 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.

        Show
        Guilherme Blanco added a comment - Christophe Coevoet Benjamin Eberlei 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.
        Hide
        Marco Pivetta added a comment -

        Guilherme Blanco this was already refused before because of the BC break.

        Show
        Marco Pivetta added a comment - Guilherme Blanco this was already refused before because of the BC break.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Kirill chEbba Chebunin
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: