From f739160fb4f863453291b3a74a7e171eda1c4d89 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Sat, 9 Jul 2022 12:48:17 +0100 Subject: [PATCH] Fix infinite recursion when checking for the new topic tool on empty pages Bug: T312689 Change-Id: Iaf5033a55e3840ef65be0c4994f8b6c00fe2551b --- includes/Hooks/HookUtils.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/Hooks/HookUtils.php b/includes/Hooks/HookUtils.php index 7cc2d9c1b..550374075 100644 --- a/includes/Hooks/HookUtils.php +++ b/includes/Hooks/HookUtils.php @@ -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; }