Fixed Unexpected behavior from \XF::getClassForAlias

Xon

Well-known member
Licensed customer
Affected version
2.3.0
\XF::getClassForAlias will sometimes suggest incorrect replacements for some View handlers;

XF\Pub\View\Reaction\React => XF\Pub\View\Reaction\ReactHandler
XF\Pub\View\Attachment\View => XF\Pub\View\Attachment\ViewHandler
XF\Pub\View\Like\Like => XF\Pub\View\Like\LikeHandler
XF\Api\View\Attachment\View => XF\Api\View\Attachment\ViewHandler
XF\Admin\View\Attachment\View => XF\Admin\View\Attachment\ViewHandler
 
getClassForAlias also suggests bad aliases for these classes:

Code:
XF\ModeratorLog\Logger
XF\Poll\ResponseEditor
XF\Tag\RenderWrapper
XF\ChangeLog\DisplayEntry
XF\Attachment\Manipulator
XF\AdminSearch\TypeResultSet
XF\AdminSearch\Searcher
XF\ActivitySummary\Instance
XF\Sitemap\Entry
XF\Sitemap\BuildState
XF\Sitemap\Builder
XF\Sitemap\Renderer

These namespaces aren't renamed, so should not return aliases:
Code:
XF\Install
XF\Template\Compiler
XF\InlineMod
XF\Stats\Grouper

It probably should skip classes which start with Abstract or end with Trait/Interface

Aka when generating the class_alias list for https://xenforo.com/community/resources/xf2-2-xf2-3-rename-aliases.9498/ I made a script to call getClassForAlias on every XF2.2 file and then checked the resulting list to see if it pointed to a non-existent class.
 
We messed this up so currently reverted and not part of 2.3.11 fixes. Will give it some more thought today though.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.11).

Change log:
Only return a renamed class from getClassForAlias/getAliasForClass when the resolved class exists
There may be a delay before changes are rolled out to the XenForo Community.
 
No I didn't change my mind. At the time of writing the previous fix had been removed from 2.3.11 but I had committed to taking another look today, which I did, and that resulted in a new fix which, yes, will be in 2.3.11.
 
Sadly this bugfix caused a horrible regression;

I often use ThingRepository::get() which reliably causes class extensions to fail :(
 
Back
Top Bottom