stuff in our mainline code. Using hooks, the function becomes:
function showAnArticle( $article ) {
-
if ( Hooks::run( 'ArticleShow', array( &$article ) ) ) {
-
# code to actually show the article goes here
Hooks::run( 'ArticleShowComplete', array( &$article ) );
* @return bool
*/
public function deleteIfExpired() {
-
if ( $this->isExpired() ) {
wfDebug( "Block::deleteIfExpired() -- deleting\n" );
$this->delete();
* not be the same as the target you gave if you used $vagueTarget!
*/
public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) {
-
list( $target, $type ) = self::parseTarget( $specificTarget );
if ( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) {
return Block::newFromID( $target );
* @return TitleArray TitleArray object for category members.
*/
public function getMembers( $limit = false, $offset = '' ) {
-
$dbr = wfGetDB( DB_REPLICA );
$conds = [ 'cl_to' => $this->getName(), 'cl_from = page_id' ];
* Scans a "parent layer" of the articles/categories in $this->next
*/
private function scanNextLayer() {
-
# Find all parents of the article currently in $this->next
$layer = [];
$res = $this->dbr->select(
* @return string HTML output
*/
public function getHTML() {
-
$this->showGallery = $this->getConfig()->get( 'CategoryMagicGallery' )
&& !$this->getOutput()->mNoGallery;
// PSR2.Methods.MethodDeclaration.Underscore
// PSR2.Classes.PropertyDeclaration.ScopeMissing
function _newObject() {
-
/* Put the caller offset for wfDeprecated as 6, as
* that gives the function that uses this object, since:
* 1 = this function ( _newObject )
}
if ( $html === null ) {
-
// Omit large new page diffs, T31110
// Also use diff link for non-textual content
$diffText = self::getDiffLink( $title, $newid );
* @return string HTML output
*/
public static function formatHiddenCategories( $hiddencats ) {
-
$outText = '';
if ( count( $hiddencats ) > 0 ) {
# Construct the HTML
// ATTENTION: This hook is likely to be removed soon due to overall design of the system.
if ( Hooks::run( 'BeforeHttpsRedirect', [ $this->context, &$redirUrl ] ) ) {
-
if ( $request->wasPosted() ) {
// This is weird and we'd hope it almost never happens. This
// means that a POST came in via HTTP and policy requires us
* @throws MWException
*/
private function moveToInternal( User $user, &$nt, $reason = '', $createRedirect = true,
- array $changeTags = [] ) {
-
+ array $changeTags = []
+ ) {
global $wgContLang;
if ( $nt->exists() ) {
$moveOverRedirect = true;
* @return string
*/
function wfHtmlValidationHandler( $s ) {
-
$errors = '';
if ( MWTidy::checkErrors( $s, $errors ) ) {
return $s;
* @return string normalized css
*/
public static function normalizeCss( $value ) {
-
// Decode character references like {
$value = Sanitizer::decodeCharReferences( $value );
* @return array|bool True on success, getUserPermissionsErrors()-like array on failure
*/
public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true,
- array $changeTags = [] ) {
-
+ array $changeTags = []
+ ) {
global $wgUser;
$err = $this->isValidMoveOperation( $nt, $auth, $reason );
if ( is_array( $err ) ) {
* no pages were moved
*/
public function moveSubpages( $nt, $auth = true, $reason = '', $createRedirect = true,
- array $changeTags = [] ) {
-
+ array $changeTags = []
+ ) {
global $wgMaximumMovedPages;
// Check permissions
if ( !$this->userCan( 'move-subpages' ) ) {
* @return string HTML
*/
public function onView() {
-
if ( $this->page->getID() == 0 ) {
$s = $this->msg( 'nocredits' )->parse();
} else {
* @return bool
*/
protected function getWatchlistValue( $watchlist, $titleObj, $userOption = null ) {
-
$userWatching = $this->getUser()->isWatched( $titleObj, User::IGNORE_USER_RIGHTS );
switch ( $watchlist ) {
/** @var $newTitle Title */
foreach ( $titles as $id => $newTitle ) {
-
if ( !isset( $titles[$id - 1] ) ) {
$titles[$id - 1] = $oldTitle;
}
* @param string $group Which group modules belong to (action,format,...)
*/
public function addModules( array $modules, $group ) {
-
foreach ( $modules as $name => $moduleSpec ) {
if ( is_array( $moduleSpec ) ) {
$class = $moduleSpec['class'];
* @return ResultWrapper
*/
protected function select( $method, $extraQuery = [], array &$hookData = null ) {
-
$tables = array_merge(
$this->tables,
isset( $extraQuery['tables'] ) ? (array)$extraQuery['tables'] : []
}
foreach ( $res as $row ) {
-
// create user object and pass along $userGroups if set
// that reduces the number of database queries needed in User dramatically
if ( !isset( $userGroups ) ) {
* @return ResultWrapper
*/
protected function queryLinks( $table, $startId, $endId, $max, $select = 'all' ) {
-
$fromField = $this->getPrefix( $table ) . '_from';
if ( !$startId && !$endId && is_infinite( $max )
* @param array &$join_conds Array of join conditions; see IDatabase::select $join_conds
*/
public function modifyQuery( IDatabase $dbr, ChangesListSpecialPage $specialPage,
- &$tables, &$fields, &$conds, &$query_options, &$join_conds ) {
-
+ &$tables, &$fields, &$conds, &$query_options, &$join_conds
+ ) {
if ( $this->queryCallable === null ) {
return;
}
* @param string $backwardKey i18n key for conflict message in reverse
* direction (when in UI context of $other object)
*/
- public function conflictsWith( $other, $globalKey, $forwardKey,
- $backwardKey ) {
-
- if ( $globalKey === null || $forwardKey === null ||
- $backwardKey === null ) {
-
+ public function conflictsWith( $other, $globalKey, $forwardKey, $backwardKey ) {
+ if ( $globalKey === null || $forwardKey === null || $backwardKey === null ) {
throw new MWException( 'All messages must be specified' );
}
* @param string $contextDescription i18n key for conflict message in this
* direction (when in UI context of $this object)
*/
- public function setUnidirectionalConflict( $other, $globalDescription,
- $contextDescription ) {
-
+ public function setUnidirectionalConflict( $other, $globalDescription, $contextDescription ) {
if ( $other instanceof ChangesListFilterGroup ) {
$this->conflictingGroups[] = [
'group' => $other->getName(),
* @param string $backwardKey i18n key for conflict message in reverse
* direction (when in UI context of $other object)
*/
- public function conflictsWith( $other, $globalKey, $forwardKey,
- $backwardKey ) {
-
- if ( $globalKey === null || $forwardKey === null ||
- $backwardKey === null ) {
-
+ public function conflictsWith( $other, $globalKey, $forwardKey, $backwardKey ) {
+ if ( $globalKey === null || $forwardKey === null || $backwardKey === null ) {
throw new MWException( 'All messages must be specified' );
}
* @param string $contextDescription i18n key for conflict message in this
* direction (when in UI context of $this object)
*/
- public function setUnidirectionalConflict( $other, $globalDescription,
- $contextDescription ) {
-
+ public function setUnidirectionalConflict( $other, $globalDescription, $contextDescription ) {
if ( $other instanceof ChangesListFilterGroup ) {
$this->conflictingGroups[] = [
'group' => $other->getName(),
* @param string $value URL parameter value
*/
public function modifyQuery( IDatabase $dbr, ChangesListSpecialPage $specialPage,
- &$tables, &$fields, &$conds, &$query_options, &$join_conds, $value ) {
-
+ &$tables, &$fields, &$conds, &$query_options, &$join_conds, $value
+ ) {
$allowedFilterNames = [];
foreach ( $this->filters as $filter ) {
$allowedFilterNames[] = $filter->getName();
* @return string
*/
public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
-
$date = $this->getLanguage()->userDate(
$rc->mAttribs['rc_timestamp'],
$this->getUser()
* @return string|bool
*/
public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
-
$classes = $this->getHTMLClasses( $rc, $watched );
// use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
if ( $linenumber ) {
&$rev_id = null, &$log_id = null, $params = null, RecentChange $rc = null,
User $user = null
) {
-
$tagsToAdd = array_filter( (array)$tagsToAdd ); // Make sure we're submitting all tags...
$tagsToRemove = array_filter( (array)$tagsToRemove );
// update the tag_summary row
$prevTags = [];
if ( !self::updateTagSummaryRow( $tagsToAdd, $tagsToRemove, $rc_id, $rev_id,
- $log_id, $prevTags ) ) {
-
+ $log_id, $prevTags )
+ ) {
// nothing to do
return [ [], [], $prevTags ];
}
* @since 1.25
*/
protected static function updateTagSummaryRow( &$tagsToAdd, &$tagsToRemove,
- $rc_id, $rev_id, $log_id, &$prevTags = [] ) {
-
+ $rc_id, $rev_id, $log_id, &$prevTags = []
+ ) {
$dbw = wfGetDB( DB_MASTER );
$tsConds = array_filter( [
* @return Status
* @since 1.25
*/
- public static function canAddTagsAccompanyingChange( array $tags,
- User $user = null ) {
-
+ public static function canAddTagsAccompanyingChange( array $tags, User $user = null ) {
if ( !is_null( $user ) ) {
if ( !$user->isAllowed( 'applychangetags' ) ) {
return Status::newFatal( 'tags-apply-no-permission' );
public static function addTagsAccompanyingChangeWithChecks(
array $tags, $rc_id, $rev_id, $log_id, $params, User $user
) {
-
// are we allowed to do this?
$result = self::canAddTagsAccompanyingChange( $tags, $user );
if ( !$result->isOK() ) {
* @since 1.25
*/
public static function canUpdateTags( array $tagsToAdd, array $tagsToRemove,
- User $user = null ) {
-
+ User $user = null
+ ) {
if ( !is_null( $user ) ) {
if ( !$user->isAllowed( 'changetags' ) ) {
return Status::newFatal( 'tags-update-no-permission' );
* @since 1.25
*/
public static function updateTagsWithChecks( $tagsToAdd, $tagsToRemove,
- $rc_id, $rev_id, $log_id, $params, $reason, User $user ) {
-
+ $rc_id, $rev_id, $log_id, $params, $reason, User $user
+ ) {
if ( is_null( $tagsToAdd ) ) {
$tagsToAdd = [];
}
* @since 1.25
*/
protected static function logTagManagementAction( $action, $tag, $reason,
- User $user, $tagCount = null, array $logEntryTags = [] ) {
-
+ User $user, $tagCount = null, array $logEntryTags = []
+ ) {
$dbw = wfGetDB( DB_MASTER );
$logEntry = new ManualLogEntry( 'managetags', $action );
* @since 1.25
*/
public static function activateTagWithChecks( $tag, $reason, User $user,
- $ignoreWarnings = false, array $logEntryTags = [] ) {
-
+ $ignoreWarnings = false, array $logEntryTags = []
+ ) {
// are we allowed to do this?
$result = self::canActivateTag( $tag, $user );
if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
* @since 1.25
*/
public static function deactivateTagWithChecks( $tag, $reason, User $user,
- $ignoreWarnings = false, array $logEntryTags = [] ) {
-
+ $ignoreWarnings = false, array $logEntryTags = []
+ ) {
// are we allowed to do this?
$result = self::canDeactivateTag( $tag, $user );
if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
* @since 1.25
*/
public static function createTagWithChecks( $tag, $reason, User $user,
- $ignoreWarnings = false, array $logEntryTags = [] ) {
-
+ $ignoreWarnings = false, array $logEntryTags = []
+ ) {
// are we allowed to do this?
$result = self::canCreateTag( $tag, $user );
if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
* @since 1.25
*/
public static function deleteTagWithChecks( $tag, $reason, User $user,
- $ignoreWarnings = false, array $logEntryTags = [] ) {
-
+ $ignoreWarnings = false, array $logEntryTags = []
+ ) {
// are we allowed to do this?
$result = self::canDeleteTag( $tag, $user );
if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
* @throws Exception If you give an unknown $typeName
*/
public static function factory( $typeName, IContextSource $context,
- Title $title, array $ids ) {
-
+ Title $title, array $ids
+ ) {
switch ( $typeName ) {
case 'revision':
$className = 'ChangeTagsRevisionList';
* @param User $user
* @return Status
*/
- public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params,
- $reason, $user ) {
-
+ public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params, $reason, $user ) {
// @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
for ( $this->reset(); $this->current(); $this->next() ) {
// @codingStandardsIgnoreEnd
* @param User $user
* @return Status
*/
- public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params,
- $reason, $user ) {
-
+ public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params, $reason, $user ) {
// @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
for ( $this->reset(); $this->current(); $this->next() ) {
// @codingStandardsIgnoreEnd
$po = new ParserOutput();
if ( Hooks::run( 'ContentGetParserOutput',
- [ $this, $title, $revId, $options, $generateHtml, &$po ] ) ) {
-
+ [ $this, $title, $revId, $options, $generateHtml, &$po ] )
+ ) {
// Save and restore the old value, just in case something is reusing
// the ParserOptions object in some weird way.
$oldRedir = $options->getRedirectTarget();
*/
public function createDifferenceEngine( IContextSource $context, $old = 0, $new = 0,
$rcid = 0, // FIXME: Deprecated, no longer used
- $refreshCache = false, $unhide = false ) {
-
+ $refreshCache = false, $unhide = false
+ ) {
// hook: get difference engine
$differenceEngine = null;
if ( !Hooks::run( 'GetDifferenceEngine',
* @see Content::replaceSection()
*/
public function replaceSection( $sectionId, Content $with, $sectionTitle = '' ) {
-
$myModelId = $this->getModel();
$sectionModelId = $with->getModel();
$text = (string)$record['formatted'];
if ( $this->useUdp() ) {
-
// Clean it up for the multiplexer
if ( $this->prefix !== '' ) {
$leader = ( $this->prefix === '{channel}' ) ?
* @return DiffOp[]
*/
public function diff( $from_lines, $to_lines ) {
-
// Diff and store locally
$this->diffInternal( $from_lines, $to_lines );
* @return string The formatted output.
*/
public function format( $diff ) {
-
$xi = $yi = 1;
$block = false;
$context = [];
* @param string[] $closing
*/
protected function changed( $orig, $closing ) {
-
$diff = new WordLevelDiff( $orig, $closing );
$del = $diff->orig();
$add = $diff->closing();
* @access private
*/
function writeRevision( $row ) {
-
$out = " <revision>\n";
$out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
* @access private
*/
function writeLogItem( $row ) {
-
$out = " <logitem>\n";
$out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
* @return string
*/
protected function wrapGalleryText( $galleryText, $thumb ) {
-
// If we have no text, do not output anything to avoid
// ugly white overlay.
if ( trim( $galleryText ) === '' ) {
* @return bool
*/
public function finishImportPage( $title, $foreignTitle, $revCount,
- $sRevCount, $pageInfo ) {
-
+ $sRevCount, $pageInfo
+ ) {
// Update article count statistics (T42009)
// The normal counting logic in WikiPage->doEditUpdates() is designed for
// one-revision-at-a-time editing, not bulk imports. In this situation it
* @return bool|mixed
*/
private function processLogItem( $logInfo ) {
-
$revision = new WikiRevision( $this->config );
if ( isset( $logInfo['id'] ) ) {
}
protected function setDefault( $table, $field, $default ) {
-
$info = $this->db->fieldInfo( $table, $field );
if ( $info->defaultValue() !== $default ) {
$this->output( "Changing '$table.$field' default value\n" );
* @return bool Whether it exists
*/
public function isValidInterwiki( $prefix ) {
-
return array_key_exists( $prefix, $this->getInterwikiMap() );
}
* @return string Raw binary random data
*/
public function generate( $bytes, $forceStrong = false ) {
-
$bytes = floor( $bytes );
static $buffer = '';
if ( is_null( $this->strong ) ) {
* @return mixed
*/
public function get( $key, &$casToken = null ) {
-
if ( $this->_debug ) {
$this->_debugprint( "get($key)" );
}
* Primary job is to initialize the XMLParser
*/
function __construct( LoggerInterface $logger = null ) {
-
if ( !function_exists( 'xml_parser_create_ns' ) ) {
// this should already be checked by this point
throw new RuntimeException( 'XMP support requires XML Parser' );
* For example in jpeg's with extendedXMP
*/
private function resetXMLParser() {
-
$this->destroyXMLParser();
$this->xmlParser = xml_parser_create_ns( 'UTF-8', ' ' );
* @throws RuntimeException On invalid data
*/
function char( $parser, $data ) {
-
$data = trim( $data );
if ( trim( $data ) === "" ) {
return;
* @throws RuntimeException
*/
private function endElementNested( $elm ) {
-
/* cur item must be the same as $elm, unless if in MODE_STRUCT
* in which case it could also be rdf:Description */
if ( $this->curItem[0] !== $elm
* @param string $elm Namespace and element
*/
private function endElementModeQDesc( $elm ) {
-
if ( $elm === self::NS_RDF . ' value' ) {
list( $ns, $tag ) = explode( ' ', $this->curItem[0], 2 );
$this->saveValue( $ns, $tag, $this->charContent );
* @throws RuntimeException
*/
function startElement( $parser, $elm, $attribs ) {
-
if ( $elm === self::NS_RDF . ' RDF'
|| $elm === 'adobe:ns:meta/ xmpmeta'
|| $elm === 'adobe:ns:meta/ xapmeta'
* @param string $val Value to save
*/
private function saveValue( $ns, $tag, $val ) {
-
$info =& $this->items[$ns][$tag];
$finalName = isset( $info['map_name'] )
? $info['map_name'] : $tag;
* @return array Metadata array
*/
public static function GIF( $filename ) {
-
$meta = new self();
$baseArray = GIFMetadataExtractor::getMetadata( $filename );
* if we make up our own types like Exif::DATE.
*/
function collapseData() {
-
$this->exifGPStoNumber( 'GPSLatitude' );
$this->exifGPStoNumber( 'GPSDestLatitude' );
$this->exifGPStoNumber( 'GPSLongitude' );
*/
private function charCodeString( $prop ) {
if ( isset( $this->mFilteredExifData[$prop] ) ) {
-
if ( strlen( $this->mFilteredExifData[$prop] ) <= 8 ) {
// invalid. Must be at least 9 bytes long.
* only code that seems to have wide use. It does detect that code.
*/
static function getCharset( $tag ) {
-
// According to iim standard, charset is defined by the tag 1:90.
// in which there are iso 2022 escape sequences to specify the character set.
// the iim standard seems to encourage that all necessary escape sequences are
$buffer = fread( $fh, 1 );
}
if ( $buffer === "\xFE" ) {
-
// COM section -- file comment
// First see if valid utf-8,
// if not try to convert it to windows-1252.
*/
function convertMetadataVersion( $metadata, $version = 1 ) {
if ( !is_array( $metadata ) ) {
-
// unserialize to keep return parameter consistent.
MediaWiki\suppressWarnings();
$ret = unserialize( $metadata );
}
function isMetadataValid( $image, $metadata ) {
-
if ( $metadata === self::BROKEN_FILE ) {
// Do not repetitivly regenerate metadata on broken file.
return self::METADATA_GOOD;
&& $scalerParams['physicalHeight'] == $scalerParams['srcHeight']
&& !isset( $scalerParams['quality'] )
) {
-
# normaliseParams (or the user) wants us to return the unscaled image
wfDebug( __METHOD__ . ": returning unscaled image\n" );
* @since 1.21
*/
protected function getContentObject() {
-
if ( $this->mPage->getId() === 0 ) {
# If this is a MediaWiki:x message, then load the messages
# and return the message value for x.
$outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() );
if ( !Hooks::run( 'ArticleContentViewCustom',
- [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
-
+ [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] )
+ ) {
# Allow extensions do their own custom view for certain pages
$outputDone = true;
}
* @return bool
*/
public function updateIfNewerOn( $dbw, $revision ) {
-
$row = $dbw->selectRow(
[ 'revision', 'page' ],
[ 'rev_id', 'rev_timestamp', 'page_is_redirect' ],
public function replaceSectionContent(
$sectionId, Content $sectionContent, $sectionTitle = '', $edittime = null
) {
-
$baseRevId = null;
if ( $edittime && $sectionId !== 'new' ) {
$dbr = wfGetDB( DB_REPLICA );
public function replaceSectionAtRev( $sectionId, Content $sectionContent,
$sectionTitle = '', $baseRevId = null
) {
-
if ( strval( $sectionId ) === '' ) {
// Whole-page edit; let the whole text through
$newContent = $sectionContent;
$magicWords = new MagicWordArray( [ 'url_path', 'url_query', 'url_wiki' ] );
}
switch ( $magicWords->matchStartToEnd( $arg ) ) {
-
// Encode as though it's a wiki page, '_' for ' '.
case 'url_wiki':
$func = 'wfUrlencode';
* @return string
*/
public function doTableStuff( $text ) {
-
$lines = StringUtils::explode( "\n", $text );
$out = '';
$td_history = []; # Is currently a td tag open?
* @return string
*/
public function internalParse( $text, $isMain = true, $frame = false ) {
-
$origText = $text;
// Avoid PHP 7.1 warning from passing $this by reference
* @return string
*/
public function replaceExternalLinks( $text ) {
-
$bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
if ( $bits === false ) {
throw new MWException( "PCRE needs to be compiled with "
* @return string The text of the template
*/
public function braceSubstitution( $piece, $frame ) {
-
// Flags
// $text has been filled
* @return array
*/
public function argSubstitution( $piece, $frame ) {
-
$error = false;
$parts = $piece['parts'];
$nameWithSpaces = $frame->expand( $piece['title'] );
* @return string
*/
public function doDoubleUnderscore( $text ) {
-
# The position of __TOC__ needs to be recorded
$mw = MagicWord::get( 'toc' );
if ( $mw->match( $text ) ) {
* @return string HTML
*/
public function renderImageGallery( $text, $params ) {
-
$mode = false;
if ( isset( $params['mode'] ) ) {
$mode = $params['mode'];
* @return PPNode_DOM
*/
public function preprocessToObj( $text, $flags = 0 ) {
-
$xml = $this->cacheGetTree( $text, $flags );
if ( $xml === false ) {
$xml = $this->preprocessToXml( $text, $flags );
}
// Handle comments
if ( isset( $matches[2] ) && $matches[2] == '!--' ) {
-
// To avoid leaving blank lines, when a sequence of
// space-separated comments is both preceded and followed by
// a newline (ignoring spaces), then
}
// Handle comments
if ( isset( $matches[2] ) && $matches[2] == '!--' ) {
-
// To avoid leaving blank lines, when a sequence of
// space-separated comments is both preceded and followed by
// a newline (ignoring spaces), then
* @param array $localFileRefs List of files
*/
protected function saveFileDependencies( ResourceLoaderContext $context, $localFileRefs ) {
-
try {
// Related bugs and performance considerations:
// 1. Don't needlessly change the database value with the same list in a
// (e.g. startup module) iterate more than once over all modules to get versions.
$contextHash = $context->getHash();
if ( !array_key_exists( $contextHash, $this->versionHash ) ) {
-
if ( $this->enableModuleContentVersion() ) {
// Detect changes directly
$str = json_encode( $this->getModuleContent( $context ) );
* @return array
*/
protected function getConfigSettings( $context ) {
-
$hash = $context->getHash();
if ( isset( $this->configVars[$hash] ) ) {
return $this->configVars[$hash];
// The list of implicit dependencies won't be altered, so we can
// cache them without having to worry.
if ( !isset( $dependencyCache[$moduleName] ) ) {
-
if ( !isset( $registryData[$moduleName] ) ) {
// Dependencies may not exist
$dependencyCache[$moduleName] = [];
}
foreach ( $allSearchTerms as $term ) {
-
# Exact match? No need to look further.
$title = Title::newFromText( $term );
if ( is_null( $title ) ) {
* @throws \MWException
*/
public function normalizePageName( $pageName, $apiUrl ) {
-
// Check if we have strings as arguments.
if ( !is_string( $pageName ) ) {
throw new \MWException( '$pageName must be a string' );
}
function translate( $value ) {
-
// Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
$value = preg_replace( '/^string:/', '', $value );
* @return string
*/
function getNewtalks() {
-
$newMessagesAlert = '';
$user = $this->getUser();
$newtalks = $user->getNewMessageLinks();
'showHideSuffix' => 'showhideliu',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_user = 0';
},
'cssClassSuffix' => 'liu',
'showHideSuffix' => 'showhideanons',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_user != 0';
},
'cssClassSuffix' => 'anon',
'showHideSuffix' => 'showhidemine',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$user = $ctx->getUser();
$conds[] = 'rc_user_text != ' . $dbr->addQuotes( $user->getName() );
},
'description' => 'rcfilters-filter-editsbyother-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$user = $ctx->getUser();
$conds[] = 'rc_user_text = ' . $dbr->addQuotes( $user->getName() );
},
'showHideSuffix' => 'showhidebots',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_bot = 0';
},
'cssClassSuffix' => 'bot',
'description' => 'rcfilters-filter-humans-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_bot = 1';
},
'cssClassSuffix' => 'human',
'showHideSuffix' => 'showhideminor',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_minor = 0';
},
'cssClassSuffix' => 'minor',
'description' => 'rcfilters-filter-major-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_minor = 1';
},
'cssClassSuffix' => 'major',
'default' => false,
'priority' => -2,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
},
'cssClassSuffix' => 'src-mw-edit',
'default' => false,
'priority' => -3,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
},
'cssClassSuffix' => 'src-mw-new',
'default' => false,
'priority' => -5,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
},
'cssClassSuffix' => 'src-mw-log',
'showHideSuffix' => 'showhidepatr',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_patrolled = 0';
},
'cssClassSuffix' => 'patrolled',
'description' => 'rcfilters-filter-unpatrolled-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_patrolled = 1';
},
'cssClassSuffix' => 'unpatrolled',
'default' => false,
'priority' => -4,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
},
'cssClassSuffix' => 'src-mw-categorize',
$opts = $this->getOptions();
/** @var ChangesListFilterGroup $group */
foreach ( $this->getFilterGroups() as $group ) {
-
if ( $group->getConflictingGroups() ) {
wfLogWarning(
$group->getName() .
/** @var ChangesListFilter $filter */
foreach ( $group->getFilters() as $filter ) {
-
/** @var ChangesListFilter $conflictingFilter */
foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
if (
* @param FormOptions $opts
*/
protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
- &$join_conds, FormOptions $opts ) {
-
+ &$join_conds, FormOptions $opts
+ ) {
$dbr = $this->getDB();
$user = $this->getUser();
* @return bool|ResultWrapper Result or false
*/
protected function doMainQuery( $tables, $fields, $conds,
- $query_options, $join_conds, FormOptions $opts ) {
-
+ $query_options, $join_conds, FormOptions $opts
+ ) {
$tables[] = 'recentchanges';
$fields = array_merge( RecentChange::selectFields(), $fields );
* (optional)
*/
public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
- &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0 ) {
-
+ &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
+ ) {
global $wgLearnerEdits,
$wgExperiencedUserEdits,
$wgLearnerMemberSince,
# Get the cached result, select one extra row for navigation
$res = $this->fetchFromCache( $dbLimit, $this->offset );
if ( !$this->listoutput ) {
-
# Fetch the timestamp of this update
$ts = $this->getCachedTimestamp();
$lang = $this->getLanguage();
global $wgPageLanguageUseDB, $wgContentHandlerUseDB;
if ( !is_array( self::$list ) ) {
-
self::$list = self::$coreList;
if ( !$wgDisableInternalSearch ) {
}
protected function checkExecutePermissions( User $user ) {
-
if ( !AuthManager::singleton()->allowsPropertyChange( 'emailaddress' ) ) {
throw new ErrorPageError( 'changeemail', 'cannotchangeemail' );
}
* @return array
*/
public static function getUserLinks( SpecialPage $sp, User $target ) {
-
$id = $target->getId();
$username = $target->getName();
$userpage = $target->getUserPage();
* @param bool $exportall Whether to export everything
*/
private function doExport( $page, $history, $list_authors, $exportall ) {
-
// If we are grabbing everything, enable full history and ignore the rest
if ( $exportall ) {
$history = WikiExporter::FULL;
* @return PageDataRequestHandler
*/
private function newDefaultRequestHandler() {
-
return new PageDataRequestHandler();
}
* @inheritdoc
*/
protected function buildQuery( &$tables, &$fields, &$conds,
- &$query_options, &$join_conds, FormOptions $opts ) {
-
+ &$query_options, &$join_conds, FormOptions $opts
+ ) {
$dbr = $this->getDB();
parent::buildQuery( $tables, $fields, $conds,
$query_options, $join_conds, $opts );
* @inheritdoc
*/
protected function doMainQuery( $tables, $fields, $conds, $query_options,
- $join_conds, FormOptions $opts ) {
-
+ $join_conds, FormOptions $opts
+ ) {
$dbr = $this->getDB();
$user = $this->getUser();
* @inheritdoc
*/
protected function doMainQuery( $tables, $select, $conds, $query_options,
- $join_conds, FormOptions $opts ) {
-
+ $join_conds, FormOptions $opts
+ ) {
$target = $opts['target'];
$showlinkedto = $opts['showlinkedto'];
$limit = $opts['limit'];
$mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer );
if ( $search->getFeatureData( 'enable-new-crossproject-page' ) ) {
-
$sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
$sidebarResultsWidget = new InterwikiSearchResultSetWidget(
$this,
$includesCachedPages = false;
foreach ( $groups as $group => $sortedPages ) {
-
$out->wrapWikiMsg(
"<h2 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h2>\n",
"specialpages-group-$group"
foreach ( $stats as $header => $items ) {
// Identify the structure used
if ( is_array( $items ) ) {
-
// Ignore headers that are recursively set as legacy header
if ( $header !== 'statistics-header-hooks' ) {
$return .= $this->formatRowHeader( $header );
}
if ( $showManageActions ) { // we've already checked that the user had the requisite userright
-
// activate
if ( ChangeTags::canActivateTag( $tag )->isOK() ) {
$actionLinks[] = $linkRenderer->makeKnownLink(
[],
[ 'tag' => $tag ] );
}
-
}
if ( $showDeleteActions || $showManageActions ) {
*/
protected function processVerificationError( $details ) {
switch ( $details['status'] ) {
-
/** Statuses that only require name changing **/
case UploadBase::MIN_LENGTH_PARTNAME:
$this->showRecoverableUploadError( $this->msg( 'minlength1' )->escaped() );
* @return array Tuple of added, then removed groups
*/
function doSaveUserGroups( $user, $add, $remove, $reason = '', $tags = [],
- $groupExpiries = [] ) {
-
+ $groupExpiries = []
+ ) {
// Validate input set...
$isself = $user->getName() == $this->getUser()->getName();
$groups = $user->getGroups();
* @param array $newUGMs Associative array of (group name => UserGroupMembership)
*/
protected function addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags,
- $oldUGMs, $newUGMs ) {
-
+ $oldUGMs, $newUGMs
+ ) {
// make sure $oldUGMs and $newUGMs are in the same order, and serialise
// each UGM object to a simplified array
$oldUGMs = array_map( function ( $group ) use ( $oldUGMs ) {
* @inheritdoc
*/
protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
- &$join_conds, FormOptions $opts ) {
-
+ &$join_conds, FormOptions $opts
+ ) {
$dbr = $this->getDB();
parent::buildQuery( $tables, $fields, $conds, $query_options, $join_conds,
$opts );
* @inheritdoc
*/
protected function doMainQuery( $tables, $fields, $conds, $query_options,
- $join_conds, FormOptions $opts ) {
-
+ $join_conds, FormOptions $opts
+ ) {
$dbr = $this->getDB();
$user = $this->getUser();
if ( $this->language->needsGenderDistinction() &&
MWNamespace::hasGenderDistinction( $namespace )
) {
-
// NOTE: we are assuming here that the title text is a user name!
$gender = $this->genderCache->getGenderOf( $text, __METHOD__ );
$name = $this->language->getGenderNsText( $namespace, $gender );
* @return mixed Const self::OK or else an array with error information
*/
public function verifyUpload() {
-
/**
* If there was no filename or a zero size given, give up quick.
*/
* @return bool
*/
public function checkSvgScriptCallback( $element, $attribs, $data = null ) {
-
list( $namespace, $strippedElement ) = $this->splitXmlNamespace( $element );
// We specifically don't include:
* @return bool true if the CSS contains an illegal string, false if otherwise
*/
private static function checkCssFragment( $value ) {
-
# Forbid external stylesheets, for both reliability and to protect viewer's privacy
if ( stripos( $value, '@import' ) !== false ) {
return true;
* @return string
*/
public static function getLink( $ugm, IContextSource $context, $format,
- $userName = null ) {
-
+ $userName = null
+ ) {
if ( $format !== 'wiki' && $format !== 'html' ) {
throw new MWException( 'UserGroupMembership::getLink() $format parameter should be ' .
"'wiki' or 'html'" );
// format class-name : path when they get converted into json.
foreach ( $this->classes as $path => $contained ) {
foreach ( $contained as $fqcn ) {
-
// Using substr to remove the leading '/'
$json[$key][$fqcn] = substr( $path, 1 );
}
}
foreach ( $this->overrides as $path => $fqcn ) {
-
// Using substr to remove the leading '/'
$json[$key][$fqcn] = substr( $path, 1 );
}
* @return string
*/
public function getAutoload( $commandName = 'AutoloadGenerator' ) {
-
// We need to check whether an extenson.json or skin.json exists or not, and
// incase it doesn't, update the autoload.php file.
* @return string HTML
*/
protected function footerHtml( $term, $iwPrefix ) {
-
$href = Title::makeTitle( NS_SPECIAL, 'Search', null, $iwPrefix )->getLocalURL(
[ 'search' => $term, 'fulltext' => 1 ]
);
* @return OOUI\IconWidget
**/
protected function iwIcon( $iwPrefix ) {
-
$interwiki = $this->iwLookup->fetch( $iwPrefix );
$parsed = wfParseUrl( wfExpandUrl( $interwiki ? $interwiki->getURL() : '/' ) );
* @return string HTML
*/
public function render( SearchResult $result, $terms, $position ) {
-
$title = $result->getTitle();
$iwPrefix = $result->getTitle()->getInterwiki();
$titleSnippet = $result->getTitleSnippet();
$redirectTitle = $result->getRedirectTitle();
$redirect = '';
if ( $redirectTitle !== null ) {
-
$redirectText = $result->getRedirectSnippet();
if ( $redirectText ) {
* @return bool
*/
public static function isValidBuiltInCode( $code ) {
-
if ( !is_string( $code ) ) {
if ( is_object( $code ) ) {
$addmsg = " of class " . get_class( $code );
* @return string The converted text
*/
public function autoConvert( $text, $toVariant = false ) {
-
$this->loadTables();
if ( !$toVariant ) {
* @return string
*/
function normalizeForSearch( $string ) {
-
# MySQL fulltext index doesn't grok utf-8, so we
# need to fold cases and convert to hex
}
function loadRegs() {
-
$this->mCyrl2Latn = [
# # Punctuation
'/№/u' => 'No.',
* @return string
*/
function convertGrammar( $word, $case ) {
-
$variant = $this->getPreferredVariant();
switch ( $variant ) {
case 'kk-arab':
* @return string
*/
function commafy( $_ ) {
-
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
* @return string
*/
function normalizeForSearch( $string ) {
-
// Double-width roman characters
$s = self::convertDoubleWidth( $string );
$s = trim( $s );
* @return string
*/
function normalizeForSearch( $s ) {
-
// Double-width roman characters
$s = parent::normalizeForSearch( $s );
$s = trim( $s );
* @return array Resulting list of changed files
*/
private function getGitModifiedFiles( $path ) {
-
global $wgMaxShellMemory;
if ( !is_dir( "$path/.git" ) ) {
}
function doDelete( $delete = false, $args = [] ) {
-
# Data should come off the master, wrapped in a transaction
$dbw = $this->getDB( DB_MASTER );
$this->beginTransaction( $dbw, __METHOD__ );
}
while ( $failures < $this->maxFailures ) {
-
// As soon as we found a good text for the $id, we will return immediately.
// Hence, if we make it past the try catch block, we know that we did not
// find a good text.
# Batch "upload" operation
$count = count( $files );
if ( $count > 0 ) {
-
foreach ( $files as $file ) {
-
if ( $sleep && ( $processed > 0 ) ) {
sleep( $sleep );
}
$count = 0;
if ( ( $messageExist ) && ( $messageCExist ) ) {
-
if ( !strcmp( $runMode, 'php' ) ) {
print "<?php\n";
print '$dupeMessages = [' . "\n";
$ok = true;
foreach ( $targets as $row ) {
-
// Find the new title and determine the action to take
$newTitle = $this->getDestinationTitle( $ns, $name,
}
public function execute() {
-
$name = $this->getArg();
$delete = $this->getOption( 'delete', false );
AND ucc.constraint_name = uc.constraint_name
AND uccpk.constraint_name = uc.r_constraint_name
AND uccpk.table_name = '$ltable'" );
- while ( ( $row = $result->fetchRow() ) !== false ) {
+ while ( ( $row = $result->fetchRow() ) !== false ) {
$this->output( "Altering {$row['constraint_name']} ..." );
try {
$this->output( "Starting from page_id $start of $end.\n" );
for ( $id = $start; $id <= $end; $id++ ) {
-
if ( !( $id % self::REPORTING_INTERVAL ) ) {
$this->output( "$id\n" );
wfWaitForSlaves();
$this->output( "Starting from page_id $start of $end.\n" );
for ( $id = $start; $id <= $end; $id++ ) {
-
if ( !( $id % self::REPORTING_INTERVAL ) ) {
$this->output( "$id\n" );
wfWaitForSlaves();
}
public function execute() {
-
$this->output( "Remove unused accounts\n\n" );
# Do an initial scan for inactive accounts and report the result
* @return bool
*/
private function initializeOpts( $opts, $args ) {
-
$this->mQuick = isset( $opts['nowarn'] );
$this->mQuiet = isset( $opts['quiet'] );
$this->mDry = isset( $opts['dry'] );
);
foreach ( $result as $id ) {
-
$user = User::newFromId( $id->user_id );
// Get the options and update stats
if ( $this->mAnOption ) {
-
if ( !array_key_exists( $this->mAnOption, $defaultOptions ) ) {
print "Invalid user option. Use --list to see valid choices\n";
exit;
);
foreach ( $result as $id ) {
-
$user = User::newFromId( $id->user_id );
$curValue = $user->getOption( $this->mAnOption );
$username = $user->getName();
if ( $curValue == $this->mOldValue ) {
-
if ( !$this->mQuiet ) {
print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' " .
"to '{$this->mNewValue}'): ";
* @return bool
*/
public function warn() {
-
if ( $this->mQuick ) {
return true;
}
$installer = InstallerOverrides::getWebInstaller( $wgRequest );
if ( !$installer->startSession() ) {
-
if ( $installer->request->getVal( "css" ) ) {
// Do not display errors on css pages
$installer->outputCss();
<?xml version="1.0"?>
<ruleset name="MediaWiki">
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
+ <exclude name="Generic.ControlStructures.InlineControlStructure" />
+ <!-- Rule will pass in 0.10.0 but update depends on T167168 -->
+ <exclude name="MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace" />
<!-- Disable rules added in 0.8.0 that don't pass yet -->
<exclude name="MediaWiki.Commenting.FunctionComment.ExtraParamComment" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamComment" />
<exclude name="MediaWiki.Commenting.IllegalSingleLineComment.IllegalSingleLineCommentEnd" />
<exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
- <exclude name="MediaWiki.WhiteSpace.DisallowEmptyLineFunctions.NoEmptyLine" />
- <exclude name="MediaWiki.WhiteSpace.SpaceBeforeControlStructureBrace.EmptyLines" />
- <exclude name="MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.SingleSpaceBeforeSingleLineComment" />
<exclude name="MediaWiki.Usage.DbrQueryUsage.DbrQueryFound" />
<property name="ignoreList" type="array" value="$IP,$messageMemc,$parserMemc" />
</properties>
</rule>
- <file>.</file>
- <arg name="encoding" value="UTF-8"/>
- <arg name="extensions" value="php,php5,inc,sample"/>
<rule ref="Generic.Files.LineLength">
<exclude-pattern>*/languages/messages/Messages*.php</exclude-pattern>
</rule>
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<exclude-pattern>*/includes/StubObject.php</exclude-pattern>
</rule>
- <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed">
- <severity>0</severity>
- </rule>
+ <file>.</file>
+ <arg name="encoding" value="UTF-8"/>
+ <arg name="extensions" value="php,php5,inc,sample"/>
<exclude-pattern>node_modules/</exclude-pattern>
<exclude-pattern>vendor/</exclude-pattern>
<exclude-pattern type="relative">^extensions/</exclude-pattern>
private function addCoreDBData() {
if ( $this->db->getType() == 'oracle' ) {
-
# Insert 0 user to prevent FK violations
# Anonymous user
if ( !$this->db->selectField( 'user', '1', [ 'user_id' => 0 ] ) ) {
if ( !isset( $wgNamespaceContentModels[$ns] ) ||
$wgNamespaceContentModels[$ns] === CONTENT_MODEL_WIKITEXT
) {
-
$wikitextNS = $ns;
return $wikitextNS;
* @covers ::wfClientAcceptsGzip
*/
public function testClientAcceptsGzipTest() {
-
$settings = [
'gzip' => true,
'bzip' => false,
* @covers ::wfPercent
*/
public function testWfPercentTest() {
-
$pcts = [
[ 6 / 7, '0.86%', 2, false ],
[ 3 / 3, '1%' ],
* @dataProvider provideCasesForFormatLinksInComment
*/
public function testFormatLinksInComment( $expected, $input, $wiki ) {
-
$conf = new SiteConfiguration();
$conf->settings = [
'wgServer' => [
}
public function testWatchAndUnWatchItem() {
-
$user = $this->getUser();
$title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
// Cleanup after previous tests
}
public function execute() {
-
$getOptSpec = [
'dictionaryFile::',
'minWidth::',
* Test basic lists
*/
public function testAllTogether() {
-
// All props together
$this->check( $this->merge(
self::$links,
public function makeEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid,
$timestamp, $counter, $watchingUsers
) {
-
$attribs = array_merge(
$this->getDefaultAttributes( $titleText, $timestamp ),
[
public function makeNewBotEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid,
$timestamp, $counter, $watchingUsers
) {
-
$attribs = array_merge(
$this->getDefaultAttributes( $titleText, $timestamp ),
[
public function makeCategorizationRecentChange(
User $user, $titleText, $curid, $thisid, $lastid, $timestamp
) {
-
$attribs = array_merge(
$this->getDefaultAttributes( $titleText, $timestamp ),
[
}
public function testImportForImportSource() {
-
$this->doImport( $this->importStreamSource );
// Imported title
* @depends testImportForImportSource
*/
public function testReImportForImportSource() {
-
$this->doImport( $this->importStreamSource );
// ReImported title
}
private function doImport( $importStreamSource ) {
-
$importer = new WikiImporter(
$importStreamSource->value,
MediaWikiServices::getInstance()->getMainConfig()
}
public function testFetch() {
-
$interwiki = $this->interwikiLookup->fetch( '' );
$this->assertNull( $interwiki );
* @covers XMPReader::checkParseSafety
*/
public function testCheckParseSafety() {
-
// Test for detection
$xmpPath = __DIR__ . '/../../../data/xmp/';
$file = fopen( $xmpPath . 'doctype-included.xmp', 'rb' );
}
public function handleRequestProvider() {
-
$cases = [];
$cases[] = [ '', [], [], '!!', 400 ];
}
public static function provideGetMetadata() {
-
$xmpNugget = <<<EOF
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
}
public function testGetPoliciesForUser() {
-
$upp = $this->getUserPasswordPolicy();
$user = User::newFromName( 'TestUserPolicy' );
* @dataProvider provideCheckUserPassword
*/
public function testCheckUserPassword( $username, $groups, $password, $valid, $ok, $msg ) {
-
$upp = $this->getUserPasswordPolicy();
$user = User::newFromName( $username );
* @todo give this test a real name explaining what is being tested here
*/
public function testBug41337() {
-
// Set a low limit
$this->setMwGlobals( 'wgMaxSigChars', 2 );
* @dataProvider basicProvider
*/
public function testBasic( ForeignTitle $title, $expectedId, $expectedName,
- $expectedText ) {
-
+ $expectedText
+ ) {
$this->assertEquals( true, $title->isNamespaceIdKnown() );
$this->assertEquals( $expectedId, $title->getNamespaceId() );
$this->assertEquals( $expectedName, $title->getNamespaceName() );
* @dataProvider basicProvider
*/
public function testBasic( $title, $ns, ForeignTitle $foreignTitle ) {
-
$foreignNamespaces = [
0 => '', 1 => 'Talk', 100 => 'Portal', 9000 => 'Bogus'
];
* @dataProvider basicProvider
*/
public function testBasic( ForeignTitle $foreignTitle, Title $rootPage,
- Title $title ) {
-
+ Title $title
+ ) {
$factory = new SubpageImportTitleFactory( $rootPage );
$testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
* Test vectors from Appendix A on https://tools.ietf.org/html/rfc5869
*/
public static function providerRfc5869() {
-
// @codingStandardsIgnoreStart Generic.Files.LineLength
return [
// A.1
* @param string $name Title of the current page
*/
protected function assertPageStart( $id, $ns, $name ) {
-
$this->assertNodeStart( "page" );
$this->skipWhitespace();
if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
&& ( $this->xml->name == "text" )
) {
-
$this->xml->read();
}
$this->skipWhitespace();
* Simulates what Maintenance wants to happen at script's end.
*/
public function simulateShutdown() {
-
if ( $this->shutdownSimulated ) {
$this->testCase->fail( __METHOD__ . " called more than once" );
}
* after shutdown simulation.
*/
private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
-
$this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
"Output before shutdown simulation" );
// duration. If the dump did not take long enough increase the iteration
// count, to generate a bigger stub file next time.
while ( $lastDuration < $minDuration ) {
-
// Setting up the dump
wfRecursiveRemoveDir( $nameOutputDir );
$this->assertTrue( wfMkdirParents( $nameOutputDir ),
// Each run of the following loop body tries to handle exactly 1 /page/ (not
// iteration of stub content). $i is only increased after having treated page 4.
for ( $i = 0; $i < $iterations; ) {
-
// 1. Assuring a file is opened and ready. Skipping across header if
// necessary.
if ( !$fileOpened ) {
$content = $header;
$iterations = intval( $iterations );
for ( $i = 0; $i < $iterations; $i++ ) {
-
$page1 = ' <page>
<title>BackupDumperTestP1</title>
<ns>0</ns>
private function assertLogItem( $id, $user_name, $user_id, $comment, $type,
$subtype, $title, $parameters = []
) {
-
$this->assertNodeStart( "logitem" );
$this->skipWhitespace();
return {
setup: function () {
-
// Greetings, mock environment!
mw.config = new MwMap();
mw.config.set( freshConfigCopy( localEnv.config ) );