aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Category/CategoryViewer.php
diff options
context:
space:
mode:
authorAmir Sarabadani <ladsgroup@gmail.com>2025-02-07 18:27:49 +0100
committerAmir Sarabadani <ladsgroup@gmail.com>2025-02-07 18:27:49 +0100
commitbf22a7ba449cff86a50785b351d90c47596012b7 (patch)
treee612a5bcad3e19875e5b3f51bd45c133818e91d3 /includes/Category/CategoryViewer.php
parent1d8b433ceb4ffd35c7ecd0e1de2035a238b700ed (diff)
downloadmediawikicore-bf22a7ba449cff86a50785b351d90c47596012b7.tar.gz
mediawikicore-bf22a7ba449cff86a50785b351d90c47596012b7.zip
Category: Add support for read new
In Category and CategoryViewer Bug: T385890 Change-Id: I498765bbb6dd1c942f28694e567189429637bfc1
Diffstat (limited to 'includes/Category/CategoryViewer.php')
-rw-r--r--includes/Category/CategoryViewer.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/includes/Category/CategoryViewer.php b/includes/Category/CategoryViewer.php
index fbe49650869c..27c3446387f4 100644
--- a/includes/Category/CategoryViewer.php
+++ b/includes/Category/CategoryViewer.php
@@ -104,6 +104,8 @@ class CategoryViewer extends ContextSource {
/** @var ILanguageConverter */
private $languageConverter;
+ private int $migrationStage;
+
/**
* @since 1.19 $context is a second, required parameter
* @param PageIdentity $page
@@ -136,6 +138,7 @@ class CategoryViewer extends ContextSource {
$this->from = $from;
$this->until = $until;
$this->limit = $context->getConfig()->get( MainConfigNames::CategoryPagingLimit );
+ $this->migrationStage = $context->getConfig()->get( MainConfigNames::CategoryLinksSchemaMigrationStage );
$this->cat = Category::newFromTitle( $page );
$this->query = $query;
$this->collation = MediaWikiServices::getInstance()->getCollationFactory()->getCategoryCollation();
@@ -413,13 +416,10 @@ class CategoryViewer extends ContextSource {
'cat_pages',
'cat_files',
'cl_sortkey_prefix',
- 'cl_collation'
]
) )
->from( 'page' )
- ->where( [ 'cl_to' => $this->page->getDBkey() ] )
- ->andWhere( $extraConds )
- ->useIndex( [ 'categorylinks' => 'cl_sortkey' ] );
+ ->andWhere( $extraConds );
if ( $this->flip[$type] ) {
$queryBuilder->orderBy( 'cl_sortkey', SelectQueryBuilder::SORT_DESC );
@@ -433,10 +433,22 @@ class CategoryViewer extends ContextSource {
'cat_title = page_title',
'page_namespace' => NS_CATEGORY
] )
- ->limit( $this->limit + 1 )
- ->caller( __METHOD__ );
+ ->limit( $this->limit + 1 );
+ if ( $this->migrationStage & SCHEMA_COMPAT_READ_OLD ) {
+ $queryBuilder->where( [ 'cl_to' => $this->page->getDBkey() ] )
+ ->field( 'cl_collation' )
+ ->useIndex( [ 'categorylinks' => 'cl_sortkey' ] );
+ } else {
+ $queryBuilder->join( 'linktarget', null, 'cl_target_id = lt_id' )
+ ->where( [ 'lt_title' => $this->page->getDBkey(), 'lt_namespace' => NS_CATEGORY ] );
+
+ $queryBuilder->join( 'collation', null, 'cl_collation_id = collation_id' )
+ ->field( 'collation_name', 'cl_collation' );
+
+ $queryBuilder->useIndex( [ 'categorylinks' => 'cl_sortkey_id' ] );
+ }
- $res = $queryBuilder->fetchResultSet();
+ $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
$this->getHookRunner()->onCategoryViewer__doCategoryQuery( $type, $res );
$linkCache = MediaWikiServices::getInstance()->getLinkCache();