Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Throw when loading a proxy without identifiers#10818

Closed
MatTheCat wants to merge 2 commits into
doctrine:2.15.xfrom
MatTheCat:proxy-without-identifier
Closed

Throw when loading a proxy without identifiers#10818
MatTheCat wants to merge 2 commits into
doctrine:2.15.xfrom
MatTheCat:proxy-without-identifier

Conversation

@MatTheCat
Copy link
Copy Markdown
Contributor

@MatTheCat MatTheCat commented Jul 6, 2023

Related to symfony/symfony#50874

Loading a proxy without identifiers currently leads to its hydration using its table’s first row; it is better to throw in that case.
Not sure if it should be done in EntityPersister:loadById though 🤔

@nicolas-grekas
Copy link
Copy Markdown
Member

This is not supposed to happen so this should not be needed.
The root issue is fixed in #10819

@MatTheCat MatTheCat force-pushed the proxy-without-identifier branch from 0c255d4 to b2abc0b Compare July 9, 2023 15:49
@MatTheCat
Copy link
Copy Markdown
Contributor Author

Well it happened 😅
Luckily the bug was found, but an exception would have been more appropriate.

Comment thread tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php Outdated
@greg0ire
Copy link
Copy Markdown
Member

greg0ire commented Nov 7, 2023

Might be interesting to see if there are other places in the code where an empty array will cause hard to troubleshoot issues and if yes, introducing an alternate method that throws instead of returning an empty array. Also, finding out what method should not be called with an empty array and annotate them with non-empty-array instead of just array. For instance, does it make sense to call EntityPersister::loadById() with an empty array?

Co-authored-by: Grégoire Paris <[email protected]>
@MatTheCat
Copy link
Copy Markdown
Contributor Author

Indeed. I guess such a work would supersede this PR?

@greg0ire
Copy link
Copy Markdown
Member

greg0ire commented Nov 8, 2023

The first part would, I suppose.

@MatTheCat
Copy link
Copy Markdown
Contributor Author

Closing as itʼs not really an issue.

@MatTheCat MatTheCat closed this Feb 2, 2024
@MatTheCat MatTheCat deleted the proxy-without-identifier branch February 2, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants