Doctrine Common
  1. Doctrine Common
  2. DCOM-104

Dump() has side-effects or is unreliable

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Debian Squeeze, MySQL 5

      Description

      after setting a one-to-one bi-directional relationship, I am hunting a bug and trying this:

      \Doctrine\Common\Util\Debug::Dump($this->lord, 1);
      \Doctrine\Common\Util\Debug::Dump($this, 2);
      \Doctrine\Common\Util\Debug::Dump($this->lord, 1);

      The first Dump() shows $this->lord as being NULL.
      The third Dump() shows it as NOT being null, just like the 2nd one also shows it as having a value.

        Activity

        Hide
        Tom Vogt added a comment -

        More analysis found the issue being caused by an overloaded setLord() method:

        public function setLord($NewLord) {
        // overwriting the setter because we also want to update the lord days counter
        if ($NewLord!=$this->lord)

        { $this->lord->setFief(null); // this is the line causing the issue if ($NewLord) $NewLord->setFief($this); $this->lord = $NewLord; $this->lordDays = 0; }

        return $this;
        }

        without the marked line, everything works as expected, but of course the inverse side doesn't get updated without it.

        Show
        Tom Vogt added a comment - More analysis found the issue being caused by an overloaded setLord() method: public function setLord($NewLord) { // overwriting the setter because we also want to update the lord days counter if ($NewLord!=$this->lord) { $this->lord->setFief(null); // this is the line causing the issue if ($NewLord) $NewLord->setFief($this); $this->lord = $NewLord; $this->lordDays = 0; } return $this; } without the marked line, everything works as expected, but of course the inverse side doesn't get updated without it.
        Hide
        Tom Vogt added a comment -

        it ate the newlines in the comment above. The problematic line is:

        $this->lord->setFief(null);

        i.e. the update of the inverse side.

        Show
        Tom Vogt added a comment - it ate the newlines in the comment above. The problematic line is: $this->lord->setFief(null); i.e. the update of the inverse side.
        Hide
        Christophe Coevoet added a comment -

        I confirm that the dump command has some side effects. It initializes the persistent collections too

        Show
        Christophe Coevoet added a comment - I confirm that the dump command has some side effects. It initializes the persistent collections too
        Hide
        Tom Vogt added a comment -

        Could this for the time being be fixed with a notice in the documentation warning of possible side-effects of Dump() ?

        Show
        Tom Vogt added a comment - Could this for the time being be fixed with a notice in the documentation warning of possible side-effects of Dump() ?
        Hide
        Guilherme Blanco added a comment -

        Debug is a utility that does expose the Proxy information as part of its rendering, thus providing your suggested documentation addiction right out of the bat.

        Closing as won't fix.

        Show
        Guilherme Blanco added a comment - Debug is a utility that does expose the Proxy information as part of its rendering, thus providing your suggested documentation addiction right out of the bat. Closing as won't fix.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Tom Vogt
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: