'InfoAction' => __DIR__ . '/includes/actions/InfoAction.php',
'InitEditCount' => __DIR__ . '/maintenance/initEditCount.php',
'InitSiteStats' => __DIR__ . '/maintenance/initSiteStats.php',
+ 'InitUserPreference' => __DIR__ . '/maintenance/initUserPreference.php',
'InstallDocFormatter' => __DIR__ . '/includes/installer/InstallDocFormatter.php',
'Installer' => __DIR__ . '/includes/installer/Installer.php',
'InstallerOverrides' => __DIR__ . '/includes/installer/InstallerOverrides.php',
'MovePage' => __DIR__ . '/includes/MovePage.php',
'MovePageForm' => __DIR__ . '/includes/specials/SpecialMovepage.php',
'MssqlInstaller' => __DIR__ . '/includes/installer/MssqlInstaller.php',
- 'MssqlResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php',
'MssqlUpdater' => __DIR__ . '/includes/installer/MssqlUpdater.php',
'MultiConfig' => __DIR__ . '/includes/config/MultiConfig.php',
'MultiHttpClient' => __DIR__ . '/includes/libs/MultiHttpClient.php',
'Protect' => __DIR__ . '/maintenance/protect.php',
'ProtectAction' => __DIR__ . '/includes/actions/ProtectAction.php',
'ProtectLogFormatter' => __DIR__ . '/includes/logging/ProtectLogFormatter.php',
- 'ProtectedPagesPager' => __DIR__ . '/includes/specials/SpecialProtectedpages.php',
+ 'ProtectedPagesPager' => __DIR__ . '/includes/specials/pagers/ProtectedPagesPager.php',
'ProtectedTitlesPager' => __DIR__ . '/includes/specials/pagers/ProtectedTitlesPager.php',
'ProtectionForm' => __DIR__ . '/includes/ProtectionForm.php',
'ProxyLookup' => __DIR__ . '/includes/ProxyLookup.php',
'Wikimedia\\Rdbms\\ConnectionManager' => __DIR__ . '/includes/libs/rdbms/connectionmanager/ConnectionManager.php',
'Wikimedia\\Rdbms\\DBMasterPos' => __DIR__ . '/includes/libs/rdbms/database/position/DBMasterPos.php',
'Wikimedia\\Rdbms\\DatabaseDomain' => __DIR__ . '/includes/libs/rdbms/database/DatabaseDomain.php',
+ 'Wikimedia\\Rdbms\\FakeResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php',
'Wikimedia\\Rdbms\\Field' => __DIR__ . '/includes/libs/rdbms/field/Field.php',
'Wikimedia\\Rdbms\\IBlob' => __DIR__ . '/includes/libs/rdbms/encasing/IBlob.php',
'Wikimedia\\Rdbms\\ILBFactory' => __DIR__ . '/includes/libs/rdbms/lbfactory/ILBFactory.php',
'Wikimedia\\Rdbms\\LoadMonitorNull' => __DIR__ . '/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php',
'Wikimedia\\Rdbms\\MssqlBlob' => __DIR__ . '/includes/libs/rdbms/encasing/MssqlBlob.php',
'Wikimedia\\Rdbms\\MssqlField' => __DIR__ . '/includes/libs/rdbms/field/MssqlField.php',
+ 'Wikimedia\\Rdbms\\MssqlResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php',
'Wikimedia\\Rdbms\\MySQLField' => __DIR__ . '/includes/libs/rdbms/field/MySQLField.php',
'Wikimedia\\Rdbms\\MySQLMasterPos' => __DIR__ . '/includes/libs/rdbms/database/position/MySQLMasterPos.php',
'Wikimedia\\Rdbms\\PostgresBlob' => __DIR__ . '/includes/libs/rdbms/encasing/PostgresBlob.php',
'Wikimedia\\Rdbms\\PostgresField' => __DIR__ . '/includes/libs/rdbms/field/PostgresField.php',
+ 'Wikimedia\\Rdbms\\ResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php',
'Wikimedia\\Rdbms\\SQLiteField' => __DIR__ . '/includes/libs/rdbms/field/SQLiteField.php',
'Wikimedia\\Rdbms\\SessionConsistentConnectionManager' => __DIR__ . '/includes/libs/rdbms/connectionmanager/SessionConsistentConnectionManager.php',
'Wikimedia\\Rdbms\\TransactionProfiler' => __DIR__ . '/includes/libs/rdbms/TransactionProfiler.php',
/**
* An array of preferences to not show for the user
*/
-$wgHiddenPrefs = [
- 'rcenhancedfilters',
-];
+$wgHiddenPrefs = [];
/**
* Characters to prevent during new account creations.
*/
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\FakeResultWrapper;
/**
* @todo document
*
* @param Title $title
* @param int $id
+ * @param int $flags
* @return string|bool False if not found
*/
static function getTimestampFromId( $title, $id, $flags = 0 ) {
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* List for revision table items for a single page
* @file
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* The TitleArray class only exists to provide the newFromResult method at pre-
* sent.
* @file
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
class TitleArrayFromResult extends TitleArray implements Countable {
/** @var ResultWrapper */
public $res;
<?php
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Extension mechanism for WatchedItemQueryService
*
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\FakeResultWrapper;
/**
* This class handles printing the history page for an article. In order to
* @file
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* This class contains a list of pages that the client has requested.
private $mMissingPageIDs = [];
private $mRedirectTitles = [];
private $mSpecialTitles = [];
+ private $mAllSpecials = []; // separate from mAllPages to avoid breaking getAllTitlesByNamespace()
private $mNormalizedTitles = [];
private $mInterwikiTitles = [];
/** @var Title[] */
* @return LinkBatch
*/
private function getRedirectTargets() {
- $lb = new LinkBatch();
+ $titlesToResolve = [];
$db = $this->getDB();
$res = $db->select(
unset( $this->mPendingRedirectIDs[$rdfrom] );
if ( $to->isExternal() ) {
$this->mInterwikiTitles[$to->getPrefixedText()] = $to->getInterwiki();
- } elseif ( !isset( $this->mAllPages[$row->rd_namespace][$row->rd_title] ) ) {
- $lb->add( $row->rd_namespace, $row->rd_title );
+ } elseif ( !isset( $this->mAllPages[$to->getNamespace()][$to->getDBkey()] ) ) {
+ $titlesToResolve[] = $to;
}
$this->mRedirectTitles[$from] = $to;
}
// What the hell. Let's just ignore this
continue;
}
- $lb->addObj( $rt );
+ if ( $rt->isExternal() ) {
+ $this->mInterwikiTitles[$rt->getPrefixedText()] = $rt->getInterwiki();
+ } elseif ( !isset( $this->mAllPages[$rt->getNamespace()][$rt->getDBkey()] ) ) {
+ $titlesToResolve[] = $rt;
+ }
$from = $title->getPrefixedText();
$this->mResolvedRedirectTitles[$from] = $title;
$this->mRedirectTitles[$from] = $rt;
}
}
- return $lb;
+ return $this->processTitlesArray( $titlesToResolve );
}
/**
$titleObj = Title::newFromTextThrow( $title, $this->mDefaultNamespace );
} catch ( MalformedTitleException $ex ) {
// Handle invalid titles gracefully
- $this->mAllPages[0][$title] = $this->mFakePageId;
- $this->mInvalidTitles[$this->mFakePageId] = [
- 'title' => $title,
- 'invalidreason' => $this->getErrorFormatter()->formatException( $ex, [ 'bc' => true ] ),
- ];
- $this->mFakePageId--;
+ if ( !isset( $this->mAllPages[0][$title] ) ) {
+ $this->mAllPages[0][$title] = $this->mFakePageId;
+ $this->mInvalidTitles[$this->mFakePageId] = [
+ 'title' => $title,
+ 'invalidreason' => $this->getErrorFormatter()->formatException( $ex, [ 'bc' => true ] ),
+ ];
+ $this->mFakePageId--;
+ }
continue; // There's nothing else we can do
}
} else {
if ( $titleObj->getNamespace() < 0 ) {
// Handle Special and Media pages
$titleObj = $titleObj->fixSpecialName();
- $this->mSpecialTitles[$this->mFakePageId] = $titleObj;
- $this->mFakePageId--;
+ $ns = $titleObj->getNamespace();
+ $dbkey = $titleObj->getDBkey();
+ if ( !isset( $this->mAllSpecials[$ns][$dbkey] ) ) {
+ $this->mAllSpecials[$ns][$dbkey] = $this->mFakePageId;
+ $this->mSpecialTitles[$this->mFakePageId] = $titleObj;
+ $this->mFakePageId--;
+ }
} else {
// Regular page
$linkBatch->addObj( $titleObj );
* @file
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* This is a base class for all Query modules.
* It provides some common functionality such as constructing various SQL
* @copyright © 2011, Antoine Musso
*/
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\FakeResultWrapper;
+
/**
* Class for fetching backlink lists, approximate backlink counts and
* partitions. This is a shared cache.
*/
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* Class representing a list of titles
* @file
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Feed to Special:RecentChanges and Special:RecentChangesLiked
*
*/
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
class ChangesList extends ContextSource {
/**
* @ingroup Database
*/
use Wikimedia\Rdbms\Blob;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* @ingroup Database
return count( self::$preSendUpdates ) + count( self::$postSendUpdates );
}
+ /**
+ * @param integer $stage DeferredUpdates constant (PRESEND, POSTSEND, or ALL)
+ * @since 1.29
+ */
+ public static function getPendingUpdates( $stage = self::ALL ) {
+ $updates = [];
+ if ( $stage === self::ALL || $stage === self::PRESEND ) {
+ $updates = array_merge( $updates, self::$preSendUpdates );
+ }
+ if ( $stage === self::ALL || $stage === self::POSTSEND ) {
+ $updates = array_merge( $updates, self::$postSendUpdates );
+ }
+ return $updates;
+ }
+
/**
* Clear all pending updates without performing them. Generally, you don't
* want or need to call this. Unit tests need it though.
* @defgroup Dump Dump
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* @ingroup SpecialPage Dump
*/
* @ingroup FileRepo
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A repository that stores files in the local filesystem and registers them
* in the wiki's own database. This is the most commonly used repository class.
use Wikimedia\Rdbms\TransactionProfiler;
use Wikimedia\Rdbms\LikeMatch;
use Wikimedia\Rdbms\DatabaseDomain;
+use Wikimedia\Rdbms\ResultWrapper;
use Wikimedia\Rdbms\DBMasterPos;
use Wikimedia\Rdbms\Blob;
use Wikimedia\Timestamp\ConvertibleTimestamp;
use Wikimedia\Rdbms\Blob;
use Wikimedia\Rdbms\MssqlBlob;
use Wikimedia\Rdbms\MssqlField;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\MssqlResultWrapper;
/**
* @ingroup Database
use Wikimedia\Rdbms\DBMasterPos;
use Wikimedia\Rdbms\MySQLMasterPos;
use Wikimedia\Rdbms\MySQLField;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* Database abstraction object for MySQL.
* @ingroup Database
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Database abstraction object for PHP extension mysqli.
*
use Wikimedia\Rdbms\Blob;
use Wikimedia\Rdbms\PostgresBlob;
use Wikimedia\Rdbms\PostgresField;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* @ingroup Database
*/
use Wikimedia\Rdbms\Blob;
use Wikimedia\Rdbms\SQLiteField;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* @ingroup Database
use Wikimedia\Rdbms\LikeMatch;
use Wikimedia\Rdbms\DBMasterPos;
use Wikimedia\Rdbms\Field;
+use Wikimedia\Rdbms\IResultWrapper;
/**
* Basic database interface for live and lazy-loaded relation database handles
* member variables.
* If no more rows are available, false is returned.
*
- * @param ResultWrapper|stdClass $res Object as returned from IDatabase::query(), etc.
+ * @param IResultWrapper|stdClass $res Object as returned from IDatabase::query(), etc.
* @return stdClass|bool
* @throws DBUnexpectedError Thrown if the database returns an error
*/
* form. Fields are retrieved with $row['fieldname'].
* If no more rows are available, false is returned.
*
- * @param ResultWrapper $res Result object as returned from IDatabase::query(), etc.
+ * @param IResultWrapper $res Result object as returned from IDatabase::query(), etc.
* @return array|bool
* @throws DBUnexpectedError Thrown if the database returns an error
*/
* @param bool $tempIgnore Whether to avoid throwing an exception on errors...
* maybe best to catch the exception instead?
* @throws DBError
- * @return bool|ResultWrapper True for a successful write query, ResultWrapper object
+ * @return bool|IResultWrapper True for a successful write query, IResultWrapper object
* for a successful read query, or false on failure if $tempIgnore set
*/
public function query( $sql, $fname = __METHOD__, $tempIgnore = false );
*
* [ 'page' => [ 'LEFT JOIN', 'page_latest=rev_id' ] ]
*
- * @return ResultWrapper|bool If the query returned no rows, a ResultWrapper
+ * @return IResultWrapper|bool If the query returned no rows, a IResultWrapper
* with no rows in it will be returned. If there was a query error, a
* DBQueryError exception will be thrown, except if the "ignore errors"
* option was set, in which case false will be returned.
* for the format. Use $conds == "*" to delete all rows
* @param string $fname Name of the calling function
* @throws DBUnexpectedError
- * @return bool|ResultWrapper
+ * @return bool|IResultWrapper
*/
public function delete( $table, $conds, $fname = __METHOD__ );
* @param array $selectOptions Options for the SELECT part of the query, see
* IDatabase::select() for details.
*
- * @return ResultWrapper
+ * @return IResultWrapper
*/
public function insertSelect( $destTable, $srcTable, $varMap, $conds,
$fname = __METHOD__,
<?php
+
+namespace Wikimedia\Rdbms;
+
+use stdClass;
+
/**
* Overloads the relevant methods of the real ResultsWrapper so it
* doesn't go anywhere near an actual database.
return $this->fetchObject();
}
}
+
+class_alias( FakeResultWrapper::class, 'FakeResultWrapper' );
+
<?php
+
+namespace Wikimedia\Rdbms;
+
+use stdClass;
+
class MssqlResultWrapper extends ResultWrapper {
/** @var integer|null */
private $mSeekTo = null;
<?php
-use Wikimedia\Rdbms\IResultWrapper;
+namespace Wikimedia\Rdbms;
+
+use IDatabase;
+use stdClass;
+use RuntimeException;
/**
* Result wrapper for grabbing data queried from an IDatabase object
return $this->current() !== false;
}
}
+
+class_alias( ResultWrapper::class, 'ResultWrapper' );
* @file
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Class for viewing MediaWiki file description pages
*
* @file
*/
+use Wikimedia\Rdbms\FakeResultWrapper;
+
/**
* Special handling for file pages
*
use \MediaWiki\Logger\LoggerFactory;
use \MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\FakeResultWrapper;
/**
* Class representing a MediaWiki article and history.
* @ingroup Pager
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* IndexPager is an efficient pager which uses a (roughly unique) index in the
* data set to implement paging, rather than a "LIMIT offset,limit" clause.
* @ingroup RevisionDelete
*/
+use Wikimedia\Rdbms\FakeResultWrapper;
+
/**
* List for revision table items
*
<?php
+
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* This class is used for different SQL-based search engines shipped with MediaWiki
* @ingroup Search
* @ingroup SpecialPage
*/
use MediaWiki\Logger\LoggerFactory;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* Special page which uses a ChangesList to show query results.
* @ingroup SpecialPage
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Variant of QueryPage which uses a gallery to output results, thus
* suited for reports generating images
* @ingroup SpecialPage
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Variant of QueryPage which formats the result as a simple link to the page
*
* @ingroup SpecialPage
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* This is a class for doing query pages; since they're almost all the same,
* we factor out some of the functionality into a superclass, and let
* @ingroup SpecialPage
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Class definition for a wanted query page like
* WantedPages, WantedTemplates, etc
* @ingroup SpecialPage
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A special page listing redirects to non existent page. Those should be
* fixed to point to an existing page.
* @ingroup SpecialPage
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A special page listing redirects to redirecting page.
* The software will automatically not follow double redirects, to prevent loops.
* @author Brion Vibber
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Special:LinkSearch to search the external-links table.
* @ingroup SpecialPage
* @author Brian Wolff
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Special:ListDuplicatedFiles Lists all files where the current version is
* a duplicate of the current version of some other file.
* @author Rob Church <robchur@gmail.com>
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Special:Listredirects - Lists all the redirects on the wiki.
* @ingroup SpecialPage
* @author Brian Wolff
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* @ingroup SpecialPage
*/
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A special page that list pages that have highest category count
*
* @author Umherirrender
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A special page that listed pages that have highest interwiki count
*
* @author Rob Church <robchur@gmail.com>
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A special page to show pages ordered by the number of pages linking to them.
*
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A querypage to show categories ordered in descending order by the pages in them
*
* @author Rob Church <robchur@gmail.com>
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Special page lists templates with a large number of
* transclusion links, i.e. "most used" templates
* @ingroup SpecialPage
*/
-use MediaWiki\Linker\LinkRenderer;
-
/**
* A special page that lists protected pages
*
return 'maintenance';
}
}
-
-/**
- * @todo document
- * @ingroup Pager
- */
-class ProtectedPagesPager extends TablePager {
- public $mForm, $mConds;
- private $type, $level, $namespace, $sizetype, $size, $indefonly, $cascadeonly, $noredirect;
-
- /**
- * @var LinkRenderer
- */
- private $linkRenderer;
-
- /**
- * @param SpecialProtectedpages $form
- * @param array $conds
- * @param $type
- * @param $level
- * @param $namespace
- * @param string $sizetype
- * @param int $size
- * @param bool $indefonly
- * @param bool $cascadeonly
- * @param bool $noredirect
- * @param LinkRenderer $linkRenderer
- */
- function __construct( $form, $conds = [], $type, $level, $namespace,
- $sizetype = '', $size = 0, $indefonly = false, $cascadeonly = false, $noredirect = false,
- LinkRenderer $linkRenderer
- ) {
- $this->mForm = $form;
- $this->mConds = $conds;
- $this->type = ( $type ) ? $type : 'edit';
- $this->level = $level;
- $this->namespace = $namespace;
- $this->sizetype = $sizetype;
- $this->size = intval( $size );
- $this->indefonly = (bool)$indefonly;
- $this->cascadeonly = (bool)$cascadeonly;
- $this->noredirect = (bool)$noredirect;
- $this->linkRenderer = $linkRenderer;
- parent::__construct( $form->getContext() );
- }
-
- function preprocessResults( $result ) {
- # Do a link batch query
- $lb = new LinkBatch;
- $userids = [];
-
- foreach ( $result as $row ) {
- $lb->add( $row->page_namespace, $row->page_title );
- // field is nullable, maybe null on old protections
- if ( $row->log_user !== null ) {
- $userids[] = $row->log_user;
- }
- }
-
- // fill LinkBatch with user page and user talk
- if ( count( $userids ) ) {
- $userCache = UserCache::singleton();
- $userCache->doQuery( $userids, [], __METHOD__ );
- foreach ( $userids as $userid ) {
- $name = $userCache->getProp( $userid, 'name' );
- if ( $name !== false ) {
- $lb->add( NS_USER, $name );
- $lb->add( NS_USER_TALK, $name );
- }
- }
- }
-
- $lb->execute();
- }
-
- function getFieldNames() {
- static $headers = null;
-
- if ( $headers == [] ) {
- $headers = [
- 'log_timestamp' => 'protectedpages-timestamp',
- 'pr_page' => 'protectedpages-page',
- 'pr_expiry' => 'protectedpages-expiry',
- 'log_user' => 'protectedpages-performer',
- 'pr_params' => 'protectedpages-params',
- 'log_comment' => 'protectedpages-reason',
- ];
- foreach ( $headers as $key => $val ) {
- $headers[$key] = $this->msg( $val )->text();
- }
- }
-
- return $headers;
- }
-
- /**
- * @param string $field
- * @param string $value
- * @return string HTML
- * @throws MWException
- */
- function formatValue( $field, $value ) {
- /** @var $row object */
- $row = $this->mCurrentRow;
-
- switch ( $field ) {
- case 'log_timestamp':
- // when timestamp is null, this is a old protection row
- if ( $value === null ) {
- $formatted = Html::rawElement(
- 'span',
- [ 'class' => 'mw-protectedpages-unknown' ],
- $this->msg( 'protectedpages-unknown-timestamp' )->escaped()
- );
- } else {
- $formatted = htmlspecialchars( $this->getLanguage()->userTimeAndDate(
- $value, $this->getUser() ) );
- }
- break;
-
- case 'pr_page':
- $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- if ( !$title ) {
- $formatted = Html::element(
- 'span',
- [ 'class' => 'mw-invalidtitle' ],
- Linker::getInvalidTitleDescription(
- $this->getContext(),
- $row->page_namespace,
- $row->page_title
- )
- );
- } else {
- $formatted = $this->linkRenderer->makeLink( $title );
- }
- if ( !is_null( $row->page_len ) ) {
- $formatted .= $this->getLanguage()->getDirMark() .
- ' ' . Html::rawElement(
- 'span',
- [ 'class' => 'mw-protectedpages-length' ],
- Linker::formatRevisionSize( $row->page_len )
- );
- }
- break;
-
- case 'pr_expiry':
- $formatted = htmlspecialchars( $this->getLanguage()->formatExpiry(
- $value, /* User preference timezone */true ) );
- $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- if ( $this->getUser()->isAllowed( 'protect' ) && $title ) {
- $changeProtection = $this->linkRenderer->makeKnownLink(
- $title,
- $this->msg( 'protect_change' )->text(),
- [],
- [ 'action' => 'unprotect' ]
- );
- $formatted .= ' ' . Html::rawElement(
- 'span',
- [ 'class' => 'mw-protectedpages-actions' ],
- $this->msg( 'parentheses' )->rawParams( $changeProtection )->escaped()
- );
- }
- break;
-
- case 'log_user':
- // when timestamp is null, this is a old protection row
- if ( $row->log_timestamp === null ) {
- $formatted = Html::rawElement(
- 'span',
- [ 'class' => 'mw-protectedpages-unknown' ],
- $this->msg( 'protectedpages-unknown-performer' )->escaped()
- );
- } else {
- $username = UserCache::singleton()->getProp( $value, 'name' );
- if ( LogEventsList::userCanBitfield(
- $row->log_deleted,
- LogPage::DELETED_USER,
- $this->getUser()
- ) ) {
- if ( $username === false ) {
- $formatted = htmlspecialchars( $value );
- } else {
- $formatted = Linker::userLink( $value, $username )
- . Linker::userToolLinks( $value, $username );
- }
- } else {
- $formatted = $this->msg( 'rev-deleted-user' )->escaped();
- }
- if ( LogEventsList::isDeleted( $row, LogPage::DELETED_USER ) ) {
- $formatted = '<span class="history-deleted">' . $formatted . '</span>';
- }
- }
- break;
-
- case 'pr_params':
- $params = [];
- // Messages: restriction-level-sysop, restriction-level-autoconfirmed
- $params[] = $this->msg( 'restriction-level-' . $row->pr_level )->escaped();
- if ( $row->pr_cascade ) {
- $params[] = $this->msg( 'protect-summary-cascade' )->escaped();
- }
- $formatted = $this->getLanguage()->commaList( $params );
- break;
-
- case 'log_comment':
- // when timestamp is null, this is an old protection row
- if ( $row->log_timestamp === null ) {
- $formatted = Html::rawElement(
- 'span',
- [ 'class' => 'mw-protectedpages-unknown' ],
- $this->msg( 'protectedpages-unknown-reason' )->escaped()
- );
- } else {
- if ( LogEventsList::userCanBitfield(
- $row->log_deleted,
- LogPage::DELETED_COMMENT,
- $this->getUser()
- ) ) {
- $formatted = Linker::formatComment( $value !== null ? $value : '' );
- } else {
- $formatted = $this->msg( 'rev-deleted-comment' )->escaped();
- }
- if ( LogEventsList::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
- $formatted = '<span class="history-deleted">' . $formatted . '</span>';
- }
- }
- break;
-
- default:
- throw new MWException( "Unknown field '$field'" );
- }
-
- return $formatted;
- }
-
- function getQueryInfo() {
- $conds = $this->mConds;
- $conds[] = 'pr_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) .
- ' OR pr_expiry IS NULL';
- $conds[] = 'page_id=pr_page';
- $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type );
-
- if ( $this->sizetype == 'min' ) {
- $conds[] = 'page_len>=' . $this->size;
- } elseif ( $this->sizetype == 'max' ) {
- $conds[] = 'page_len<=' . $this->size;
- }
-
- if ( $this->indefonly ) {
- $infinity = $this->mDb->addQuotes( $this->mDb->getInfinity() );
- $conds[] = "pr_expiry = $infinity OR pr_expiry IS NULL";
- }
- if ( $this->cascadeonly ) {
- $conds[] = 'pr_cascade = 1';
- }
- if ( $this->noredirect ) {
- $conds[] = 'page_is_redirect = 0';
- }
-
- if ( $this->level ) {
- $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
- }
- if ( !is_null( $this->namespace ) ) {
- $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace );
- }
-
- return [
- 'tables' => [ 'page', 'page_restrictions', 'log_search', 'logging' ],
- 'fields' => [
- 'pr_id',
- 'page_namespace',
- 'page_title',
- 'page_len',
- 'pr_type',
- 'pr_level',
- 'pr_expiry',
- 'pr_cascade',
- 'log_timestamp',
- 'log_user',
- 'log_comment',
- 'log_deleted',
- ],
- 'conds' => $conds,
- 'join_conds' => [
- 'log_search' => [
- 'LEFT JOIN', [
- 'ls_field' => 'pr_id', 'ls_value = ' . $this->mDb->buildStringCast( 'pr_id' )
- ]
- ],
- 'logging' => [
- 'LEFT JOIN', [
- 'ls_log_id = log_id'
- ]
- ]
- ]
- ];
- }
-
- protected function getTableClass() {
- return parent::getTableClass() . ' mw-protectedpages';
- }
-
- function getIndexField() {
- return 'pr_id';
- }
-
- function getDefaultSort() {
- return 'pr_id';
- }
-
- function isFieldSortable( $field ) {
- // no index for sorting exists
- return false;
- }
-}
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* A special page that lists last changes made to the wiki
$panelString = implode( "\n", $panel );
// Insert a placeholder for RCFilters
- if ( $this->getUser()->getOption(
- 'rcenhancedfilters',
- /*default=*/ null,
- /*ignoreHidden=*/ true
- )
- ) {
+ if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
$this->getOutput()->addHTML(
Html::element(
'div',
parent::addModules();
$out = $this->getOutput();
$out->addModules( 'mediawiki.special.recentchanges' );
- if ( $this->getUser()->getOption(
- 'rcenhancedfilters',
- /*default=*/ null,
- /*ignoreHidden=*/ true
- )
- ) {
+ if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
$out->addModules( 'mediawiki.rcfilters.filters.ui' );
$out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
}
* @ingroup SpecialPage
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* SpecialShortpages extends QueryPage. It is used to return the shortest
* pages in the database.
* @ingroup SpecialPage
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* Used to show archived pages and eventually restore them.
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* A special page that displays a list of pages that are not on anyones watchlist.
*
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
/**
* A special page that lists last changes made to the wiki,
* @ingroup Pager
*/
+use Wikimedia\Rdbms\FakeResultWrapper;
+
/**
* Use TablePager for prettified output. We have to pretend that we're
* getting data from a table when in fact not all of it comes from the database.
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
class BlockListPager extends TablePager {
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\FakeResultWrapper;
class ContribsPager extends ReverseChronologicalPager {
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\FakeResultWrapper;
class DeletedContribsPager extends IndexPager {
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\FakeResultWrapper;
class ImageListPager extends TablePager {
--- /dev/null
+<?php
+/**
+ * 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
+ * @ingroup Pager
+ */
+
+use \MediaWiki\Linker\LinkRenderer;
+
+/**
+ * @todo document
+ */
+class ProtectedPagesPager extends TablePager {
+ public $mForm, $mConds;
+ private $type, $level, $namespace, $sizetype, $size, $indefonly, $cascadeonly, $noredirect;
+
+ /**
+ * @var LinkRenderer
+ */
+ private $linkRenderer;
+
+ /**
+ * @param SpecialProtectedpages $form
+ * @param array $conds
+ * @param $type
+ * @param $level
+ * @param $namespace
+ * @param string $sizetype
+ * @param int $size
+ * @param bool $indefonly
+ * @param bool $cascadeonly
+ * @param bool $noredirect
+ * @param LinkRenderer $linkRenderer
+ */
+ function __construct( $form, $conds = [], $type, $level, $namespace,
+ $sizetype = '', $size = 0, $indefonly = false, $cascadeonly = false, $noredirect = false,
+ LinkRenderer $linkRenderer
+ ) {
+ $this->mForm = $form;
+ $this->mConds = $conds;
+ $this->type = ( $type ) ? $type : 'edit';
+ $this->level = $level;
+ $this->namespace = $namespace;
+ $this->sizetype = $sizetype;
+ $this->size = intval( $size );
+ $this->indefonly = (bool)$indefonly;
+ $this->cascadeonly = (bool)$cascadeonly;
+ $this->noredirect = (bool)$noredirect;
+ $this->linkRenderer = $linkRenderer;
+ parent::__construct( $form->getContext() );
+ }
+
+ function preprocessResults( $result ) {
+ # Do a link batch query
+ $lb = new LinkBatch;
+ $userids = [];
+
+ foreach ( $result as $row ) {
+ $lb->add( $row->page_namespace, $row->page_title );
+ // field is nullable, maybe null on old protections
+ if ( $row->log_user !== null ) {
+ $userids[] = $row->log_user;
+ }
+ }
+
+ // fill LinkBatch with user page and user talk
+ if ( count( $userids ) ) {
+ $userCache = UserCache::singleton();
+ $userCache->doQuery( $userids, [], __METHOD__ );
+ foreach ( $userids as $userid ) {
+ $name = $userCache->getProp( $userid, 'name' );
+ if ( $name !== false ) {
+ $lb->add( NS_USER, $name );
+ $lb->add( NS_USER_TALK, $name );
+ }
+ }
+ }
+
+ $lb->execute();
+ }
+
+ function getFieldNames() {
+ static $headers = null;
+
+ if ( $headers == [] ) {
+ $headers = [
+ 'log_timestamp' => 'protectedpages-timestamp',
+ 'pr_page' => 'protectedpages-page',
+ 'pr_expiry' => 'protectedpages-expiry',
+ 'log_user' => 'protectedpages-performer',
+ 'pr_params' => 'protectedpages-params',
+ 'log_comment' => 'protectedpages-reason',
+ ];
+ foreach ( $headers as $key => $val ) {
+ $headers[$key] = $this->msg( $val )->text();
+ }
+ }
+
+ return $headers;
+ }
+
+ /**
+ * @param string $field
+ * @param string $value
+ * @return string HTML
+ * @throws MWException
+ */
+ function formatValue( $field, $value ) {
+ /** @var $row object */
+ $row = $this->mCurrentRow;
+
+ switch ( $field ) {
+ case 'log_timestamp':
+ // when timestamp is null, this is a old protection row
+ if ( $value === null ) {
+ $formatted = Html::rawElement(
+ 'span',
+ [ 'class' => 'mw-protectedpages-unknown' ],
+ $this->msg( 'protectedpages-unknown-timestamp' )->escaped()
+ );
+ } else {
+ $formatted = htmlspecialchars( $this->getLanguage()->userTimeAndDate(
+ $value, $this->getUser() ) );
+ }
+ break;
+
+ case 'pr_page':
+ $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
+ if ( !$title ) {
+ $formatted = Html::element(
+ 'span',
+ [ 'class' => 'mw-invalidtitle' ],
+ Linker::getInvalidTitleDescription(
+ $this->getContext(),
+ $row->page_namespace,
+ $row->page_title
+ )
+ );
+ } else {
+ $formatted = $this->linkRenderer->makeLink( $title );
+ }
+ if ( !is_null( $row->page_len ) ) {
+ $formatted .= $this->getLanguage()->getDirMark() .
+ ' ' . Html::rawElement(
+ 'span',
+ [ 'class' => 'mw-protectedpages-length' ],
+ Linker::formatRevisionSize( $row->page_len )
+ );
+ }
+ break;
+
+ case 'pr_expiry':
+ $formatted = htmlspecialchars( $this->getLanguage()->formatExpiry(
+ $value, /* User preference timezone */true ) );
+ $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
+ if ( $this->getUser()->isAllowed( 'protect' ) && $title ) {
+ $changeProtection = $this->linkRenderer->makeKnownLink(
+ $title,
+ $this->msg( 'protect_change' )->text(),
+ [],
+ [ 'action' => 'unprotect' ]
+ );
+ $formatted .= ' ' . Html::rawElement(
+ 'span',
+ [ 'class' => 'mw-protectedpages-actions' ],
+ $this->msg( 'parentheses' )->rawParams( $changeProtection )->escaped()
+ );
+ }
+ break;
+
+ case 'log_user':
+ // when timestamp is null, this is a old protection row
+ if ( $row->log_timestamp === null ) {
+ $formatted = Html::rawElement(
+ 'span',
+ [ 'class' => 'mw-protectedpages-unknown' ],
+ $this->msg( 'protectedpages-unknown-performer' )->escaped()
+ );
+ } else {
+ $username = UserCache::singleton()->getProp( $value, 'name' );
+ if ( LogEventsList::userCanBitfield(
+ $row->log_deleted,
+ LogPage::DELETED_USER,
+ $this->getUser()
+ ) ) {
+ if ( $username === false ) {
+ $formatted = htmlspecialchars( $value );
+ } else {
+ $formatted = Linker::userLink( $value, $username )
+ . Linker::userToolLinks( $value, $username );
+ }
+ } else {
+ $formatted = $this->msg( 'rev-deleted-user' )->escaped();
+ }
+ if ( LogEventsList::isDeleted( $row, LogPage::DELETED_USER ) ) {
+ $formatted = '<span class="history-deleted">' . $formatted . '</span>';
+ }
+ }
+ break;
+
+ case 'pr_params':
+ $params = [];
+ // Messages: restriction-level-sysop, restriction-level-autoconfirmed
+ $params[] = $this->msg( 'restriction-level-' . $row->pr_level )->escaped();
+ if ( $row->pr_cascade ) {
+ $params[] = $this->msg( 'protect-summary-cascade' )->escaped();
+ }
+ $formatted = $this->getLanguage()->commaList( $params );
+ break;
+
+ case 'log_comment':
+ // when timestamp is null, this is an old protection row
+ if ( $row->log_timestamp === null ) {
+ $formatted = Html::rawElement(
+ 'span',
+ [ 'class' => 'mw-protectedpages-unknown' ],
+ $this->msg( 'protectedpages-unknown-reason' )->escaped()
+ );
+ } else {
+ if ( LogEventsList::userCanBitfield(
+ $row->log_deleted,
+ LogPage::DELETED_COMMENT,
+ $this->getUser()
+ ) ) {
+ $formatted = Linker::formatComment( $value !== null ? $value : '' );
+ } else {
+ $formatted = $this->msg( 'rev-deleted-comment' )->escaped();
+ }
+ if ( LogEventsList::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
+ $formatted = '<span class="history-deleted">' . $formatted . '</span>';
+ }
+ }
+ break;
+
+ default:
+ throw new MWException( "Unknown field '$field'" );
+ }
+
+ return $formatted;
+ }
+
+ function getQueryInfo() {
+ $conds = $this->mConds;
+ $conds[] = 'pr_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) .
+ ' OR pr_expiry IS NULL';
+ $conds[] = 'page_id=pr_page';
+ $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type );
+
+ if ( $this->sizetype == 'min' ) {
+ $conds[] = 'page_len>=' . $this->size;
+ } elseif ( $this->sizetype == 'max' ) {
+ $conds[] = 'page_len<=' . $this->size;
+ }
+
+ if ( $this->indefonly ) {
+ $infinity = $this->mDb->addQuotes( $this->mDb->getInfinity() );
+ $conds[] = "pr_expiry = $infinity OR pr_expiry IS NULL";
+ }
+ if ( $this->cascadeonly ) {
+ $conds[] = 'pr_cascade = 1';
+ }
+ if ( $this->noredirect ) {
+ $conds[] = 'page_is_redirect = 0';
+ }
+
+ if ( $this->level ) {
+ $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
+ }
+ if ( !is_null( $this->namespace ) ) {
+ $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace );
+ }
+
+ return [
+ 'tables' => [ 'page', 'page_restrictions', 'log_search', 'logging' ],
+ 'fields' => [
+ 'pr_id',
+ 'page_namespace',
+ 'page_title',
+ 'page_len',
+ 'pr_type',
+ 'pr_level',
+ 'pr_expiry',
+ 'pr_cascade',
+ 'log_timestamp',
+ 'log_user',
+ 'log_comment',
+ 'log_deleted',
+ ],
+ 'conds' => $conds,
+ 'join_conds' => [
+ 'log_search' => [
+ 'LEFT JOIN', [
+ 'ls_field' => 'pr_id', 'ls_value = ' . $this->mDb->buildStringCast( 'pr_id' )
+ ]
+ ],
+ 'logging' => [
+ 'LEFT JOIN', [
+ 'ls_log_id = log_id'
+ ]
+ ]
+ ]
+ ];
+ }
+
+ protected function getTableClass() {
+ return parent::getTableClass() . ' mw-protectedpages';
+ }
+
+ function getIndexField() {
+ return 'pr_id';
+ }
+
+ function getDefaultSort() {
+ return 'pr_id';
+ }
+
+ function isFieldSortable( $field ) {
+ // no index for sorting exists
+ return false;
+ }
+}
* @file
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
abstract class UserArray implements Iterator {
/**
* @param ResultWrapper $res
/**
* @param array $ids
- * @return UserArrayFromResult
+ * @return UserArrayFromResult|ArrayIterator
*/
static function newFromIDs( $ids ) {
$ids = array_map( 'intval', (array)$ids ); // paranoia
/**
* @since 1.25
* @param array $names
- * @return UserArrayFromResult
+ * @return UserArrayFromResult|ArrayIterator
*/
static function newFromNames( $names ) {
$names = array_map( 'strval', (array)$names ); // paranoia
* @file
*/
+use Wikimedia\Rdbms\ResultWrapper;
+
class UserArrayFromResult extends UserArray implements Countable {
/** @var ResultWrapper */
public $res;
/** @var int */
public $key;
- /** @var bool|stdClass */
+ /** @var bool|User */
public $current;
/**
require_once __DIR__ . '/Maintenance.php';
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Maintenance script to convert user options to the new `user_properties` table.
*
--- /dev/null
+<?php
+/**
+ * Initialize a user preference based on the value
+ * of another preference.
+ *
+ * @ingroup Maintenance
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * Maintenance script that initializes a user preference
+ * based on the value of another preference.
+ *
+ * @ingroup Maintenance
+ */
+class InitUserPreference extends Maintenance {
+ public function __construct() {
+ parent::__construct();
+ $this->addOption(
+ 'target',
+ 'Name of the user preference to initialize',
+ true,
+ true,
+ 't'
+ );
+ $this->addOption(
+ 'source',
+ 'Name of the user preference to take the value from',
+ true,
+ true,
+ 's'
+ );
+ $this->setBatchSize( 300 );
+ }
+
+ public function execute() {
+ $target = $this->getOption( 'target' );
+ $source = $this->getOption( 'source' );
+ $this->output( "Initializing '$target' based on the value of '$source'\n" );
+
+ $dbr = $this->getDB( DB_REPLICA );
+ $dbw = $this->getDB( DB_MASTER );
+
+ $iterator = new BatchRowIterator(
+ $dbr,
+ 'user_properties',
+ [ 'up_user', 'up_property' ],
+ $this->mBatchSize
+ );
+ $iterator->setFetchColumns( [ 'up_user', 'up_value' ] );
+ $iterator->addConditions( [
+ 'up_property' => $source,
+ 'up_value IS NOT NULL',
+ 'up_value != 0',
+ ] );
+
+ $processed = 0;
+ foreach ( $iterator as $batch ) {
+ foreach ( $batch as $row ) {
+ $values = [
+ 'up_user' => $row->up_user,
+ 'up_property' => $target,
+ 'up_value' => $row->up_value,
+ ];
+ $dbw->upsert(
+ 'user_properties',
+ $values,
+ [ 'up_user', 'up_property' ],
+ $values,
+ __METHOD__
+ );
+
+ $processed += $dbw->affectedRows();
+ }
+ }
+
+ $this->output( "Processed $processed user(s)\n" );
+ $this->output( "Finished!\n" );
+ }
+}
+
+$maintClass = 'InitUserPreference'; // Tells it to run the class
+require_once RUN_MAINTENANCE_IF_MAIN;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
require_once __DIR__ . '/Maintenance.php';
/**
* Merge page histories
*
- * @param integer $id The page_id
+ * @param stdClass $row Page row
* @param Title $newTitle The new title
* @return bool
*/
require_once __DIR__ . '/Maintenance.php';
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Maintenance script that sends purge requests for pages edited in a date
* range to squid/varnish.
require_once __DIR__ . '/Maintenance.php';
+use Wikimedia\Rdbms\ResultWrapper;
+
/**
* Maintenance script that sends SQL queries from the specified file to the database.
*
$wiki = $this->hasOption( 'wikidb' ) ? $this->getOption( 'wikidb' ) : false;
// Get the appropriate load balancer (for this wiki)
if ( $this->hasOption( 'cluster' ) ) {
- $lb = wfGetLBFactory()->getExternalLB( $this->getOption( 'cluster' ), $wiki );
+ $lb = wfGetLBFactory()->getExternalLB( $this->getOption( 'cluster' ) );
} else {
$lb = wfGetLB( $wiki );
}
/**
* Print the results, callback for $db->sourceStream()
- * @param ResultWrapper $res The results object
+ * @param ResultWrapper|bool $res The results object
* @param IDatabase $db
*/
public function sqlPrintResult( $res, $db ) {
'scripts' => 'resources/src/jquery/jquery.highlightText.js',
'dependencies' => [
'mediawiki.RegExp',
- 'dom-level2-shim',
],
'targets' => [ 'desktop', 'mobile' ],
],
'styles' => 'resources/src/jquery/jquery.tablesorter.less',
'messages' => [ 'sort-descending', 'sort-ascending' ],
'dependencies' => [
- 'dom-level2-shim',
'mediawiki.RegExp',
'mediawiki.language.months',
],
// Deprecated since MediaWiki 1.29.0
'json' => [
- 'deprecated' => 'Use of the "json" MediaWiki module is deprecated since MediaWiki 1.29.0',
+ 'deprecated' => 'Use of the "json" module is deprecated since MediaWiki 1.29.0',
'targets' => [ 'desktop', 'mobile' ],
],
'mediawiki.api.upload' => [
'scripts' => 'resources/src/mediawiki/api/upload.js',
'dependencies' => [
- 'dom-level2-shim',
'mediawiki.api',
'mediawiki.api.edit',
],
'mediawiki.Upload' => [
'scripts' => 'resources/src/mediawiki/mediawiki.Upload.js',
'dependencies' => [
- 'dom-level2-shim',
'mediawiki.api.upload',
],
],
'mediawiki.util',
'mediawiki.language',
'user.options',
- 'dom-level2-shim',
],
'targets' => [ 'desktop', 'mobile' ],
],
],
/* dom-level2-shim */
- // IE 8
+ // Deprecated since MediaWiki 1.29.0
'dom-level2-shim' => [
- 'scripts' => 'resources/src/polyfill-nodeTypes.js',
+ 'deprecated' => 'Use of the "dom-level2-shim" module is deprecated since MediaWiki 1.29.0',
'targets' => [ 'desktop', 'mobile' ],
- 'skipFunction' => 'resources/src/dom-level2-skip.js',
],
/* OOjs */
+++ /dev/null
-/*!
- * Skip function for dom-level2-shim module.
- *
- * Tests for window.Node because that's the only thing that this shim is adding.
- */
-return !!window.Node;
window.addEventListener( 'popstate', function () {
controller.updateChangesList();
} );
+
+ $( 'a.mw-helplink' ).attr(
+ 'href',
+ 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:New_filters_for_edit_review'
+ );
}
};
icon: 'feedback',
flags: [ 'progressive' ],
label: mw.msg( 'rcfilters-filterlist-feedbacklink' ),
- href: 'https://www.mediawiki.org/wiki/Help_talk:Edit_Review_Improvements/RC_filters'
+ href: 'https://www.mediawiki.org/wiki/Help_talk:New_filters_for_edit_review'
} ).$element
);
payload += $.byteLength( module.script.toString() );
}
+ // Tally templates and messages. Calculate their JSON size so that keys
+ // are included in the module size - in the case of messages, keys can be
+ // longer than values - and so that empty objects are also included.
+ $.each( [ module.templates, module.messages ], function ( i, object ) {
+ if ( object ) {
+ payload += $.byteLength( JSON.stringify( object ) );
+ }
+ } );
+
return payload;
},
+++ /dev/null
-/**
- * Adds window.Node with node types according to:
- * https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247
- */
-
-window.Node = window.Node || {
- ELEMENT_NODE: 1,
- ATTRIBUTE_NODE: 2,
- TEXT_NODE: 3,
- CDATA_SECTION_NODE: 4,
- ENTITY_REFERENCE_NODE: 5,
- ENTITY_NODE: 6,
- PROCESSING_INSTRUCTION_NODE: 7,
- COMMENT_NODE: 8,
- DOCUMENT_NODE: 9,
- DOCUMENT_TYPE_NODE: 10,
- DOCUMENT_FRAGMENT_NODE: 11,
- NOTATION_NODE: 12
-};
'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
'wgLanguageCode' => $langCode,
'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
- 'wgNamespacesWithSubpages' => [
- 0 => isset( $opts['subpage'] ),
- 2 => isset( $opts['subpage'] ),
- ],
+ 'wgNamespacesWithSubpages' => array_fill_keys(
+ MWNamespace::getValidNamespaces(), isset( $opts['subpage'] )
+ ),
'wgMaxTocLevel' => $maxtoclevel,
'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
'wgThumbLimits' => [ self::getOptionValue( 'thumbsize', $opts, 180 ) ],
<?php
class DeferredUpdatesTest extends MediaWikiTestCase {
+
+ /**
+ * @covers DeferredUpdates::getPendingUpdates
+ */
+ public function testGetPendingUpdates() {
+ # Prevent updates from running
+ $this->setMwGlobals( 'wgCommandLineMode', false );
+
+ $pre = DeferredUpdates::PRESEND;
+ $post = DeferredUpdates::POSTSEND;
+ $all = DeferredUpdates::ALL;
+
+ $update = $this->getMockBuilder( 'DeferrableUpdate' )
+ ->getMock();
+ $update->expects( $this->never() )
+ ->method( 'doUpdate' );
+
+ DeferredUpdates::addUpdate( $update, $pre );
+ $this->assertCount( 1, DeferredUpdates::getPendingUpdates( $pre ) );
+ $this->assertCount( 0, DeferredUpdates::getPendingUpdates( $post ) );
+ $this->assertCount( 1, DeferredUpdates::getPendingUpdates( $all ) );
+ $this->assertCount( 1, DeferredUpdates::getPendingUpdates() );
+ DeferredUpdates::clearPendingUpdates();
+ $this->assertCount( 0, DeferredUpdates::getPendingUpdates() );
+
+ DeferredUpdates::addUpdate( $update, $post );
+ $this->assertCount( 0, DeferredUpdates::getPendingUpdates( $pre ) );
+ $this->assertCount( 1, DeferredUpdates::getPendingUpdates( $post ) );
+ $this->assertCount( 1, DeferredUpdates::getPendingUpdates( $all ) );
+ $this->assertCount( 1, DeferredUpdates::getPendingUpdates() );
+ DeferredUpdates::clearPendingUpdates();
+ $this->assertCount( 0, DeferredUpdates::getPendingUpdates() );
+ }
+
public function testDoUpdatesWeb() {
$this->setMwGlobals( 'wgCommandLineMode', false );
'mediawiki.page.ready',
'mediawiki.page.startup',
'test.sinonjs',
- 'dom-level2-shim',
],
'position' => 'top',
'targets' => [ 'desktop', 'mobile' ],