Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initializing lazy objects and get rid of "Typed property must not be accessed before initialization" errors #10385

Merged

Conversation

nicolas-grekas
Copy link
Member

Fix #10336

@simonberger
Copy link
Contributor

Where is the point in taking my fix and implement it in just a different coding style?
#10362

@nicolas-grekas
Copy link
Member Author

No specific point, I just missed your PR sorry, thanks for point at it.
Now that I compared both, I find the code style easier to follow in this very PR. WDYT?

@pableu
Copy link

pableu commented Jan 11, 2023

@simonberger closed #10362, so let's get this one merged :-)

@bendavies
Copy link

LGTM, fixes my similar issue. thanks NG.

Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good because there are more tests, but don't ask me to explain this change 😅 If somebody can help me figure it out, I might feel confident enough to merge.

if (isset($this->_hints[Query::HINT_REFRESH_ENTITY])) {
$this->registerManaged($this->class, $this->_hints[Query::HINT_REFRESH_ENTITY], $data);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines were removed in #10187 as pointed out in #10336 (comment)


$skippedProperties[$prefix . $name] = true;
$filter = ReflectionProperty::IS_PRIVATE;
$reflector = $reflector->getParentClass();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to do the same as before, but for does it also for ancestors in the class hierarchy, retrieving only private properties for those (I guess public and protected are already retrieved at the first iteration because they are inherited).

$this->_em->clear();

$this->assertSame('foo', $entity->relation->value);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this test 100% covers this change, the while loop only ever does one iteration. Yet when I use git restore --source=origin/2.14.x lib/Doctrine/ORM/Proxy/ProxyFactory.php, a preexisting test fails Doctrine\Tests\ORM\Functional\MappedSuperclassTest::testCRUD, which means the scenario where there is more than 1 iteration is already covered 👍

It gets broken by the changes in SimpleObjectHydrator, and fixed by the changes in ProxyFactory

@greg0ire greg0ire requested review from derrabus, ostrolucky and SenseException and removed request for ostrolucky January 16, 2023 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants