Fixed Page criteria targeting a specific action is unreliable

Affected version
2.1.0+

Xon

Well-known member
Notices targeting particular page criteria via "Controller and action" with an action are unreliable, and the description text is now outright wrong.

Example: AddOn\Path\To\ClassName :: methodName
Specify action name as personal-details, not actionPersonalDetails or personalDetails. You may leave the action blank to apply to all actions within the specified controller.
During the XF2.1 update, the following was added to XF\Mv\Dispatcher::dispatchClass

PHP:
if ($action instanceof \Closure)
{
    $action = $action($controller, $responseType, $params);
}
else
{
    $action = preg_replace('#[^a-z0-9]#i', ' ', $action);
    $action = str_replace(' ', '', ucwords($action));
}
An $action of personal-details is normalized to PersonalDetails, which means personal-details doesn't match.

The normalization should be apply after an $action closure is called, and it would make sense to simplify it to all lower-case during normalization as php function names are not case sensitive and it saves lower-casing it in a loop and/or whenever the action needs to be compared.

For notices, the action condition should go through the same normalization to ensure reliable action matching.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
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.1.10).

Change log:
Properly normalize page action criteria
There may be a delay before changes are rolled out to the XenForo Community.
 
Top