From 4e468b49e06c9d1e251cedc0fee3959f869e8978 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Wed, 10 Jan 2024 13:31:38 +0300 Subject: 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 --- includes/Category/Category.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'includes/Category') 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() + ); } /** -- cgit v1.2.3