From 62ddb8bcebde51952bf4662bcf9e5c35365e12df Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Fri, 26 Aug 2022 12:07:15 +0200 Subject: [PATCH] Use cheaper getRawVal/getCheck instead of getVal where possible getVal/getText can be expensive because they do Unicode normalization. We can skip this when we know we aren't going to do anything meaningful with the value anyway. Change-Id: I9d939a44df6b67bcd8429096d89600ce1566ca39 --- includes/Hooks/HookUtils.php | 12 ++++++------ includes/Hooks/PageHooks.php | 2 +- includes/Notifications/EventDispatcher.php | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/Hooks/HookUtils.php b/includes/Hooks/HookUtils.php index 94c9ea16c..2bb796735 100644 --- a/includes/Hooks/HookUtils.php +++ b/includes/Hooks/HookUtils.php @@ -445,12 +445,12 @@ class HookUtils { return ( // ?title=...&action=edit§ion=new // ?title=...&veaction=editsource§ion=new - ( $req->getVal( 'action' ) === 'edit' || $req->getVal( 'veaction' ) === 'editsource' ) && - $req->getVal( 'section' ) === 'new' && + ( $req->getRawVal( 'action' ) === 'edit' || $req->getRawVal( 'veaction' ) === 'editsource' ) && + $req->getRawVal( 'section' ) === 'new' && // Adding a new topic with preloaded text is not supported yet (T269310) !( - $req->getVal( 'editintro' ) || $req->getVal( 'preload' ) || - $req->getVal( 'preloadparams' ) || $req->getVal( 'preloadtitle' ) + $req->getCheck( 'editintro' ) || $req->getCheck( 'preload' ) || + $req->getCheck( 'preloadparams' ) || $req->getCheck( 'preloadtitle' ) ) && // User has new topic tool enabled (and not using &dtenable=0) static::isFeatureEnabledForOutput( $out, static::NEWTOPICTOOL ) @@ -475,14 +475,14 @@ class HookUtils { ( // When following a red link from another page (but not when clicking the 'Edit' tab) ( - $req->getVal( 'action' ) === 'edit' && $req->getVal( 'redlink' ) === '1' && + $req->getRawVal( 'action' ) === 'edit' && $req->getRawVal( 'redlink' ) === '1' && // …if not disabled by the user $optionsLookup->getOption( $user, 'discussiontools-newtopictool-createpage' ) ) || // When the new topic tool will be opened (usually when clicking the 'Add topic' tab) static::shouldOpenNewTopicTool( $context ) || // In read mode (accessible for non-existent pages by clicking 'Cancel' in editor) - $req->getVal( 'action', 'view' ) === 'view' + $req->getRawVal( 'action', 'view' ) === 'view' ) && // Only in talk namespaces, not including other namespaces that isAvailableForTitle() allows $title->isTalkPage() && diff --git a/includes/Hooks/PageHooks.php b/includes/Hooks/PageHooks.php index e058f4581..c56e4459e 100644 --- a/includes/Hooks/PageHooks.php +++ b/includes/Hooks/PageHooks.php @@ -442,7 +442,7 @@ class PageHooks implements // Only show when following the link from the new topic tool, never on normal edit attempts. // This can be called from within ApiVisualEditor, so we can't access most request parameters // for the main request. However, we can access 'editintro', because it's passed to the API. - $context->getRequest()->getVal( 'editintro' ) === 'mw-dt-topic-hint' + $context->getRequest()->getRawVal( 'editintro' ) === 'mw-dt-topic-hint' ) { $context->getOutput()->enableOOUI(); diff --git a/includes/Notifications/EventDispatcher.php b/includes/Notifications/EventDispatcher.php index 1836d40a1..04e2ddbca 100644 --- a/includes/Notifications/EventDispatcher.php +++ b/includes/Notifications/EventDispatcher.php @@ -358,11 +358,11 @@ class EventDispatcher { // might either be after an API request from DiscussionTools or a // regular POST from WikiEditor. Both should have this value snuck // into their request if their session is being logged. - if ( !$request->getVal( 'editingStatsId' ) ) { + if ( !$request->getCheck( 'editingStatsId' ) ) { return false; } $editingStatsId = $request->getVal( 'editingStatsId' ); - $isDiscussionTools = (bool)$request->getVal( 'dttags' ); + $isDiscussionTools = $request->getCheck( 'dttags' ); $extensionRegistry = ExtensionRegistry::getInstance(); if ( !$extensionRegistry->isLoaded( 'EventLogging' ) ) {