From 1a365e77dfb8825136626202b1df462731b42060 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 16 Aug 2015 08:22:05 +0200 Subject: Update to MediaWiki 1.25.2 --- includes/DefaultSettings.php | 2 +- includes/GlobalFunctions.php | 2 +- includes/Setup.php | 4 +-- includes/User.php | 37 +++++------------------ includes/api/ApiBase.php | 2 +- includes/api/ApiOpenSearch.php | 14 ++++++++- includes/api/ApiQueryImageInfo.php | 5 ++- includes/exception/MWExceptionHandler.php | 7 ++++- includes/filerepo/ForeignAPIRepo.php | 1 + includes/installer/DatabaseUpdater.php | 23 ++++++++++---- includes/registration/ExtensionProcessor.php | 1 + includes/registration/ExtensionRegistry.php | 20 +++++++++++- includes/specials/SpecialDeletedContributions.php | 2 +- includes/specials/SpecialVersion.php | 4 +-- 14 files changed, 75 insertions(+), 49 deletions(-) (limited to 'includes') diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 010c471c..75ed529e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -75,7 +75,7 @@ $wgConfigRegistry = array( * MediaWiki version number * @since 1.2 */ -$wgVersion = '1.25.1'; +$wgVersion = '1.25.2'; /** * Name of the site. It must be changed in LocalSettings.php diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 240cb97b..45cd7ea5 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3342,7 +3342,7 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, // Removing leading zeros works around broken base detection code in // some PHP versions (see and // ). - $result = gmp_strval( gmp_init( ltrim( $input, '0' ), $sourceBase ), $destBase ); + $result = gmp_strval( gmp_init( ltrim( $input, '0' ) ?: '0', $sourceBase ), $destBase ); } elseif ( extension_loaded( 'bcmath' ) && ( $engine == 'auto' || $engine == 'bcmath' ) ) { $decimal = '0'; foreach ( str_split( strtolower( $input ) ) as $char ) { diff --git a/includes/Setup.php b/includes/Setup.php index dd8fbf8a..b3bf0fca 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -232,9 +232,7 @@ if ( $wgUseInstantCommons ) { $wgForeignFileRepos[] = array( 'class' => 'ForeignAPIRepo', 'name' => 'wikimediacommons', - 'apibase' => WebRequest::detectProtocol() === 'https' ? - 'https://commons.wikimedia.org/w/api.php' : - 'http://commons.wikimedia.org/w/api.php', + 'apibase' => 'https://commons.wikimedia.org/w/api.php', 'hashLevels' => 2, 'fetchDescription' => true, 'descriptionCacheExpiry' => 43200, diff --git a/includes/User.php b/includes/User.php index 3cd69fdc..8ea491ce 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2204,6 +2204,8 @@ class User implements IDBAccessObject { * page. Ignored if null or !$val. */ public function setNewtalk( $val, $curRev = null ) { + global $wgMemc; + if ( wfReadOnly() ) { return; } @@ -2218,7 +2220,6 @@ class User implements IDBAccessObject { $field = 'user_id'; $id = $this->getId(); } - global $wgMemc; if ( $val ) { $changed = $this->updateNewtalk( $field, $id, $curRev ); @@ -2270,37 +2271,13 @@ class User implements IDBAccessObject { } /** - * Immediately touch the user data cache for this account. - * Updates user_touched field, and removes account data from memcached - * for reload on the next hit. + * Immediately touch the user data cache for this account + * + * Calls touch() and removes account data from memcached */ public function invalidateCache() { - if ( wfReadOnly() ) { - return; - } - $this->load(); - if ( $this->mId ) { - $this->mTouched = $this->newTouchedTimestamp(); - - $dbw = wfGetDB( DB_MASTER ); - $userid = $this->mId; - $touched = $this->mTouched; - $method = __METHOD__; - $dbw->onTransactionIdle( function () use ( $dbw, $userid, $touched, $method ) { - // Prevent contention slams by checking user_touched first - $encTouched = $dbw->addQuotes( $dbw->timestamp( $touched ) ); - $needsPurge = $dbw->selectField( 'user', '1', - array( 'user_id' => $userid, 'user_touched < ' . $encTouched ) ); - if ( $needsPurge ) { - $dbw->update( 'user', - array( 'user_touched' => $dbw->timestamp( $touched ) ), - array( 'user_id' => $userid, 'user_touched < ' . $encTouched ), - $method - ); - } - } ); - $this->clearSharedCache(); - } + $this->touch(); + $this->clearSharedCache(); } /** diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 5a1eb995..6c33da57 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1192,7 +1192,7 @@ abstract class ApiBase extends ContextSource { $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' ); } $token = $user->getOption( 'watchlisttoken' ); - if ( $token == '' || $token != $params['token'] ) { + if ( $token == '' || !hash_equals( $token, $params['token'] ) ) { $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index a93b7cc6..0adb464d 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -384,13 +384,25 @@ class ApiOpenSearchFormatJson extends ApiFormatJson { public function execute() { if ( !$this->getResult()->getResultData( 'error' ) ) { - $warnings = $this->getResult()->removeValue( 'warnings', null ); + $result = $this->getResult(); + + // Ignore warnings or treat as errors, as requested + $warnings = $result->removeValue( 'warnings', null ); if ( $this->warningsAsError && $warnings ) { $this->dieUsage( 'Warnings cannot be represented in OpenSearch JSON format', 'warnings', 0, array( 'warnings' => $warnings ) ); } + + // Ignore any other unexpected keys (e.g. from $wgDebugToolbar) + $remove = array_keys( array_diff_key( + $result->getResultData(), + array( 0 => 'search', 1 => 'terms', 2 => 'descriptions', 3 => 'urls' ) + ) ); + foreach ( $remove as $key ) { + $result->removeValue( $key, null ); + } } parent::execute(); diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 94b4bbdb..095e5dda 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -592,7 +592,10 @@ class ApiQueryImageInfo extends ApiQueryBase { $retval = array(); if ( is_array( $metadata ) ) { foreach ( $metadata as $key => $value ) { - $r = array( 'name' => $key ); + $r = array( + 'name' => $key, + ApiResult::META_BC_BOOLS => array( 'value' ), + ); if ( is_array( $value ) ) { $r['value'] = self::processMetaData( $value, $result ); } else { diff --git a/includes/exception/MWExceptionHandler.php b/includes/exception/MWExceptionHandler.php index c50b6c8c..a58705f6 100644 --- a/includes/exception/MWExceptionHandler.php +++ b/includes/exception/MWExceptionHandler.php @@ -486,6 +486,8 @@ TXT; if ( $json !== false ) { wfDebugLog( 'exception-json', $json, 'private' ); } + + Hooks::run( 'LogException', array( $e, false ) ); } } @@ -501,7 +503,8 @@ TXT; // The set_error_handler callback is independent from error_reporting. // Filter out unwanted errors manually (e.g. when wfSuppressWarnings is active). - if ( ( error_reporting() & $e->getSeverity() ) !== 0 ) { + $suppressed = ( error_reporting() & $e->getSeverity() ) === 0; + if ( !$suppressed ) { $log = self::getLogMessage( $e ); if ( $wgLogExceptionBacktrace ) { wfDebugLog( $channel, $log . "\n" . $e->getTraceAsString() ); @@ -515,5 +518,7 @@ TXT; if ( $json !== false ) { wfDebugLog( "$channel-json", $json, 'private' ); } + + Hooks::run( 'LogException', array( $e, $suppressed ) ); } } diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 7ead968f..3c031921 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -521,6 +521,7 @@ class ForeignAPIRepo extends FileRepo { if ( $status->isOK() ) { return $req->getContent(); } else { + wfDebug( "ForeignAPIRepo: ERROR on GET: " . $status->getWikiText() ); return false; } } diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 702f850c..70707901 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -145,15 +145,26 @@ abstract class DatabaseUpdater { return; // already loaded } $vars = Installer::getExistingLocalSettings(); - if ( !$vars ) { - return; // no LocalSettings found + + $registry = ExtensionRegistry::getInstance(); + $queue = $registry->getQueue(); + // Don't accidentally load extensions in the future + $registry->clearQueue(); + + // This will automatically add "AutoloadClasses" to $wgAutoloadClasses + $data = $registry->readFromQueue( $queue ); + $hooks = array( 'wgHooks' => array( 'LoadExtensionSchemaUpdates' => array() ) ); + if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) { + $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']; } - if ( !isset( $vars['wgHooks'] ) || !isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) { - return; + if ( $vars && isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) { + $hooks = array_merge_recursive( $hooks, $vars['wgHooks']['LoadExtensionSchemaUpdates'] ); } global $wgHooks, $wgAutoloadClasses; - $wgHooks['LoadExtensionSchemaUpdates'] = $vars['wgHooks']['LoadExtensionSchemaUpdates']; - $wgAutoloadClasses = $wgAutoloadClasses + $vars['wgAutoloadClasses']; + $wgHooks['LoadExtensionSchemaUpdates'] = $hooks; + if ( $vars && isset( $vars['wgAutoloadClasses'] ) ) { + $wgAutoloadClasses += $vars['wgAutoloadClasses']; + } } /** diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 7f738661..bb8fb329 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -81,6 +81,7 @@ class ExtensionProcessor implements Processor { 'config', 'ParserTestFiles', 'AutoloadClasses', + 'manifest_version', ); /** diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 2558f7e2..4e690aa8 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -108,6 +108,24 @@ class ExtensionRegistry { $this->queued = array(); } + /** + * Get the current load queue. Not intended to be used + * outside of the installer. + * + * @return array + */ + public function getQueue() { + return $this->queued; + } + + /** + * Clear the current load queue. Not intended to be used + * outside of the installer. + */ + public function clearQueue() { + $this->queued = array(); + } + /** * Process a queue of extensions and return their extracted data * @@ -143,7 +161,7 @@ class ExtensionRegistry { protected function exportExtractedData( array $info ) { foreach ( $info['globals'] as $key => $val ) { - if ( !isset( $GLOBALS[$key] ) || !$GLOBALS[$key] ) { + if ( !isset( $GLOBALS[$key] ) || ( is_array( $GLOBALS[$key] ) && !$GLOBALS[$key] ) ) { $GLOBALS[$key] = $val; } elseif ( $key === 'wgHooks' || $key === 'wgExtensionCredits' ) { // Special case $wgHooks and $wgExtensionCredits, which require a recursive merge. diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index 9e4bbbe5..fb85942d 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -479,7 +479,7 @@ class DeletedContributionsPage extends SpecialPage { if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { # Block / Change block / Unblock links if ( $this->getUser()->isAllowed( 'block' ) ) { - if ( $userObj->isBlocked() ) { + if ( $userObj->isBlocked() && $userObj->getBlock()->getType() !== Block::TYPE_AUTO ) { $tools[] = Linker::linkKnown( # Change block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), $this->msg( 'change-blocklink' )->escaped() diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index c1a95939..9a1c5e5d 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -265,8 +265,8 @@ class SpecialVersion extends SpecialPage { $version = $wgVersion . ' ' . wfMessage( 'version-svn-revision', - isset( $info['directory-rev'] ) ? $info['directory-rev'] : '', - $info['checkout-rev'] + isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : '', + isset( $svnInfo['checkout-rev'] ) ? $svnInfo['checkout-rev'] : '' )->text(); } -- cgit v1.2.2