Skip to content

Loading…

DCOM-104: Dump() has side-effects or is unreliable #401

Closed
doctrinebot opened this Issue · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user tom:

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.

@doctrinebot

Comment created by tom:

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.

@doctrinebot

Comment created by tom:

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

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

i.e. the update of the inverse side.

@doctrinebot

Comment created by stof:

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

@doctrinebot

Comment created by tom:

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

@doctrinebot

Comment created by @guilhermeblanco:

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.

@doctrinebot

Issue was closed with resolution "Won't Fix"

@doctrinebot doctrinebot added the Bug label
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.