diff options
author | Derick Alangi <alangiderick@gmail.com> | 2024-01-10 13:31:38 +0300 |
---|---|---|
committer | D3r1ck01 <dalangi-ctr@wikimedia.org> | 2024-01-23 14:07:07 +0000 |
commit | 4e468b49e06c9d1e251cedc0fee3959f869e8978 (patch) | |
tree | 3124817c77322336f5010e4a5082fbc15848097c /includes/Category | |
parent | 37dcd4adf827327f5ab15a0ea793fb6f2e171b8f (diff) | |
download | mediawikicore-4e468b49e06c9d1e251cedc0fee3959f869e8978.tar.gz mediawikicore-4e468b49e06c9d1e251cedc0fee3959f869e8978.zip |
title: Make TitleArrayFromResult via TitleFactory service
The TitleFactory should really be where TitleArrayFromResult should
live as it's a place where Title objects are created based on certain
specifications.
This patch tries to consolidate the creation of TitleArrayFromResult
via the TitleFactory services and in the future, we will consolidate
more of the logic and kill TitleArrayFromResult.
Follow up on: a99ec1b and e54665d.
Change-Id: I98215af3252d756de4435b77d1280dacda8e85dc
Diffstat (limited to 'includes/Category')
-rw-r--r-- | includes/Category/Category.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/includes/Category/Category.php b/includes/Category/Category.php index b9eb4cd082ea..7b70e7a967b3 100644 --- a/includes/Category/Category.php +++ b/includes/Category/Category.php @@ -28,6 +28,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Page\PageIdentity; use MediaWiki\Title\Title; use MediaWiki\Title\TitleArrayFromResult; +use MediaWiki\Title\TitleFactory; use MWException; use stdClass; use Wikimedia\Rdbms\IConnectionProvider; @@ -72,10 +73,14 @@ class Category { /** @var ReadOnlyMode */ private $readOnlyMode; + /** @var TitleFactory */ + private $titleFactory; + private function __construct() { $services = MediaWikiServices::getInstance(); $this->dbProvider = $services->getDBLoadBalancerFactory(); $this->readOnlyMode = $services->getReadOnlyMode(); + $this->titleFactory = $services->getTitleFactory(); } /** @@ -340,9 +345,9 @@ class Category { $queryBuilder->andWhere( $dbr->expr( 'cl_sortkey', '>', $offset ) ); } - $result = new TitleArrayFromResult( $queryBuilder->caller( __METHOD__ )->fetchResultSet() ); - - return $result; + return $this->titleFactory->newTitleArrayFromResult( + $queryBuilder->caller( __METHOD__ )->fetchResultSet() + ); } /** |