Fix infinite recursion when checking for the new topic tool on empty pages

Bug: T312689
Change-Id: Iaf5033a55e3840ef65be0c4994f8b6c00fe2551b
This commit is contained in:
Ed Sanders 2022-07-09 12:48:17 +01:00
parent ddaf0d1084
commit f739160fb4

View file

@ -230,7 +230,13 @@ class HookUtils {
*/
public static function isFeatureEnabledForOutput( OutputPage $output, ?string $feature = null ): bool {
// Only show on normal page views (not history etc.), and in edit mode for previews
if ( !in_array( $output->getActionName(), [ 'view', 'edit', 'submit' ] ) ) {
if (
// Don't try to call $output->getActionName if testing for NEWTOPICTOOL as we use
// the hook onGetActionName to override the action for the tool on empty pages.
// If we tried to call it here it would set up infinite recursion (T312689)
$feature !== static::NEWTOPICTOOL &&
!in_array( $output->getActionName(), [ 'view', 'edit', 'submit' ] )
) {
return false;
}