From 5018000e35aeb48ab95ef3271ffe48f5e44eeab4 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Tue, 19 Oct 2021 20:05:35 +0200 Subject: [PATCH] Change User::isAnon to !User::isRegistered in PageEditStash Also use another variable for the full user object to make clear which parts needs it and which part is fine with an UserIdentity Change-Id: I8422159a462cc54b54006a44e7b46079919691ad --- includes/Storage/PageEditStash.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/Storage/PageEditStash.php b/includes/Storage/PageEditStash.php index 237c984f8a6..23303218bbe 100644 --- a/includes/Storage/PageEditStash.php +++ b/includes/Storage/PageEditStash.php @@ -213,18 +213,18 @@ class PageEditStash { * * @param PageIdentity $page * @param Content $content - * @param UserIdentity $useridentity to get parser options from - * @return stdClass|bool Returns edit stash object or false on cache miss + * @param UserIdentity $user to get parser options from + * @return stdClass|false Returns edit stash object or false on cache miss */ - public function checkCache( PageIdentity $page, Content $content, UserIdentity $useridentity ) { - $user = $this->userFactory->newFromUserIdentity( $useridentity ); + public function checkCache( PageIdentity $page, Content $content, UserIdentity $user ) { + $legacyUser = $this->userFactory->newFromUserIdentity( $user ); if ( // The context is not an HTTP POST request - !$user->getRequest()->wasPosted() || + !$legacyUser->getRequest()->wasPosted() || // The context is a CLI script or a job runner HTTP POST request $this->initiator !== self::INITIATOR_USER || // The editor account is a known bot - $user->isBot() + $legacyUser->isBot() ) { // Avoid wasted queries and statsd pollution return false; @@ -259,7 +259,7 @@ class PageEditStash { // Assume nothing changed in this time $this->incrStatsByContent( 'cache_hits.presumed_fresh', $content ); $logger->debug( "Timestamp-based cache hit for key '{key}'.", $logContext ); - } elseif ( $user->isAnon() ) { + } elseif ( !$user->isRegistered() ) { $lastEdit = $this->lastEditTime( $user ); $cacheTime = $editInfo->output->getCacheTime(); if ( $lastEdit < $cacheTime ) {