* User::makeGroupLinkWiki(), deprecated in 1.29, has been removed. Use
UserGroupMembership::getLink() instead.
* SavepointPostgres, deprecated in 1.31, has been removed.
-* Output::sectionEditLinksEnabled(), ParserOutput::getEditSectionTokens,
- ::getTOCEnabled, ::setEditSectionTokens, ::setTOCEnabled, deprecated in 1.31,
- have been removed.
+* OutputPage::enableSectionEditLinks(), OutputPage::sectionEditLinksEnabled(),
+ ParserOptions::getEditSection(), ParserOptions::setEditSection(), and
+ ParserOutput::getEditSectionTokens, ::getTOCEnabled, ::setEditSectionTokens,
+ and ::setTOCEnabled, deprecated in 1.31, have been removed.
* EditPage::safeUnicodeInput() and ::safeUnicodeOutput(), deprecated in 1.30,
have been removed.
* Four methods in OutputPage, deprecated in 1.32, have been removed. You should
removed.
* The $wgUseKeyHeader configuration option and the OutputPage::getKeyHeader()
method, deprecated in 1.32, have been removed.
+* WebInstallerOutput::addWikiText(), deprecated in 1.32, has been removed.
+* Parser::fetchFile(), deprecated in 1.32, has been removed. Use the method
+ Parser::fetchFileAndTitle() instead.
+* The global function wfBCP47, deprecated in 1.31, has been removed.
+* wfCountDown() function, deprecated in 1.31, has been removed. Use
+ \Maintenance::countDown() method instead.
* …
=== Deprecations in 1.34 ===
* temporary storage. Preprocessor_DOM generally uses less memory;
* the speed of the two is roughly the same.
*
- * If this parameter is not given, it uses Preprocessor_DOM if the
- * DOM module is available, otherwise it uses Preprocessor_Hash.
+ * If this parameter is not given, it uses Preprocessor_Hash.
*
* The Preprocessor_DOM class is deprecated, and will be removed in a future
* release.
return $lbFactory->waitForReplication( $opts );
}
-/**
- * Count down from $seconds to zero on the terminal, with a one-second pause
- * between showing each number. For use in command-line scripts.
- *
- * @deprecated since 1.31, use Maintenance::countDown()
- *
- * @codeCoverageIgnore
- * @param int $seconds
- */
-function wfCountDown( $seconds ) {
- wfDeprecated( __FUNCTION__, '1.31' );
- for ( $i = $seconds; $i >= 0; $i-- ) {
- if ( $i != $seconds ) {
- echo str_repeat( "\x08", strlen( $i + 1 ) );
- }
- echo $i;
- flush();
- if ( $i ) {
- sleep( 1 );
- }
- }
- echo "\n";
-}
-
/**
* Replace all invalid characters with '-'.
* Additional characters can be defined in $wgIllegalFileChars (see T22489).
return $val;
}
-/**
- * Get the normalised IETF language tag
- * See unit test for examples.
- * See mediawiki.language.bcp47 for the JavaScript implementation.
- *
- * @deprecated since 1.31, use LanguageCode::bcp47() directly.
- *
- * @param string $code The language code.
- * @return string The language code which complying with BCP 47 standards.
- */
-function wfBCP47( $code ) {
- wfDeprecated( __METHOD__, '1.31' );
- return LanguageCode::bcp47( $code );
-}
-
/**
* Get a specific cache object.
*
return $this->mEnableTOC;
}
- /**
- * Enables/disables section edit links, doesn't override __NOEDITSECTION__
- * @param bool $flag
- * @since 1.23
- * @deprecated since 1.31, use $poOptions to addParserOutput() instead.
- */
- public function enableSectionEditLinks( $flag = true ) {
- wfDeprecated( __METHOD__, '1.31' );
- }
-
/**
* Helper function to setup the PHP implementation of OOUI to use in this request.
*
* @file
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* $this->getPageTableFields().
*
* @param IDatabase $db
- * @param ResultWrapper $queryResult
+ * @param IResultWrapper $queryResult
*/
public function populateFromQueryResult( $db, $queryResult ) {
$this->initFromQueryResult( $queryResult );
/**
* Iterate through the result of the query on 'page' table,
* and for each row create and store title object and save any extra fields requested.
- * @param ResultWrapper $res DB Query result
+ * @param IResultWrapper $res DB Query result
* @param array $remaining Array of either pageID or ns/title elements (optional).
* If given, any missing items will go to $mMissingPageIDs and $mMissingTitles
* @param bool $processTitles Must be provided together with $remaining.
*/
use Wikimedia\Rdbms\IDatabase;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
/**
* This is a base class for all Query modules.
* @param array|null &$hookData If set, the ApiQueryBaseBeforeQuery and
* ApiQueryBaseAfterQuery hooks will be called, and the
* ApiQueryBaseProcessRow hook will be expected.
- * @return ResultWrapper
+ * @return IResultWrapper
*/
protected function select( $method, $extraQuery = [], array &$hookData = null ) {
$tables = array_merge(
}
/**
- * Given a list of blocks, return a list blocks where each block either has a
- * unique ID or has ID null.
+ * Given a list of blocks, return a list of unique blocks.
+ *
+ * This usually means that each block has a unique ID. For a block with ID null,
+ * if it's an autoblock, it will be filtered out if the parent block is present;
+ * if not, it is assumed to be a unique system block, and kept.
*
* @param AbstractBlock[] $blocks
* @return AbstractBlock[]
*/
private function getUniqueBlocks( $blocks ) {
- $blockIds = [];
- $uniqueBlocks = [];
+ $systemBlocks = [];
+ $databaseBlocks = [];
+
foreach ( $blocks as $block ) {
- $id = $block->getId();
- if ( $id === null ) {
- $uniqueBlocks[] = $block;
- } elseif ( !isset( $blockIds[$id] ) ) {
- $uniqueBlocks[] = $block;
- $blockIds[$block->getId()] = true;
+ if ( $block instanceof SystemBlock ) {
+ $systemBlocks[] = $block;
+ } elseif ( $block->getType() === DatabaseBlock::TYPE_AUTO ) {
+ if ( !isset( $databaseBlocks[$block->getParentBlockId()] ) ) {
+ $databaseBlocks[$block->getParentBlockId()] = $block;
+ }
+ } else {
+ $databaseBlocks[$block->getId()] = $block;
}
}
- return $uniqueBlocks;
+
+ return array_merge( $systemBlocks, $databaseBlocks );
}
/**
return $this;
}
+ /**
+ * @since 1.34
+ * @return int|null If this is an autoblock, ID of the parent block; otherwise null
+ */
+ public function getParentBlockId() {
+ return $this->mParentBlockId;
+ }
+
/**
* Get/set a flag determining whether the master is used for reads
*
* @since 1.34
*/
class ServiceOptions {
+ private $keys = [];
private $options = [];
/**
* @throws InvalidArgumentException if one of $keys is not found in any of $sources
*/
public function __construct( array $keys, ...$sources ) {
+ $this->keys = $keys;
foreach ( $keys as $key ) {
foreach ( $sources as $source ) {
if ( $source instanceof Config ) {
* @param string[] $expectedKeys
*/
public function assertRequiredOptions( array $expectedKeys ) {
- $actualKeys = array_keys( $this->options );
- $extraKeys = array_diff( $actualKeys, $expectedKeys );
- $missingKeys = array_diff( $expectedKeys, $actualKeys );
- Assert::precondition( !$extraKeys && !$missingKeys,
- (
- $extraKeys
- ? 'Unsupported options passed: ' . implode( ', ', $extraKeys ) . '!'
- : ''
- ) . ( $extraKeys && $missingKeys ? ' ' : '' ) . (
- $missingKeys
- ? 'Required options missing: ' . implode( ', ', $missingKeys ) . '!'
- : ''
- )
- );
+ if ( $this->keys !== $expectedKeys ) {
+ $extraKeys = array_diff( $this->keys, $expectedKeys );
+ $missingKeys = array_diff( $expectedKeys, $this->keys );
+ Assert::precondition( !$extraKeys && !$missingKeys,
+ (
+ $extraKeys
+ ? 'Unsupported options passed: ' . implode( ', ', $extraKeys ) . '!'
+ : ''
+ ) . ( $extraKeys && $missingKeys ? ' ' : '' ) . (
+ $missingKeys
+ ? 'Required options missing: ' . implode( ', ', $missingKeys ) . '!'
+ : ''
+ )
+ );
+ }
}
/**
$this->flush();
}
- /**
- * @param string $text
- * @deprecated since 1.32; use addWikiTextAsInterface instead
- */
- public function addWikiText( $text ) {
- wfDeprecated( __METHOD__, '1.32' );
- $this->addWikiTextAsInterface( $text );
- }
-
/**
* @param string $text
* @since 1.32
'deps' => $deps ];
}
- /**
- * Fetch a file and its title and register a reference to it.
- * If 'broken' is a key in $options then the file will appear as a broken thumbnail.
- * @param Title $title
- * @param array $options Array of options to RepoGroup::findFile
- * @return File|bool
- * @deprecated since 1.32, use fetchFileAndTitle instead
- */
- public function fetchFile( $title, $options = [] ) {
- wfDeprecated( __METHOD__, '1.32' );
- return $this->fetchFileAndTitle( $title, $options )[0];
- }
-
/**
* Fetch a file and its title and register a reference to it.
* If 'broken' is a key in $options then the file will appear as a broken thumbnail.
return wfSetVar( $this->mTimestamp, $x );
}
- /**
- * Create "edit section" links?
- * @deprecated since 1.31, use ParserOutput::getText() options instead.
- * @return bool
- */
- public function getEditSection() {
- wfDeprecated( __METHOD__, '1.31' );
- return true;
- }
-
- /**
- * Create "edit section" links?
- * @deprecated since 1.31, use ParserOutput::getText() options instead.
- * @param bool|null $x New value (null is no change)
- * @return bool Old value
- */
- public function setEditSection( $x ) {
- wfDeprecated( __METHOD__, '1.31' );
- return true;
- }
-
/**
* Set the redirect target.
*
"history": "Page history",
"history_short": "History",
"history_small": "history",
- "updatedmarker": "updated since my last visit",
+ "updatedmarker": "updated since your last visit",
"printableversion": "Printable version",
"permalink": "Permanent link",
"print": "Print",
require_once __DIR__ . '/Maintenance.php';
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
}
/**
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
* @param IDatabase $dbw
* @return null|int
*/
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IMaintainableDatabase;
/**
* @param string $name Prefix that is being made a namespace
* @param array $options Associative array of validated command-line options
*
- * @return ResultWrapper
+ * @return IResultWrapper
*/
private function getTargetList( $ns, $name, $options ) {
if (
use MediaWiki\Storage\SqlBlobStore;
use Wikimedia\Assert\Assert;
use Wikimedia\Rdbms\IDatabase;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
require_once __DIR__ . '/Maintenance.php';
}
/**
- * @param ResultWrapper $rows
+ * @param IResultWrapper $rows
* @param int $startId
* @param string $table
* @return int|null
*/
- private function populateContentTablesForRowBatch( ResultWrapper $rows, $startId, $table ) {
+ private function populateContentTablesForRowBatch( IResultWrapper $rows, $startId, $table ) {
$this->beginTransaction( $this->dbw, __METHOD__ );
if ( $this->contentRowMap === null ) {
require_once __DIR__ . '/Maintenance.php';
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
/**
* Maintenance script that sends purge requests for pages edited in a date
*
* @todo move this elsewhere
*
- * @param ResultWrapper $res Query result sorted by $column (ascending)
+ * @param IResultWrapper $res Query result sorted by $column (ascending)
* @param string $column
* @param int $limit
* @return array (array of rows, string column value)
*/
- protected function pageableSortedRows( ResultWrapper $res, $column, $limit ) {
+ protected function pageableSortedRows( IResultWrapper $res, $column, $limit ) {
$rows = iterator_to_array( $res, false );
// Nothing to do
require_once __DIR__ . '/Maintenance.php';
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\DBQueryError;
/**
* Print the results, callback for $db->sourceStream()
- * @param ResultWrapper|bool $res
+ * @param IResultWrapper|bool $res
* @param IDatabase $db
* @return int|null Number of rows selected or updated, or null if the query was unsuccessful.
*/
* @ingroup Maintenance
*/
+use Wikimedia\Rdbms\IMaintainableDatabase;
+
/**
* Look for duplicate user table entries and optionally prune them.
*
* @ingroup Maintenance
*/
class UserDupes {
+ /**
+ * @var IMaintainableDatabase
+ */
private $db;
private $reassigned;
private $trimmed;
private $failed;
private $outputCallback;
- function __construct( &$database, $outputCallback ) {
+ /**
+ * UserDupes constructor.
+ * @param IMaintainableDatabase &$database
+ * @param callback $outputCallback
+ */
+ public function __construct( &$database, $outputCallback ) {
$this->db = $database;
$this->outputCallback = $outputCallback;
}
* user_name index applied.
* @return bool
*/
- function hasUniqueIndex() {
+ public function hasUniqueIndex() {
$info = $this->db->indexInfo( 'user', 'user_name', __METHOD__ );
if ( !$info ) {
$this->out( "WARNING: doesn't seem to have user_name index at all!\n" );
*
* @return bool
*/
- function clearDupes() {
+ public function clearDupes() {
return $this->checkDupes( true );
}
* from the database; false to just check.
* @return bool
*/
- function checkDupes( $doDelete = false ) {
+ private function checkDupes( $doDelete = false ) {
if ( $this->hasUniqueIndex() ) {
echo wfWikiID() . " already has a unique index on its user table.\n";
/**
* We don't want anybody to mess with our stuff...
- * @private
*/
- function lock() {
+ private function lock() {
$set = [ 'user', 'revision' ];
$names = array_map( [ $this, 'lockTable' ], $set );
$tables = implode( ',', $names );
$this->db->query( "LOCK TABLES $tables", __METHOD__ );
}
- function lockTable( $table ) {
+ private function lockTable( $table ) {
return $this->db->tableName( $table ) . ' WRITE';
}
/**
* @private
*/
- function unlock() {
+ private function unlock() {
$this->db->query( "UNLOCK TABLES", __METHOD__ );
}
/**
* Grab usernames for which multiple records are present in the database.
* @return array
- * @private
*/
- function getDupes() {
+ private function getDupes() {
$user = $this->db->tableName( 'user' );
$result = $this->db->query(
"SELECT user_name,COUNT(*) AS n
* for edits. If the dupes have no edits, we can safely remove them.
* @param string $name
* @param bool $doDelete
- * @private
*/
- function examine( $name, $doDelete ) {
+ private function examine( $name, $doDelete ) {
$result = $this->db->select( 'user',
[ 'user_id' ],
[ 'user_name' => $name ],
* where it might show up...
* @param int $userid
* @return int
- * @private
*/
- function editCount( $userid ) {
+ private function editCount( $userid ) {
return intval( $this->db->selectField(
'revision',
'COUNT(*)',
/**
* @param int $from
* @param int $to
- * @private
*/
- function reassignEdits( $from, $to ) {
+ private function reassignEdits( $from, $to ) {
$this->out( 'reassigning... ' );
$this->db->update( 'revision',
[ 'rev_user' => $to ],
/**
* Remove a user account line.
* @param int $userid
- * @private
*/
- function trimAccount( $userid ) {
+ private function trimAccount( $userid ) {
$this->out( "deleting..." );
$this->db->delete( 'user', [ 'user_id' => $userid ], __METHOD__ );
$this->out( " ok" );
//
// Please extend the regex instead of adding new ones!
// And add a test case to startup.test.js
- !ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|Series60|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ )
+ !ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ )
);
}
use MediaWiki\Block\BlockManager;
use MediaWiki\Block\DatabaseBlock;
+use MediaWiki\Block\SystemBlock;
/**
* @group Blocking
],
];
}
+
+ /**
+ * @covers ::getUniqueBlocks
+ */
+ public function testGetUniqueBlocks() {
+ $blockId = 100;
+
+ $class = new ReflectionClass( BlockManager::class );
+ $method = $class->getMethod( 'getUniqueBlocks' );
+ $method->setAccessible( true );
+
+ $blockManager = $this->getBlockManager( [] );
+
+ $block = $this->getMockBuilder( DatabaseBlock::class )
+ ->setMethods( [ 'getId' ] )
+ ->getMock();
+ $block->expects( $this->any() )
+ ->method( 'getId' )
+ ->willReturn( $blockId );
+
+ $autoblock = $this->getMockBuilder( DatabaseBlock::class )
+ ->setMethods( [ 'getParentBlockId', 'getType' ] )
+ ->getMock();
+ $autoblock->expects( $this->any() )
+ ->method( 'getParentBlockId' )
+ ->willReturn( $blockId );
+ $autoblock->expects( $this->any() )
+ ->method( 'getType' )
+ ->willReturn( DatabaseBlock::TYPE_AUTO );
+
+ $blocks = [ $block, $block, $autoblock, new SystemBlock() ];
+
+ $this->assertSame( 2, count( $method->invoke( $blockManager, $blocks ) ) );
+ }
}
* @author Antoine Musso
* @author Niklas Laxström
* @author Santhosh Thottingal
- * @author Timo Tijhof
* @copyright © 2012, Antoine Musso
* @copyright © 2012, Niklas Laxström
* @copyright © 2012, Santhosh Thottingal
- * @copyright © 2012, Timo Tijhof
*/
class ResourcesTest extends MediaWikiTestCase {
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @package MediaWiki
* @author Lupo
- * @since 1.20
*/
// This file doesn't run as part of MediaWiki
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @package MediaWiki
- * @author Timo Tijhof
- * @since 1.20
*/
// This file doesn't run as part of MediaWiki