XF\Mvc\Entity\Manager\getFinder does not reliably return the same type depending on class extensions

Xon

Well-known member
Affected version
2.2.13
XenForo's dynamically creates finders of a given base-type if they are extended or otherwise will return a \XF\Mvc\Entity\Finder instance.

The problem is when return and parameter arguments are narrower than the \XF\Mvc\Entity\Finder and will cause a type error violation.
  • XenForo does not define XF\Finder\Warning
  • Add-on A extended XF\Finder\Warning
  • Add-on B has a return type hint of XF\Finder\Warning
  • Add-on B is used without Add-on A, a type error will occur as the finder is no longer of the correct type.

The change to make getFinder to reliably return the expected types is fairly simple with just another class_alias call if the base finder doesn't exist. Note, there is another issue where the output of \XF::stringToClas() can be an Entity instead of a Finder

 
Back
Top Bottom