#106600findBy([ 'uid' ... ]) uses constrain 'pid' > it's not a dropIn replacement for findByUid() according to ChangeLog #100071
Description
According to the changelog, the “magic” findBy methods are deprecated, which means, for example for a query:
@$this->myRepository->findByUid(55);@
you would now have to write:
@$this->myRepository->findOneBy([ ‘uid’ => 55 ]);@
However, the SQL query is not identical, as the new “findBy” / “findOneBy” methods take the “pid” into account and set it to “0” by default, i.e. the pid is also queried in the “constraint”. the old “findByUid” method has no “pid” query.
In my current case, it was enough to set respectStoragePage to “false” in my repository:
$querySettings->setRespectStoragePage(FALSE);
However, I don’t think this is the solution in every case, perhaps it would be possible to do exception handling for “uid”, e.g.
@if(isset($criteria[‘uid’])) {
$query->getQuerySettings()->setRespectStoragePage(false);
}@
or maybe you could add a flag to the methods?
In any case, this is not a dropIn replacement, so i think it should at least be mentioned / changed in the documentation:
https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Deprecation-100071-MagicRepositoryFindByMethods.html
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.