#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.
Related issues 2
History 6
-
Garvin Hicking commented and changed category status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-04-23T10:36:07+00:00" > 04/23/25, 10:36 </span> -
Georg Ringer commented <span data-processor="relativetime" data-value="2025-04-23T13:44:04+00:00" > 04/23/25, 13:44 </span>
however,
findByUidcan be also switched tofindByIdentifier^^ -
Christian Hackl commented <span data-processor="relativetime" data-value="2025-04-23T14:53:12+00:00" > 04/23/25, 14:53 </span>
oh ok, I wasn’t aware that this method wasn’t one of the “magic” methods, I thought all findBy* were “magic” methods, I didn’t look properly – then please excuse my mistake.
However, yes, it would certainly be nice to have a corresponding note in the changelog :) -
Georg Ringer commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2025-04-23T18:54:33+00:00" > 04/23/25, 18:54 </span>closing in favor of #106603
-
Georg Ringer changed Related to #106603 <span data-processor="relativetime" data-value="2025-04-23T18:54:54+00:00" > 04/23/25, 18:54 </span>
-
Benni Mack changed Related to #100071 <span data-processor="relativetime" data-value="2025-04-24T08:38:43+00:00" > 04/24/25, 08:38 </span>
Thanks for the report. I believe this to be “just” a missing documentation specificity.
In fact, “findByUid” is NOT a magic method. It is specifically implemented, and thus was NOT deprecated. The changelog does not explicitly mention that, because only real “magic” methods are addressed.
So you could continue to use
findByUidif that implementation detail is important. Adding a change like you propose would possibly lead to breaking changes for others who may rely on the behavior you want (which can be achieved byfindByUid(findByIdentifieractually ;)).So I would suggest we patch the changelog and add a note like:
What do you think? Would you maybe want to contribute a changelog core patch for this? :-)