aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/Feed/AtomFeed.php18
-rw-r--r--includes/Storage/DerivedPageDataUpdater.php12
-rw-r--r--includes/block/BlockManager.php15
-rw-r--r--includes/changes/ChangesListStringOptionsFilterGroup.php14
-rw-r--r--includes/changes/RCCacheEntryFactory.php13
-rw-r--r--includes/filerepo/ForeignAPIRepo.php9
-rw-r--r--includes/filerepo/file/LocalFile.php11
-rw-r--r--includes/import/WikiImporter.php26
-rw-r--r--includes/language/Language.php40
-rw-r--r--includes/parser/Parsoid/HtmlToContentTransform.php6
-rw-r--r--includes/site/SiteImporter.php9
-rw-r--r--includes/user/ActorCache.php16
-rw-r--r--includes/user/ActorStoreFactory.php10
-rw-r--r--includes/user/Options/UserOptionsManager.php14
14 files changed, 34 insertions, 179 deletions
diff --git a/includes/Feed/AtomFeed.php b/includes/Feed/AtomFeed.php
index 0ed7f76e6cdb..79c7e208f5b4 100644
--- a/includes/Feed/AtomFeed.php
+++ b/includes/Feed/AtomFeed.php
@@ -56,7 +56,11 @@ class AtomFeed extends ChannelFeed {
// uses htmlentities, which does not work with XML
$templateParams = [
'language' => $this->xmlEncode( $this->getLanguage() ),
- 'feedID' => $this->getFeedId(),
+ // Atom 1.0 requires a unique, opaque IRI as a unique identifier
+ // for every feed we create. For now just use the URL, but who
+ // can tell if that's right? If we put options on the feed, do we
+ // have to change the id? Maybe? Maybe not.
+ 'feedID' => $this->getSelfUrl(),
'title' => $this->getTitle(),
'url' => $this->xmlEncode( wfExpandUrl( $this->getUrlUnescaped(), PROTO_CURRENT ) ),
'selfUrl' => $this->getSelfUrl(),
@@ -68,18 +72,6 @@ class AtomFeed extends ChannelFeed {
}
/**
- * Atom 1.0 requires a unique, opaque IRI as a unique identifier
- * for every feed we create. For now just use the URL, but who
- * can tell if that's right? If we put options on the feed, do we
- * have to change the id? Maybe? Maybe not.
- *
- * @return string
- */
- private function getFeedId() {
- return $this->getSelfUrl();
- }
-
- /**
* Atom 1.0 requests a self-reference to the feed.
* @return string
*/
diff --git a/includes/Storage/DerivedPageDataUpdater.php b/includes/Storage/DerivedPageDataUpdater.php
index 763626829bca..a136951ba949 100644
--- a/includes/Storage/DerivedPageDataUpdater.php
+++ b/includes/Storage/DerivedPageDataUpdater.php
@@ -743,23 +743,13 @@ class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface, P
}
/**
- * Returns the content model of the given slot
- *
- * @param string $role slot role name
- * @return string
- */
- private function getContentModel( $role ) {
- return $this->getRawSlot( $role )->getModel();
- }
-
- /**
* @param string $role slot role name
* @return ContentHandler
* @throws MWUnknownContentModelException
*/
private function getContentHandler( $role ): ContentHandler {
return $this->contentHandlerFactory
- ->getContentHandler( $this->getContentModel( $role ) );
+ ->getContentHandler( $this->getRawSlot( $role )->getModel() );
}
private function usePrimary() {
diff --git a/includes/block/BlockManager.php b/includes/block/BlockManager.php
index 5c94079b3073..40da52acdf86 100644
--- a/includes/block/BlockManager.php
+++ b/includes/block/BlockManager.php
@@ -220,7 +220,9 @@ class BlockManager {
// Case #1: checking the global user, including IP blocks
$ip = $request->getIP();
- $applySoftBlocks = $this->applySoftBlockToUser( $user );
+ // For soft blocks, i.e. blocks that don't block logged-in users,
+ // temporary users are treated as anon users, and are blocked.
+ $applySoftBlocks = !$this->userIdentityUtils->isNamed( $user );
$xff = $request->getHeader( 'X-Forwarded-For' );
@@ -367,17 +369,6 @@ class BlockManager {
}
/**
- * For soft blocks, i.e. blocks that don't block logged-in users,
- * temporary users are treated as anon users, and are blocked.
- *
- * @param UserIdentity $user
- * @return bool
- */
- private function applySoftBlockToUser( UserIdentity $user ): bool {
- return !$this->userIdentityUtils->isNamed( $user );
- }
-
- /**
* @param string|null $ip
* @param AbstractBlock[] $blocks
* @return AbstractBlock|null
diff --git a/includes/changes/ChangesListStringOptionsFilterGroup.php b/includes/changes/ChangesListStringOptionsFilterGroup.php
index 36cba64128e2..4f7ec260d584 100644
--- a/includes/changes/ChangesListStringOptionsFilterGroup.php
+++ b/includes/changes/ChangesListStringOptionsFilterGroup.php
@@ -170,7 +170,8 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
&$tables, &$fields, &$conds, &$query_options, &$join_conds,
FormOptions $opts, $isStructuredFiltersEnabled
) {
- if ( !$this->isActive( $isStructuredFiltersEnabled ) ) {
+ // STRING_OPTIONS filter groups are exclusively active on Structured UI
+ if ( !$isStructuredFiltersEnabled ) {
return;
}
@@ -234,15 +235,4 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
public function addOptions( FormOptions $opts, $allowDefaults, $isStructuredFiltersEnabled ) {
$opts->add( $this->getName(), $allowDefaults ? $this->getDefault() : '' );
}
-
- /**
- * Check if this filter group is currently active
- *
- * @param bool $isStructuredUI Is structured filters UI current enabled
- * @return bool
- */
- private function isActive( $isStructuredUI ) {
- // STRING_OPTIONS filter groups are exclusively active on Structured UI
- return $isStructuredUI;
- }
}
diff --git a/includes/changes/RCCacheEntryFactory.php b/includes/changes/RCCacheEntryFactory.php
index 47374574f1ba..4801fb403c76 100644
--- a/includes/changes/RCCacheEntryFactory.php
+++ b/includes/changes/RCCacheEntryFactory.php
@@ -22,7 +22,6 @@
use MediaWiki\Linker\Linker;
use MediaWiki\Linker\LinkRenderer;
-use MediaWiki\Permissions\Authority;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Title\Title;
@@ -89,7 +88,7 @@ class RCCacheEntryFactory {
// Make "cur" and "diff" links. Do not use link(), it is too slow if
// called too many times (50% of CPU time on RecentChanges!).
- $showDiffLinks = $this->showDiffLinks( $cacheEntry, $user );
+ $showDiffLinks = ChangesList::userCan( $cacheEntry, RevisionRecord::DELETED_TEXT, $user );
$cacheEntry->difflink = $this->buildDiffLink( $cacheEntry, $showDiffLinks );
$cacheEntry->curlink = $this->buildCurLink( $cacheEntry, $showDiffLinks );
@@ -130,16 +129,6 @@ class RCCacheEntryFactory {
}
/**
- * @param RecentChange $cacheEntry
- * @param Authority $performer
- *
- * @return bool
- */
- private function showDiffLinks( RecentChange $cacheEntry, Authority $performer ) {
- return ChangesList::userCan( $cacheEntry, RevisionRecord::DELETED_TEXT, $performer );
- }
-
- /**
* @param RCCacheEntry $cacheEntry
*
* @return string
diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php
index b19e7a201d9a..d5fd99e68b91 100644
--- a/includes/filerepo/ForeignAPIRepo.php
+++ b/includes/filerepo/ForeignAPIRepo.php
@@ -115,13 +115,6 @@ class ForeignAPIRepo extends FileRepo implements IForeignRepoWithMWApi {
}
/**
- * @return string
- */
- private function getApiUrl() {
- return $this->mApiBase;
- }
-
- /**
* Per docs in FileRepo, this needs to return false if we don't support versioned
* files. Well, we don't.
*
@@ -503,7 +496,7 @@ class ForeignAPIRepo extends FileRepo implements IForeignRepoWithMWApi {
*/
public function getInfo() {
$info = parent::getInfo();
- $info['apiurl'] = $this->getApiUrl();
+ $info['apiurl'] = $this->mApiBase;
$query = [
'format' => 'json',
diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php
index b2fc79e3d646..70abf6793796 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1287,13 +1287,6 @@ class LocalFile extends File {
}
/**
- * Refresh metadata in memcached, but don't touch thumbnails or CDN
- */
- private function purgeMetadataCache() {
- $this->invalidateCache();
- }
-
- /**
* Delete all previously generated thumbnails, refresh metadata in memcached and purge the CDN.
* @stable to override
*
@@ -1302,9 +1295,9 @@ class LocalFile extends File {
* @note This used to purge old thumbnails by default as well, but doesn't anymore.
*/
public function purgeCache( $options = [] ) {
- // Refresh metadata cache
+ // Refresh metadata in memcached, but don't touch thumbnails or CDN
$this->maybeUpgradeRow();
- $this->purgeMetadataCache();
+ $this->invalidateCache();
// Delete thumbnails
$this->purgeThumbnails( $options );
diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php
index a24b4e39dbd4..2868393d4836 100644
--- a/includes/import/WikiImporter.php
+++ b/includes/import/WikiImporter.php
@@ -1050,8 +1050,10 @@ class WikiImporter {
}
$role = $contentInfo['role'] ?? SlotRecord::MAIN;
- $model = $contentInfo['model'] ?? $this->getDefaultContentModel( $title, $role );
- $handler = $this->getContentHandler( $model );
+ $model = $contentInfo['model'] ?? $this->slotRoleRegistry
+ ->getRoleHandler( $role )
+ ->getDefaultModel( $title );
+ $handler = $this->contentHandlerFactory->getContentHandler( $model );
$text = $handler->importTransform( $contentInfo['text'] );
@@ -1290,26 +1292,6 @@ class WikiImporter {
}
/**
- * @param string $model
- * @return ContentHandler
- */
- private function getContentHandler( $model ) {
- return $this->contentHandlerFactory->getContentHandler( $model );
- }
-
- /**
- * @param Title $title
- * @param string $role
- *
- * @return string
- */
- private function getDefaultContentModel( $title, $role ) {
- return $this->slotRoleRegistry
- ->getRoleHandler( $role )
- ->getDefaultModel( $title );
- }
-
- /**
* Open the XMLReader connected to the source adapter id
* @suppress PhanStaticCallToNonStatic, UnusedSuppression -- for PHP 7.4 support
*/
diff --git a/includes/language/Language.php b/includes/language/Language.php
index ec96020bcd79..fa9a3b59739e 100644
--- a/includes/language/Language.php
+++ b/includes/language/Language.php
@@ -788,38 +788,6 @@ class Language implements Bcp47Code {
}
/**
- * @param int $key Number from 1 to 12
- * @return string
- */
- private function getIranianCalendarMonthName( $key ) {
- return $this->getMessageFromDB( self::IRANIAN_CALENDAR_MONTHS_MESSAGES[$key - 1] );
- }
-
- /**
- * @param int $key Number from 1 to 14
- * @return string
- */
- private function getHebrewCalendarMonthName( $key ) {
- return $this->getMessageFromDB( self::HEBREW_CALENDAR_MONTHS_MESSAGES[$key - 1] );
- }
-
- /**
- * @param int $key Number from 1 to 14
- * @return string
- */
- private function getHebrewCalendarMonthNameGen( $key ) {
- return $this->getMessageFromDB( self::HEBREW_CALENDAR_MONTH_GENITIVE_MESSAGES[$key - 1] );
- }
-
- /**
- * @param int $key Number from 1 to 12
- * @return string
- */
- private function getHijriCalendarMonthName( $key ) {
- return $this->getMessageFromDB( self::HIJRI_CALENDAR_MONTH_MESSAGES[$key - 1] );
- }
-
- /**
* Pass through the result from $dateTimeObj->format()
*
* @param DateTime|false|null &$dateTimeObj
@@ -999,7 +967,7 @@ class Language implements Bcp47Code {
if ( !$hebrew ) {
$hebrew = self::tsToHebrew( $ts );
}
- $s .= $this->getHebrewCalendarMonthNameGen( $hebrew[1] );
+ $s .= $this->getMessageFromDB( self::HEBREW_CALENDAR_MONTH_GENITIVE_MESSAGES[$hebrew[1] - 1] );
break;
case 'd':
@@ -1060,7 +1028,7 @@ class Language implements Bcp47Code {
if ( !$iranian ) {
$iranian = self::tsToIranian( $ts );
}
- $s .= $this->getIranianCalendarMonthName( $iranian[1] );
+ $s .= $this->getMessageFromDB( self::IRANIAN_CALENDAR_MONTHS_MESSAGES[$iranian[1] - 1] );
break;
case 'xmF':
@@ -1068,7 +1036,7 @@ class Language implements Bcp47Code {
if ( !$hijri ) {
$hijri = self::tsToHijri( $ts );
}
- $s .= $this->getHijriCalendarMonthName( $hijri[1] );
+ $s .= $this->getMessageFromDB( self::HIJRI_CALENDAR_MONTH_MESSAGES[$hijri[1] - 1] );
break;
case 'xjF':
@@ -1076,7 +1044,7 @@ class Language implements Bcp47Code {
if ( !$hebrew ) {
$hebrew = self::tsToHebrew( $ts );
}
- $s .= $this->getHebrewCalendarMonthName( $hebrew[1] );
+ $s .= $this->getMessageFromDB( self::HEBREW_CALENDAR_MONTHS_MESSAGES[$hebrew[1] - 1] );
break;
case 'm':
diff --git a/includes/parser/Parsoid/HtmlToContentTransform.php b/includes/parser/Parsoid/HtmlToContentTransform.php
index 73a0d596e8fa..59235d02eaa2 100644
--- a/includes/parser/Parsoid/HtmlToContentTransform.php
+++ b/includes/parser/Parsoid/HtmlToContentTransform.php
@@ -90,10 +90,6 @@ class HtmlToContentTransform {
$this->metrics = $metrics;
}
- private function startTiming(): Timing {
- return Timing::start( $this->metrics );
- }
-
private function incrementMetrics( string $key ) {
if ( $this->metrics ) {
$this->metrics->increment( $key );
@@ -510,7 +506,7 @@ class HtmlToContentTransform {
$this->incrementMetrics(
"downgrade.from.{$downgrade['from']}.to.{$downgrade['to']}"
);
- $downgradeTiming = $this->startTiming();
+ $downgradeTiming = Timing::start( $this->metrics );
Parsoid::downgrade( $downgrade, $pb );
$downgradeTiming->end( 'downgrade.time' );
diff --git a/includes/site/SiteImporter.php b/includes/site/SiteImporter.php
index 0895bab124b5..f5cf76665d38 100644
--- a/includes/site/SiteImporter.php
+++ b/includes/site/SiteImporter.php
@@ -108,14 +108,7 @@ class SiteImporter {
libxml_use_internal_errors( $oldLibXmlErrors );
// phpcs:ignore Generic.PHP.NoSilencedErrors
@libxml_disable_entity_loader( $oldDisable );
- $this->importFromDOM( $document->documentElement );
- }
-
- /**
- * @param DOMElement $root
- */
- private function importFromDOM( DOMElement $root ) {
- $sites = $this->makeSiteList( $root );
+ $sites = $this->makeSiteList( $document->documentElement );
$this->store->saveSites( $sites );
}
diff --git a/includes/user/ActorCache.php b/includes/user/ActorCache.php
index 95ea8de22c6d..678e98a9bdd2 100644
--- a/includes/user/ActorCache.php
+++ b/includes/user/ActorCache.php
@@ -134,19 +134,13 @@ class ActorCache {
private function getCachedValue( string $keyType, $keyValue ): ?array {
if ( isset( $this->cache[$keyType][$keyValue] ) ) {
$cached = $this->cache[$keyType][$keyValue];
- $this->ping( $cached['actorId'] );
+ $actorId = $cached['actorId'];
+ // Record the actor with $actorId was recently used.
+ $item = $this->cache[self::KEY_ACTOR_ID][$actorId];
+ unset( $this->cache[self::KEY_ACTOR_ID][$actorId] );
+ $this->cache[self::KEY_ACTOR_ID][$actorId] = $item;
return $cached;
}
return null;
}
-
- /**
- * Record the actor with $actorId was recently used.
- * @param int $actorId
- */
- private function ping( int $actorId ) {
- $item = $this->cache[self::KEY_ACTOR_ID][$actorId];
- unset( $this->cache[self::KEY_ACTOR_ID][$actorId] );
- $this->cache[self::KEY_ACTOR_ID][$actorId] = $item;
- }
}
diff --git a/includes/user/ActorStoreFactory.php b/includes/user/ActorStoreFactory.php
index 626c49e5febd..df73ef0d822e 100644
--- a/includes/user/ActorStoreFactory.php
+++ b/includes/user/ActorStoreFactory.php
@@ -104,7 +104,7 @@ class ActorStoreFactory {
$wikiId = WikiAwareEntity::LOCAL;
}
- $storeCacheKey = $this->getStoreCacheKey( $wikiId );
+ $storeCacheKey = $wikiId === WikiAwareEntity::LOCAL ? 'LOCAL' : $wikiId;
if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
$this->storeCache[$storeCacheKey] = new ActorStore(
$this->getLoadBalancerForTable( 'actor', $wikiId ),
@@ -129,14 +129,6 @@ class ActorStoreFactory {
}
/**
- * @param string|false $wikiId
- * @return string
- */
- private function getStoreCacheKey( $wikiId ): string {
- return $wikiId === WikiAwareEntity::LOCAL ? 'LOCAL' : $wikiId;
- }
-
- /**
* Returns a load balancer for the database that has the $table
* for the given $wikiId.
*
diff --git a/includes/user/Options/UserOptionsManager.php b/includes/user/Options/UserOptionsManager.php
index 8c130b9a9a98..12c83f6b2c7d 100644
--- a/includes/user/Options/UserOptionsManager.php
+++ b/includes/user/Options/UserOptionsManager.php
@@ -523,7 +523,7 @@ class UserOptionsManager extends UserOptionsLookup {
* Fetches the options directly from the database with no caches.
*
* @param UserIdentity $user
- * @param int $queryFlags
+ * @param int $queryFlags a bit field composed of READ_XXX flags
* @param array|null $prefetchedOptions
* @return array
*/
@@ -534,7 +534,8 @@ class UserOptionsManager extends UserOptionsLookup {
): array {
if ( $prefetchedOptions === null ) {
$this->logger->debug( 'Loading options from database', [ 'user_id' => $user->getId() ] );
- [ $dbr, $options ] = $this->getDBAndOptionsForQueryFlags( $queryFlags );
+ [ $mode, $options ] = DBAccessObjectUtils::getDBOptions( $queryFlags );
+ $dbr = DBAccessObjectUtils::getDBFromIndex( $this->dbProvider, $mode );
$res = $dbr->newSelectQueryBuilder()
->select( [ 'up_property', 'up_value' ] )
->from( 'user_properties' )
@@ -665,15 +666,6 @@ class UserOptionsManager extends UserOptionsLookup {
}
/**
- * @param int $queryFlags a bit field composed of READ_XXX flags
- * @return array [ IDatabase $db, array $options ]
- */
- private function getDBAndOptionsForQueryFlags( $queryFlags ): array {
- [ $mode, $options ] = DBAccessObjectUtils::getDBOptions( $queryFlags );
- return [ DBAccessObjectUtils::getDBFromIndex( $this->dbProvider, $mode ), $options ];
- }
-
- /**
* Determines if it's ok to use cached options values for a given user and query flags
* @param UserIdentity $user
* @param int $queryFlags