- Affected version
- 2.2.13
XenForo's dynamically creates finders of a given base-type if they are extended or otherwise will return a
The problem is when return and parameter arguments are narrower than the
The change to make
\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
The
This will then give a misleading missing function message quite some distance from the root-cause.
Reproducer:
XF\Mvc\Entity\Manager::getFinder
function is type hinted to return a finder, but if an add-on does not implement the entity name as a short-string, this will fail and instead return the entity.This will then give a misleading missing function message quite some distance from the root-cause.
Reproducer:
PHP:
namespace MyAddon\Entity;
class MyEntity extends \XF\Mvc\Entity\Entity
{
public static function getStructure(Structure $structure): Structure
{
$structure->table = 'xf_my_table';
$structure->shortName = 'MyAddon:MyEntity'...
- Xon
- Replies: 0
- Forum: Bug reports