title: Drop TitleArray in favor of TitleArrayFromResult

This patch kills TitleArray and makes TitleArrayFromResult the way
forward.

Change-Id: I056edecbee69114c77d14ecc9e7fe6212262a970
This commit is contained in:
Derick Alangi 2023-10-04 14:33:42 +01:00 committed by D3r1ck01
parent af780552ab
commit e54665dccb
6 changed files with 7 additions and 78 deletions

View file

@ -82,6 +82,7 @@ because of Phabricator reports.
* …
=== Breaking changes in 1.42 ===
* TitleArray, deprecated since 1.41, has been removed.
* UserRightsProxy, deprecated since 1.38, has been removed.
* UserLoginCompleteHook is always called with its $direct parameter set to
boolean true. The false case has been removed.

View file

@ -2200,7 +2200,6 @@ $wgAutoloadLocalClasses = [
'MediaWiki\\Title\\NamespaceInfo' => __DIR__ . '/includes/title/NamespaceInfo.php',
'MediaWiki\\Title\\SubpageImportTitleFactory' => __DIR__ . '/includes/title/SubpageImportTitleFactory.php',
'MediaWiki\\Title\\Title' => __DIR__ . '/includes/title/Title.php',
'MediaWiki\\Title\\TitleArray' => __DIR__ . '/includes/title/TitleArray.php',
'MediaWiki\\Title\\TitleArrayFromResult' => __DIR__ . '/includes/title/TitleArrayFromResult.php',
'MediaWiki\\Title\\TitleFactory' => __DIR__ . '/includes/title/TitleFactory.php',
'MediaWiki\\Title\\TitleFormatter' => __DIR__ . '/includes/title/TitleFormatter.php',
@ -2856,7 +2855,6 @@ $wgAutoloadLocalClasses = [
'TiffHandler' => __DIR__ . '/includes/media/TiffHandler.php',
'Timing' => __DIR__ . '/includes/libs/Timing.php',
'Title' => __DIR__ . '/includes/title/Title.php',
'TitleArray' => __DIR__ . '/includes/title/TitleArray.php',
'TitleArrayFromResult' => __DIR__ . '/includes/title/TitleArrayFromResult.php',
'TitleCleanup' => __DIR__ . '/maintenance/cleanupTitles.php',
'TitleFactory' => __DIR__ . '/includes/title/TitleFactory.php',

View file

@ -25,7 +25,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\Request\WebRequest;
use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Title\Title;
use MediaWiki\Title\TitleArray;
use MediaWiki\Title\TitleArrayFromResult;
use Wikimedia\Rdbms\IResultWrapper;
/**
@ -1207,7 +1207,7 @@ EOT
/**
* @see WikiFilePage::getForeignCategories
* @return TitleArray|Title[]
* @return TitleArrayFromResult
*/
public function getForeignCategories() {
return $this->getPage()->getForeignCategories();

View file

@ -23,7 +23,7 @@ namespace MediaWiki\Page;
use MapCacheLRU;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\Title\Title;
use MediaWiki\Title\TitleArray;
use MediaWiki\Title\TitleArrayFromResult;
use Wikimedia\Rdbms\IConnectionProvider;
/**
@ -210,7 +210,7 @@ class PageProps {
private function getGoodIDs( $titles ) {
$result = [];
if ( is_iterable( $titles ) ) {
if ( $titles instanceof TitleArray ||
if ( $titles instanceof TitleArrayFromResult ||
( is_array( $titles ) && reset( $titles ) instanceof Title
) ) {
// If the first element is a Title, assume all elements are Titles,

View file

@ -1,71 +0,0 @@
<?php
/**
* Class to walk into a list of Title objects.
*
* Note: this entire file is a byte-for-byte copy of UserArray.php with
* s/User/Title/. If anyone can figure out how to do this nicely with
* inheritance or something, please do so.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Title;
use Iterator;
use Wikimedia\Rdbms\IResultWrapper;
/**
* The TitleArray class only exists to provide the newFromResult method at pre-
* sent.
* The documentation of the return types for the abstract current/key functions
* helps static code analyzer to treat this as Iterator<Title>
*
* @deprecated since 1.41, Use TitleArrayFromResult instead.
*
* @method int count()
*/
abstract class TitleArray implements Iterator {
/**
* @deprecated since 1.41, Use TitleArrayFromResult instead.
* @param IResultWrapper $res A SQL result including at least page_namespace and
* page_title -- also can have page_id, page_len, page_is_redirect,
* page_latest (if those will be used). See Title::newFromRow.
* @return TitleArrayFromResult
*/
public static function newFromResult( $res ) {
wfDeprecated( __METHOD__, '1.41' );
// TODO consider merging this class with TitleArrayFromResult now that the
// TitleArrayFromResult hook has been removed
return new TitleArrayFromResult( $res );
}
/**
* @return Title
*/
abstract public function current(): Title;
/**
* @return int
*/
abstract public function key(): int;
}
/**
* @deprecated since 1.41
*/
class_alias( TitleArray::class, 'TitleArray' );

View file

@ -27,6 +27,7 @@
namespace MediaWiki\Title;
use Countable;
use Iterator;
use Wikimedia\Rdbms\IResultWrapper;
/**
@ -34,7 +35,7 @@ use Wikimedia\Rdbms\IResultWrapper;
* @note marked as newable in 1.35 for lack of a better alternative,
* but should probably become part of the TitleFactory service.
*/
class TitleArrayFromResult extends TitleArray implements Countable {
class TitleArrayFromResult implements Countable, Iterator {
/** @var IResultWrapper */
public $res;