diff options
author | Amir Sarabadani <ladsgroup@gmail.com> | 2021-12-14 08:41:29 +0100 |
---|---|---|
committer | Ladsgroup <Ladsgroup@gmail.com> | 2021-12-14 13:31:29 +0000 |
commit | f51f68b864d6ed463e5f66fc6e3fa4794b795399 (patch) | |
tree | b6aaf8d1164b682396f4b0c7e1584a7c79f6a1cb | |
parent | 57e2f9f3bb964e63c02e4062b0bcace6f087c3a6 (diff) |
Reuse the query result in addCategoryLinks instead of relying on cache
This is an implicit logic that it first loads everything as a batch and
then adds them to the LinkCache and then just hopes it works.
During passing arround of Title object, it reaches Title::getArticleID()
(in Title::exists()) and that now reads it from PageStore
(by using ::getFieldFromPageStore) and since the Page object doesn't
exist yet (we only populated the LinkCache), it loads the page again.
Bug: T297669
Change-Id: Icca81c97a15d90f593090711cdccdee3ea404ae2
(cherry picked from commit 70acd1dcd40d8fe573ac9074c133e003142eac81)
-rw-r--r-- | includes/OutputPage.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/includes/OutputPage.php b/includes/OutputPage.php index dbc888be1713..94e9dc1bed1a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1385,12 +1385,17 @@ class OutputPage extends ContextSource { # Set all the values to 'normal'. $categories = array_fill_keys( array_keys( $categories ), 'normal' ); + $pageData = []; # Mark hidden categories foreach ( $res as $row ) { if ( isset( $row->pp_value ) ) { $categories[$row->page_title] = 'hidden'; } + // Page exists, cache results + if ( isset( $row->page_id ) ) { + $pageData[$row->page_title] = $row; + } } # Add the remaining categories to the skin @@ -1405,7 +1410,11 @@ class OutputPage extends ContextSource { // array keys will cast numeric category names to ints, so cast back to string $category = (string)$category; $origcategory = $category; - $title = Title::makeTitleSafe( NS_CATEGORY, $category ); + if ( array_key_exists( $category, $pageData ) ) { + $title = Title::newFromRow( $pageData[$category] ); + } else { + $title = Title::makeTitleSafe( NS_CATEGORY, $category ); + } if ( !$title ) { continue; } |