Just another 80 or so PHPStorm inspection fixes (#4)
* Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
This commit is contained in:
parent
317b460500
commit
be3018b268
61 changed files with 51 additions and 94 deletions
|
|
@ -1406,7 +1406,7 @@ MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function isEmptyObject( stdClass $obj ) {
|
private static function isEmptyObject( stdClass $obj ) {
|
||||||
foreach ( $obj as $key => $value ) {
|
foreach ( $obj as $value ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ class ReflectionSchemaSource implements SettingsSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizeComment( string $doc ) {
|
private function normalizeComment( string $doc ) {
|
||||||
$doc = preg_replace( '/^\s*\/\*+\s*|\s*\*+\/\s*$/s', '', $doc );
|
$doc = preg_replace( '/^\s*\/\*+\s*|\s*\*+\/\s*$/', '', $doc );
|
||||||
$doc = preg_replace( '/^\s*\**$/m', " ", $doc );
|
$doc = preg_replace( '/^\s*\**$/m', " ", $doc );
|
||||||
$doc = preg_replace( '/^\s*\**[ \t]?/m', '', $doc );
|
$doc = preg_replace( '/^\s*\**[ \t]?/m', '', $doc );
|
||||||
return $doc;
|
return $doc;
|
||||||
|
|
|
||||||
|
|
@ -1348,8 +1348,7 @@ class WebRequest {
|
||||||
*/
|
*/
|
||||||
public static function canonicalizeIPv6LoopbackAddress( $ip ) {
|
public static function canonicalizeIPv6LoopbackAddress( $ip ) {
|
||||||
// Code moved from IPUtils library. See T248237#6614927
|
// Code moved from IPUtils library. See T248237#6614927
|
||||||
$m = [];
|
if ( preg_match( '/^0*' . IPUtils::RE_IPV6_GAP . '1$/', $ip ) ) {
|
||||||
if ( preg_match( '/^0*' . IPUtils::RE_IPV6_GAP . '1$/', $ip, $m ) ) {
|
|
||||||
return '127.0.0.1';
|
return '127.0.0.1';
|
||||||
}
|
}
|
||||||
return $ip;
|
return $ip;
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,6 @@ class HistoryPager extends ReverseChronologicalPager {
|
||||||
$classes = [];
|
$classes = [];
|
||||||
|
|
||||||
$del = '';
|
$del = '';
|
||||||
$user = $this->getUser();
|
|
||||||
$canRevDelete = $this->getAuthority()->isAllowed( 'deleterevision' );
|
$canRevDelete = $this->getAuthority()->isAllowed( 'deleterevision' );
|
||||||
// Show checkboxes for each revision, to allow for revision deletion and
|
// Show checkboxes for each revision, to allow for revision deletion and
|
||||||
// change tags
|
// change tags
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class WikiTextStructure {
|
||||||
$heading = preg_replace( '/<\/?span>/', '', $heading );
|
$heading = preg_replace( '/<\/?span>/', '', $heading );
|
||||||
// Normalize [] so the following regexp would work.
|
// Normalize [] so the following regexp would work.
|
||||||
$heading = preg_replace( [ '/[/', '/]/' ], [ '[', ']' ], $heading );
|
$heading = preg_replace( [ '/[/', '/]/' ], [ '[', ']' ], $heading );
|
||||||
$heading = preg_replace( '/<sup>\s*\[\s*\d+\s*\]\s*<\/sup>/is', '', $heading );
|
$heading = preg_replace( '/<sup>\s*\[\s*\d+\s*\]\s*<\/sup>/i', '', $heading );
|
||||||
|
|
||||||
// Strip tags from the heading or else we'll display them (escaped) in search results
|
// Strip tags from the heading or else we'll display them (escaped) in search results
|
||||||
$heading = trim( Sanitizer::stripAllTags( $heading ) );
|
$heading = trim( Sanitizer::stripAllTags( $heading ) );
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ class SearchUpdate implements DeferrableUpdate {
|
||||||
# Strip HTML markup
|
# Strip HTML markup
|
||||||
$text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/",
|
$text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/",
|
||||||
' ', $contLang->lc( " " . $text . " " ) );
|
' ', $contLang->lc( " " . $text . " " ) );
|
||||||
$text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD",
|
$text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/",
|
||||||
"\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings
|
"\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings
|
||||||
|
|
||||||
# Strip external URLs
|
# Strip external URLs
|
||||||
|
|
|
||||||
|
|
@ -1581,7 +1581,7 @@ abstract class Installer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables
|
// phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables
|
||||||
global $wgAutoloadClasses, $wgExtensionDirectory, $wgStyleDirectory;
|
global $wgExtensionDirectory, $wgStyleDirectory;
|
||||||
$wgExtensionDirectory = "$IP/extensions";
|
$wgExtensionDirectory = "$IP/extensions";
|
||||||
$wgStyleDirectory = "$IP/skins";
|
$wgStyleDirectory = "$IP/skins";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1047,7 +1047,7 @@ EOF;
|
||||||
* @return bool True if $text appears to be written in $variant
|
* @return bool True if $text appears to be written in $variant
|
||||||
*/
|
*/
|
||||||
public function guessVariant( $text, $variant ) {
|
public function guessVariant( $text, $variant ) {
|
||||||
$hasBalinese = preg_match( "/[\x{1B00}-\x{1B7F}]/u", $text, $dummy );
|
$hasBalinese = preg_match( "/[\x{1B00}-\x{1B7F}]/u", $text );
|
||||||
return ( $variant == 'ban-bali' ) == $hasBalinese;
|
return ( $variant == 'ban-bali' ) == $hasBalinese;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class LanguageCu extends Language {
|
||||||
# join and array_slice instead mb_substr
|
# join and array_slice instead mb_substr
|
||||||
$ar = [];
|
$ar = [];
|
||||||
preg_match_all( '/./us', $word, $ar );
|
preg_match_all( '/./us', $word, $ar );
|
||||||
if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
|
if ( !preg_match( "/[a-zA-Z_]/u", $word ) ) {
|
||||||
switch ( $case ) {
|
switch ( $case ) {
|
||||||
case 'genitive': # родительный падеж
|
case 'genitive': # родительный падеж
|
||||||
if ( ( implode( '', array_slice( $ar[0], -4 ) ) == 'вики' )
|
if ( ( implode( '', array_slice( $ar[0], -4 ) ) == 'вики' )
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class LanguageHy extends Language {
|
||||||
# join and array_slice instead mb_substr
|
# join and array_slice instead mb_substr
|
||||||
$ar = [];
|
$ar = [];
|
||||||
preg_match_all( '/./us', $word, $ar );
|
preg_match_all( '/./us', $word, $ar );
|
||||||
if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
|
if ( !preg_match( "/[a-zA-Z_]/u", $word ) ) {
|
||||||
switch ( $case ) {
|
switch ( $case ) {
|
||||||
case 'genitive': # սեռական հոլով
|
case 'genitive': # սեռական հոլով
|
||||||
if ( implode( '', array_slice( $ar[0], -1 ) ) == 'ա' ) {
|
if ( implode( '', array_slice( $ar[0], -1 ) ) == 'ա' ) {
|
||||||
|
|
|
||||||
|
|
@ -275,8 +275,6 @@ class RedisBagOStuff extends MediumSpecificBagOStuff {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doDeleteMulti( array $keys, $flags = 0 ) {
|
protected function doDeleteMulti( array $keys, $flags = 0 ) {
|
||||||
$result = true;
|
|
||||||
|
|
||||||
[ $keysByServer, $connByServer, $result ] = $this->getConnectionsForKeys( $keys );
|
[ $keysByServer, $connByServer, $result ] = $this->getConnectionsForKeys( $keys );
|
||||||
foreach ( $keysByServer as $server => $batchKeys ) {
|
foreach ( $keysByServer as $server => $batchKeys ) {
|
||||||
$conn = $connByServer[$server];
|
$conn = $connByServer[$server];
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,8 @@ class GeneralizedSql {
|
||||||
|
|
||||||
# All numbers => N,
|
# All numbers => N,
|
||||||
# except the ones surrounded by characters, e.g. l10n
|
# except the ones surrounded by characters, e.g. l10n
|
||||||
$sql = preg_replace( '/-?\d+(,-?\d+)+/s', 'N,...,N', $sql );
|
$sql = preg_replace( '/-?\d+(,-?\d+)+/', 'N,...,N', $sql );
|
||||||
$sql = preg_replace( '/(?<![a-zA-Z])-?\d+(?![a-zA-Z])/s', 'N', $sql );
|
$sql = preg_replace( '/(?<![a-zA-Z])-?\d+(?![a-zA-Z])/', 'N', $sql );
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -467,7 +467,6 @@ class Linker {
|
||||||
|
|
||||||
if ( !$thumb ) {
|
if ( !$thumb ) {
|
||||||
$rdfaType = 'mw:Error ' . $rdfaType;
|
$rdfaType = 'mw:Error ' . $rdfaType;
|
||||||
$label = '';
|
|
||||||
if ( $enableLegacyMediaDOM ) {
|
if ( $enableLegacyMediaDOM ) {
|
||||||
$label = $frameParams['title'];
|
$label = $frameParams['title'];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ class CoreMagicVariables {
|
||||||
LoggerInterface $logger
|
LoggerInterface $logger
|
||||||
): ?string {
|
): ?string {
|
||||||
$pageLang = $parser->getTargetLanguage();
|
$pageLang = $parser->getTargetLanguage();
|
||||||
$title = $parser->getTitle();
|
|
||||||
|
|
||||||
switch ( $id ) {
|
switch ( $id ) {
|
||||||
case '!':
|
case '!':
|
||||||
|
|
|
||||||
|
|
@ -5545,7 +5545,7 @@ class Parser {
|
||||||
if ( $value === '' ) {
|
if ( $value === '' ) {
|
||||||
$type = 'no-link';
|
$type = 'no-link';
|
||||||
} elseif ( preg_match( "/^((?i)$prots)/", $value ) ) {
|
} elseif ( preg_match( "/^((?i)$prots)/", $value ) ) {
|
||||||
if ( preg_match( "/^((?i)$prots)$addr$chars*$/u", $value, $m ) ) {
|
if ( preg_match( "/^((?i)$prots)$addr$chars*$/u", $value ) ) {
|
||||||
$this->mOutput->addExternalLink( $value );
|
$this->mOutput->addExternalLink( $value );
|
||||||
$type = 'link-url';
|
$type = 'link-url';
|
||||||
$target = $value;
|
$target = $value;
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,6 @@ class SkinComponentListItem implements SkinComponent {
|
||||||
if ( isset( $item['itemtitle'] ) ) {
|
if ( isset( $item['itemtitle'] ) ) {
|
||||||
$attrs['title'] = $item['itemtitle'];
|
$attrs['title'] = $item['itemtitle'];
|
||||||
}
|
}
|
||||||
$tag = $this->options['tag'] ?? 'li';
|
|
||||||
// Making sure we always have strings as class values
|
// Making sure we always have strings as class values
|
||||||
$classes = is_array( $attrs['class'] ) ?
|
$classes = is_array( $attrs['class'] ) ?
|
||||||
implode( ' ', $attrs['class'] ) :
|
implode( ' ', $attrs['class'] ) :
|
||||||
|
|
|
||||||
|
|
@ -1374,21 +1374,21 @@ abstract class UploadBase {
|
||||||
$chunk = Sanitizer::decodeCharReferences( $chunk );
|
$chunk = Sanitizer::decodeCharReferences( $chunk );
|
||||||
|
|
||||||
# look for script-types
|
# look for script-types
|
||||||
if ( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) ) {
|
if ( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!im', $chunk ) ) {
|
||||||
wfDebug( __METHOD__ . ": found script types" );
|
wfDebug( __METHOD__ . ": found script types" );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# look for html-style script-urls
|
# look for html-style script-urls
|
||||||
if ( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
|
if ( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!im', $chunk ) ) {
|
||||||
wfDebug( __METHOD__ . ": found html-style script urls" );
|
wfDebug( __METHOD__ . ": found html-style script urls" );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# look for css-style script-urls
|
# look for css-style script-urls
|
||||||
if ( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
|
if ( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!im', $chunk ) ) {
|
||||||
wfDebug( __METHOD__ . ": found css-style script urls" );
|
wfDebug( __METHOD__ . ": found css-style script urls" );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1420,7 +1420,7 @@ abstract class UploadBase {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} elseif ( preg_match( "!<\?xml\b!si", $contents ) ) {
|
} elseif ( preg_match( "!<\?xml\b!i", $contents ) ) {
|
||||||
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
|
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
|
||||||
// bytes. There shouldn't be a legitimate reason for this to happen.
|
// bytes. There shouldn't be a legitimate reason for this to happen.
|
||||||
wfDebug( __METHOD__ . ": Unmatched XML declaration start" );
|
wfDebug( __METHOD__ . ": Unmatched XML declaration start" );
|
||||||
|
|
@ -1448,7 +1448,7 @@ abstract class UploadBase {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} elseif ( $str != '' && preg_match( "!<\?xml\b!si", $str ) ) {
|
} elseif ( $str != '' && preg_match( "!<\?xml\b!i", $str ) ) {
|
||||||
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
|
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
|
||||||
// bytes. There shouldn't be a legitimate reason for this to happen.
|
// bytes. There shouldn't be a legitimate reason for this to happen.
|
||||||
wfDebug( __METHOD__ . ": Unmatched XML declaration start" );
|
wfDebug( __METHOD__ . ": Unmatched XML declaration start" );
|
||||||
|
|
@ -1729,7 +1729,7 @@ abstract class UploadBase {
|
||||||
# use set to add a remote / data / script target to an element
|
# use set to add a remote / data / script target to an element
|
||||||
if ( $strippedElement === 'set'
|
if ( $strippedElement === 'set'
|
||||||
&& $stripped === 'to'
|
&& $stripped === 'to'
|
||||||
&& preg_match( '!(http|https|data|script):!sim', $value )
|
&& preg_match( '!(http|https|data|script):!im', $value )
|
||||||
) {
|
) {
|
||||||
wfDebug( __METHOD__ . ": Found svg setting attribute to '$value' in uploaded file." );
|
wfDebug( __METHOD__ . ": Found svg setting attribute to '$value' in uploaded file." );
|
||||||
|
|
||||||
|
|
@ -1737,7 +1737,7 @@ abstract class UploadBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
# use handler attribute with remote / data / script
|
# use handler attribute with remote / data / script
|
||||||
if ( $stripped === 'handler' && preg_match( '!(http|https|data|script):!sim', $value ) ) {
|
if ( $stripped === 'handler' && preg_match( '!(http|https|data|script):!im', $value ) ) {
|
||||||
wfDebug( __METHOD__ . ": Found svg setting handler with remote/data/script "
|
wfDebug( __METHOD__ . ": Found svg setting handler with remote/data/script "
|
||||||
. "'$attrib'='$value' in uploaded file." );
|
. "'$attrib'='$value' in uploaded file." );
|
||||||
|
|
||||||
|
|
@ -1768,7 +1768,7 @@ abstract class UploadBase {
|
||||||
# Only allow url( "#foo" ). Do not allow url( http://example.com )
|
# Only allow url( "#foo" ). Do not allow url( http://example.com )
|
||||||
if ( $strippedElement === 'image'
|
if ( $strippedElement === 'image'
|
||||||
&& $stripped === 'filter'
|
&& $stripped === 'filter'
|
||||||
&& preg_match( '!url\s*\(\s*["\']?[^#]!sim', $value )
|
&& preg_match( '!url\s*\(\s*["\']?[^#]!im', $value )
|
||||||
) {
|
) {
|
||||||
wfDebug( __METHOD__ . ": Found image filter with url: "
|
wfDebug( __METHOD__ . ": Found image filter with url: "
|
||||||
. "\"<$strippedElement $stripped='$value'...\" in uploaded file." );
|
. "\"<$strippedElement $stripped='$value'...\" in uploaded file." );
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,8 @@ class CleanupSpam extends Maintenance {
|
||||||
->where( $conds )
|
->where( $conds )
|
||||||
->caller( __METHOD__ )
|
->caller( __METHOD__ )
|
||||||
->fetchResultSet();
|
->fetchResultSet();
|
||||||
$count = $res->numRows();
|
$count += $res->numRows();
|
||||||
$this->output( "Found $count articles containing $spec\n" );
|
$this->output( "Found $count articles containing $spec so far...\n" );
|
||||||
foreach ( $res as $row ) {
|
foreach ( $res as $row ) {
|
||||||
$this->cleanupArticle(
|
$this->cleanupArticle(
|
||||||
$row->el_from,
|
$row->el_from,
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,11 @@ class MWDoxygenFilter {
|
||||||
// wrongly interpreted as a Doxygen "\command".
|
// wrongly interpreted as a Doxygen "\command".
|
||||||
$content = addcslashes( $content, '\\' );
|
$content = addcslashes( $content, '\\' );
|
||||||
// Look for instances of "@var SomeType".
|
// Look for instances of "@var SomeType".
|
||||||
if ( preg_match( '#@var\s+\S+#s', $content ) ) {
|
if ( preg_match( '#@var\s+\S+#', $content ) ) {
|
||||||
$buffer = [ 'raw' => $content, 'desc' => null, 'type' => null, 'name' => null ];
|
$buffer = [ 'raw' => $content, 'desc' => null, 'type' => null, 'name' => null ];
|
||||||
$buffer['desc'] = preg_replace_callback(
|
$buffer['desc'] = preg_replace_callback(
|
||||||
// Strip "@var SomeType" part, but remember the type and optional name
|
// Strip "@var SomeType" part, but remember the type and optional name
|
||||||
'#@var\s+(\S+)(\s+)?(\S+)?#s',
|
'#@var\s+(\S+)(\s+)?(\S+)?#',
|
||||||
static function ( $matches ) use ( &$buffer ) {
|
static function ( $matches ) use ( &$buffer ) {
|
||||||
$buffer['type'] = $matches[1];
|
$buffer['type'] = $matches[1];
|
||||||
$buffer['name'] = $matches[3] ?? null;
|
$buffer['name'] = $matches[3] ?? null;
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ class GenerateCollationData extends Maintenance {
|
||||||
|
|
||||||
public $debugOutFile;
|
public $debugOutFile;
|
||||||
|
|
||||||
|
private $groups;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->addOption( 'data-dir', 'A directory on the local filesystem ' .
|
$this->addOption( 'data-dir', 'A directory on the local filesystem ' .
|
||||||
|
|
|
||||||
|
|
@ -623,8 +623,6 @@ class CommentStoreTest extends MediaWikiLangTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideInsertRoundTrip() {
|
public static function provideInsertRoundTrip() {
|
||||||
$db = wfGetDB( DB_REPLICA ); // for timestamps
|
|
||||||
|
|
||||||
$msgComment = new Message( 'parentheses', [ 'message comment' ] );
|
$msgComment = new Message( 'parentheses', [ 'message comment' ] );
|
||||||
$textCommentMsg = new RawMessage( '$1', [ Message::plaintextParam( '{{text}} comment' ) ] );
|
$textCommentMsg = new RawMessage( '$1', [ Message::plaintextParam( '{{text}} comment' ) ] );
|
||||||
$nestedMsgComment = new Message( [ 'parentheses', 'rawmessage' ], [ new Message( 'mainpage' ) ] );
|
$nestedMsgComment = new Message( [ 'parentheses', 'rawmessage' ], [ new Message( 'mainpage' ) ] );
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,6 @@ class ExtraParserTest extends MediaWikiIntegrationTestCase {
|
||||||
* @covers Parser::cleanSig
|
* @covers Parser::cleanSig
|
||||||
*/
|
*/
|
||||||
public function testCleanSig() {
|
public function testCleanSig() {
|
||||||
$title = Title::newFromText( __FUNCTION__ );
|
|
||||||
$outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
|
$outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
|
||||||
|
|
||||||
$this->assertEquals( "{{SUBST:Foo}} ", $outputText );
|
$this->assertEquals( "{{SUBST:Foo}} ", $outputText );
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ class GlobalTest extends MediaWikiIntegrationTestCase {
|
||||||
$this->markTestSkippedIfNoDiff3();
|
$this->markTestSkippedIfNoDiff3();
|
||||||
|
|
||||||
$mergedText = null;
|
$mergedText = null;
|
||||||
$attemptMergeResult = null;
|
$mergeAttemptResult = null;
|
||||||
$isMerged = wfMerge( $old, $mine, $yours, $mergedText, $mergeAttemptResult );
|
$isMerged = wfMerge( $old, $mine, $yours, $mergedText, $mergeAttemptResult );
|
||||||
|
|
||||||
$msg = 'Merge should be a ';
|
$msg = 'Merge should be a ';
|
||||||
|
|
|
||||||
|
|
@ -1406,7 +1406,6 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
// We don't reset the categories, for some reason, only the links
|
// We don't reset the categories, for some reason, only the links
|
||||||
$expectedNormalCats = array_merge( [ 'Initial page' ], $expectedNormal );
|
$expectedNormalCats = array_merge( [ 'Initial page' ], $expectedNormal );
|
||||||
$expectedCats = array_merge( $expectedHidden, $expectedNormalCats );
|
|
||||||
|
|
||||||
$this->doCategoryAsserts( $op, $expectedNormalCats, $expectedHidden );
|
$this->doCategoryAsserts( $op, $expectedNormalCats, $expectedHidden );
|
||||||
$this->doCategoryLinkAsserts( $op, $expectedNormal, $expectedHidden );
|
$this->doCategoryLinkAsserts( $op, $expectedNormal, $expectedHidden );
|
||||||
|
|
|
||||||
|
|
@ -939,12 +939,12 @@ END
|
||||||
'startup response undisrupted (T152266)'
|
'startup response undisrupted (T152266)'
|
||||||
);
|
);
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
'/register\([^)]+"ferry",\s*""/s',
|
'/register\([^)]+"ferry",\s*""/',
|
||||||
$response,
|
$response,
|
||||||
'startup response registers broken module'
|
'startup response registers broken module'
|
||||||
);
|
);
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
'/state\([^)]+"ferry":\s*"error"/s',
|
'/state\([^)]+"ferry":\s*"error"/',
|
||||||
$response,
|
$response,
|
||||||
'startup response sets state to error'
|
'startup response sets state to error'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ class ApiBlockTest extends ApiTestCase {
|
||||||
|
|
||||||
public function testBlockWithRestrictionsPage() {
|
public function testBlockWithRestrictionsPage() {
|
||||||
$title = 'Foo';
|
$title = 'Foo';
|
||||||
$page = $this->getExistingTestPage( $title );
|
$this->getExistingTestPage( $title );
|
||||||
|
|
||||||
$this->doBlock( [
|
$this->doBlock( [
|
||||||
'partial' => true,
|
'partial' => true,
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ class ApiDeleteTest extends ApiTestCase {
|
||||||
// test deletion without permission
|
// test deletion without permission
|
||||||
try {
|
try {
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$apiResult = $this->doApiRequest( [
|
$this->doApiRequest( [
|
||||||
'action' => 'delete',
|
'action' => 'delete',
|
||||||
'title' => $name,
|
'title' => $name,
|
||||||
'token' => $user->getEditToken(),
|
'token' => $user->getEditToken(),
|
||||||
|
|
|
||||||
|
|
@ -892,7 +892,6 @@ class ApiEditPageTest extends ApiTestCase {
|
||||||
// to insert new revision rows at once and the first one to succeed
|
// to insert new revision rows at once and the first one to succeed
|
||||||
// gets rolled back.
|
// gets rolled back.
|
||||||
$name = 'Help:' . ucfirst( __FUNCTION__ );
|
$name = 'Help:' . ucfirst( __FUNCTION__ );
|
||||||
$titleObj = Title::newFromText( $name );
|
|
||||||
|
|
||||||
$revId1 = $this->editPage( $name, '1' )->getNewRevision()->getId();
|
$revId1 = $this->editPage( $name, '1' )->getNewRevision()->getId();
|
||||||
$revId2 = $this->editPage( $name, '2' )->getNewRevision()->getId();
|
$revId2 = $this->editPage( $name, '2' )->getNewRevision()->getId();
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,6 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
|
||||||
$aboutpage = wfMessage( 'aboutpage' );
|
$aboutpage = wfMessage( 'aboutpage' );
|
||||||
$mainpage = wfMessage( 'mainpage' );
|
$mainpage = wfMessage( 'mainpage' );
|
||||||
$parens = wfMessage( 'parentheses', 'foobar' );
|
$parens = wfMessage( 'parentheses', 'foobar' );
|
||||||
$brackets = wfMessage( 'brackets', 'foobar' );
|
|
||||||
$copyright = wfMessage( 'copyright' );
|
$copyright = wfMessage( 'copyright' );
|
||||||
$disclaimers = wfMessage( 'disclaimers' );
|
$disclaimers = wfMessage( 'disclaimers' );
|
||||||
$edithelp = wfMessage( 'edithelp' );
|
$edithelp = wfMessage( 'edithelp' );
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,6 @@ class ApiPageSetTest extends ApiTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRedirectMergePolicyRedirectLoop() {
|
public function testRedirectMergePolicyRedirectLoop() {
|
||||||
$loopA = Title::makeTitle( NS_MAIN, 'UTPageRedirectOne' );
|
|
||||||
$loopB = Title::makeTitle( NS_MAIN, 'UTPageRedirectTwo' );
|
|
||||||
$this->editPage( 'UTPageRedirectOne', '#REDIRECT [[UTPageRedirectTwo]]' );
|
$this->editPage( 'UTPageRedirectOne', '#REDIRECT [[UTPageRedirectTwo]]' );
|
||||||
$this->editPage( 'UTPageRedirectTwo', '#REDIRECT [[UTPageRedirectOne]]' );
|
$this->editPage( 'UTPageRedirectTwo', '#REDIRECT [[UTPageRedirectOne]]' );
|
||||||
[ $target, $pageSet ] = $this->createPageSetWithRedirect(
|
[ $target, $pageSet ] = $this->createPageSetWithRedirect(
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@ class ApiParseTest extends ApiTestCase {
|
||||||
protected static $revIds = [];
|
protected static $revIds = [];
|
||||||
|
|
||||||
public function addDBDataOnce() {
|
public function addDBDataOnce() {
|
||||||
$title = Title::newFromText( __CLASS__ );
|
|
||||||
|
|
||||||
$status = $this->editPage( __CLASS__, 'Test for revdel' );
|
$status = $this->editPage( __CLASS__, 'Test for revdel' );
|
||||||
self::$pageId = $status->getNewRevision()->getPageId();
|
self::$pageId = $status->getNewRevision()->getPageId();
|
||||||
self::$revIds['revdel'] = $status->getNewRevision()->getId();
|
self::$revIds['revdel'] = $status->getNewRevision()->getId();
|
||||||
|
|
@ -110,7 +108,7 @@ class ApiParseTest extends ApiTestCase {
|
||||||
$this->assertSame( $expectedEnd, substr( $html, -strlen( $expectedEnd ) ) );
|
$this->assertSame( $expectedEnd, substr( $html, -strlen( $expectedEnd ) ) );
|
||||||
|
|
||||||
$unexpectedEnd = '#<!-- \nNewPP limit report|' .
|
$unexpectedEnd = '#<!-- \nNewPP limit report|' .
|
||||||
'<!--\nTransclusion expansion time report#s';
|
'<!--\nTransclusion expansion time report#';
|
||||||
$this->assertDoesNotMatchRegularExpression( $unexpectedEnd, $html );
|
$this->assertDoesNotMatchRegularExpression( $unexpectedEnd, $html );
|
||||||
|
|
||||||
$html = substr( $html, 0, strlen( $html ) - strlen( $expectedEnd ) );
|
$html = substr( $html, 0, strlen( $html ) - strlen( $expectedEnd ) );
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,6 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $val['name'] === 'viscount' ) {
|
if ( $val['name'] === 'viscount' ) {
|
||||||
$viscountFound = true;
|
|
||||||
$this->assertSame( [ 'perambulate' ], $val['rights'] );
|
$this->assertSame( [ 'perambulate' ], $val['rights'] );
|
||||||
$this->assertSame( $userAllGroups, $val['add'] );
|
$this->assertSame( $userAllGroups, $val['add'] );
|
||||||
} elseif ( $val['name'] === 'bot' ) {
|
} elseif ( $val['name'] === 'bot' ) {
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ class AbstractPrimaryAuthenticationProviderTest extends \MediaWikiIntegrationTes
|
||||||
} catch ( \BadMethodCallException $ex ) {
|
} catch ( \BadMethodCallException $ex ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$req = $this->getMockForAbstractClass( AuthenticationRequest::class );
|
|
||||||
|
|
||||||
$this->assertTrue( $provider->providerAllowsPropertyChange( 'foo' ) );
|
$this->assertTrue( $provider->providerAllowsPropertyChange( 'foo' ) );
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
\StatusValue::newGood(),
|
\StatusValue::newGood(),
|
||||||
|
|
|
||||||
|
|
@ -1144,7 +1144,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
AuthManagerLoginAuthenticateAuditHook::class, $this->never() );
|
AuthManagerLoginAuthenticateAuditHook::class, $this->never() );
|
||||||
}
|
}
|
||||||
|
|
||||||
$ex = null;
|
|
||||||
try {
|
try {
|
||||||
if ( !$i ) {
|
if ( !$i ) {
|
||||||
$ret = $this->manager->beginAuthentication( [ $req ], 'http://localhost/' );
|
$ret = $this->manager->beginAuthentication( [ $req ], 'http://localhost/' );
|
||||||
|
|
@ -2259,7 +2258,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
$this->hook( 'LocalUserCreated', LocalUserCreatedHook::class, $this->never() );
|
$this->hook( 'LocalUserCreated', LocalUserCreatedHook::class, $this->never() );
|
||||||
}
|
}
|
||||||
|
|
||||||
$ex = null;
|
|
||||||
try {
|
try {
|
||||||
if ( $first ) {
|
if ( $first ) {
|
||||||
$userReq = new UsernameAuthenticationRequest;
|
$userReq = new UsernameAuthenticationRequest;
|
||||||
|
|
@ -3096,7 +3094,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
->willReturn( $good );
|
->willReturn( $good );
|
||||||
}
|
}
|
||||||
|
|
||||||
$primaries = [];
|
|
||||||
foreach ( [
|
foreach ( [
|
||||||
PrimaryAuthenticationProvider::TYPE_NONE,
|
PrimaryAuthenticationProvider::TYPE_NONE,
|
||||||
PrimaryAuthenticationProvider::TYPE_CREATE,
|
PrimaryAuthenticationProvider::TYPE_CREATE,
|
||||||
|
|
@ -3276,8 +3273,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
return $ret;
|
return $ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
$good = StatusValue::newGood();
|
|
||||||
|
|
||||||
$primary1 = $this->createMock( AbstractPrimaryAuthenticationProvider::class );
|
$primary1 = $this->createMock( AbstractPrimaryAuthenticationProvider::class );
|
||||||
$primary1->method( 'getUniqueId' )
|
$primary1->method( 'getUniqueId' )
|
||||||
->willReturn( 'primary1' );
|
->willReturn( 'primary1' );
|
||||||
|
|
@ -3706,7 +3701,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$first = true;
|
$first = true;
|
||||||
$created = false;
|
|
||||||
$expectLog = [];
|
$expectLog = [];
|
||||||
foreach ( $managerResponses as $i => $response ) {
|
foreach ( $managerResponses as $i => $response ) {
|
||||||
if ( $response instanceof AuthenticationResponse &&
|
if ( $response instanceof AuthenticationResponse &&
|
||||||
|
|
@ -3715,7 +3709,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
$expectLog[] = [ LogLevel::INFO, 'Account linked to {user} by primary' ];
|
$expectLog[] = [ LogLevel::INFO, 'Account linked to {user} by primary' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ex = null;
|
|
||||||
try {
|
try {
|
||||||
if ( $first ) {
|
if ( $first ) {
|
||||||
$ret = $this->manager->beginAccountLink( $user, [ $req ], 'http://localhost/' );
|
$ret = $this->manager->beginAccountLink( $user, [ $req ], 'http://localhost/' );
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ class AuthenticationRequestTest extends \MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
$fields = AuthenticationRequest::mergeFieldInfo( [ $req1 ] );
|
$fields = AuthenticationRequest::mergeFieldInfo( [ $req1 ] );
|
||||||
$expect = $req1->getFieldInfo();
|
$expect = $req1->getFieldInfo();
|
||||||
foreach ( $expect as $name => &$options ) {
|
foreach ( $expect as &$options ) {
|
||||||
$options['optional'] = !empty( $options['optional'] );
|
$options['optional'] = !empty( $options['optional'] );
|
||||||
$options['sensitive'] = !empty( $options['sensitive'] );
|
$options['sensitive'] = !empty( $options['sensitive'] );
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +253,7 @@ class AuthenticationRequestTest extends \MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
$fields = AuthenticationRequest::mergeFieldInfo( [ $req1, $req2 ] );
|
$fields = AuthenticationRequest::mergeFieldInfo( [ $req1, $req2 ] );
|
||||||
$expect = $req1->getFieldInfo() + $req2->getFieldInfo();
|
$expect = $req1->getFieldInfo() + $req2->getFieldInfo();
|
||||||
foreach ( $expect as $name => &$options ) {
|
foreach ( $expect as &$options ) {
|
||||||
$options['sensitive'] = !empty( $options['sensitive'] );
|
$options['sensitive'] = !empty( $options['sensitive'] );
|
||||||
}
|
}
|
||||||
$expect['string1']['optional'] = false;
|
$expect['string1']['optional'] = false;
|
||||||
|
|
|
||||||
|
|
@ -288,7 +288,7 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
||||||
] );
|
] );
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
AuthenticationResponse::newPass(),
|
AuthenticationResponse::newPass(),
|
||||||
$res = $provider->continueLinkAttempt( $user, 'state', [ $req ] )
|
$provider->continueLinkAttempt( $user, 'state', [ $req ] )
|
||||||
);
|
);
|
||||||
$this->assertSame( [ false, false, false ], $done );
|
$this->assertSame( [ false, false, false ], $done );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -673,10 +673,6 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
||||||
$expect->createRequest->username = 'Foo';
|
$expect->createRequest->username = 'Foo';
|
||||||
$this->assertEquals( $expect, $provider->beginPrimaryAccountCreation( $user, $user, $reqs ) );
|
$this->assertEquals( $expect, $provider->beginPrimaryAccountCreation( $user, $user, $reqs ) );
|
||||||
|
|
||||||
// We have to cheat a bit to avoid having to add a new user to
|
|
||||||
// the database to test the actual setting of the password works right
|
|
||||||
$dbw = wfGetDB( DB_PRIMARY );
|
|
||||||
|
|
||||||
$user = \User::newFromName( 'UTSysop' );
|
$user = \User::newFromName( 'UTSysop' );
|
||||||
$req->username = $user->getName();
|
$req->username = $user->getName();
|
||||||
$req->password = 'NewPassword';
|
$req->password = 'NewPassword';
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ just a test"
|
||||||
"0",
|
"0",
|
||||||
"No more",
|
"No more",
|
||||||
null,
|
null,
|
||||||
trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) )
|
trim( preg_replace( '/^Intro/m', 'No more', self::$sections ) )
|
||||||
],
|
],
|
||||||
[ self::$sections,
|
[ self::$sections,
|
||||||
"",
|
"",
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ class FileTest extends MediaWikiMediaTestCase {
|
||||||
$reflection_property->setValue( $fileMock, $handlerMock );
|
$reflection_property->setValue( $fileMock, $handlerMock );
|
||||||
|
|
||||||
if ( $data['tmpBucketedThumbCache'] !== null ) {
|
if ( $data['tmpBucketedThumbCache'] !== null ) {
|
||||||
foreach ( $data['tmpBucketedThumbCache'] as $bucket => &$tmpBucketed ) {
|
foreach ( $data['tmpBucketedThumbCache'] as &$tmpBucketed ) {
|
||||||
$tmpBucketed = str_replace( '/tmp', $tempDir, $tmpBucketed );
|
$tmpBucketed = str_replace( '/tmp', $tempDir, $tmpBucketed );
|
||||||
}
|
}
|
||||||
$reflection_property = $reflection->getProperty( 'tmpBucketedThumbCache' );
|
$reflection_property = $reflection->getProperty( 'tmpBucketedThumbCache' );
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,6 @@ class GuzzleHttpRequestTest extends MediaWikiIntegrationTestCase {
|
||||||
$history = Middleware::history( $container );
|
$history = Middleware::history( $container );
|
||||||
$stack = HandlerStack::create( new MockHandler( [ new Response() ] ) );
|
$stack = HandlerStack::create( new MockHandler( [ new Response() ] ) );
|
||||||
$stack->push( $history );
|
$stack->push( $history );
|
||||||
$boundary = 'boundary';
|
|
||||||
$client = new GuzzleHttpRequest( $this->exampleUrl, [
|
$client = new GuzzleHttpRequest( $this->exampleUrl, [
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ class ImportExportTest extends MediaWikiLangTestCase {
|
||||||
|
|
||||||
$n = 1;
|
$n = 1;
|
||||||
$revisions = $this->getRevisions( $title );
|
$revisions = $this->getRevisions( $title );
|
||||||
foreach ( $revisions as $i => $rev ) {
|
foreach ( $revisions as $rev ) {
|
||||||
$revkey = "{$name}_rev" . $n++;
|
$revkey = "{$name}_rev" . $n++;
|
||||||
|
|
||||||
$vars[ $revkey . '_id' ] = $rev->getId();
|
$vars[ $revkey . '_id' ] = $rev->getId();
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,6 @@ abstract class GenericArrayObjectTest extends PHPUnit\Framework\TestCase {
|
||||||
* @param callable $function
|
* @param callable $function
|
||||||
*/
|
*/
|
||||||
protected function checkTypeChecks( $function ) {
|
protected function checkTypeChecks( $function ) {
|
||||||
$excption = null;
|
|
||||||
$list = $this->getNew();
|
$list = $this->getNew();
|
||||||
|
|
||||||
$elementClass = $list->getObjectType();
|
$elementClass = $list->getObjectType();
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ class JpegTest extends MediaWikiMediaTestCase {
|
||||||
|
|
||||||
copy( $sourceFilepath, $filepath );
|
copy( $sourceFilepath, $filepath );
|
||||||
|
|
||||||
$file = $this->dataFile( $sourceFilename, 'image/jpeg' );
|
|
||||||
$this->handler->swapICCProfile(
|
$this->handler->swapICCProfile(
|
||||||
$filepath,
|
$filepath,
|
||||||
[ 'sRGB', '-' ],
|
[ 'sRGB', '-' ],
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ class ParserOutputAccessTest extends MediaWikiIntegrationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = preg_replace( '/<!--.*?-->/s', '', $value );
|
$html = preg_replace( '/<!--.*?-->/s', '', $value );
|
||||||
$html = trim( preg_replace( '/[\r\n]{2,}/s', "\n", $html ) );
|
$html = trim( preg_replace( '/[\r\n]{2,}/', "\n", $html ) );
|
||||||
$html = trim( preg_replace( '/\s{2,}/s', ' ', $html ) );
|
$html = trim( preg_replace( '/\s{2,}/', ' ', $html ) );
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1121,7 +1121,7 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
||||||
$text = $po->getText();
|
$text = $po->getText();
|
||||||
|
|
||||||
$text = trim( preg_replace( '/<!--.*?-->/sm', '', $text ) ); # strip injected comments
|
$text = trim( preg_replace( '/<!--.*?-->/sm', '', $text ) ); # strip injected comments
|
||||||
$text = preg_replace( '!\s*(</p>|</div>)!sm', '\1', $text ); # don't let tidy confuse us
|
$text = preg_replace( '!\s*(</p>|</div>)!m', '\1', $text ); # don't let tidy confuse us
|
||||||
|
|
||||||
$this->assertEquals( $expectedHtml, $text );
|
$this->assertEquals( $expectedHtml, $text );
|
||||||
}
|
}
|
||||||
|
|
@ -1175,7 +1175,7 @@ more stuff
|
||||||
"0",
|
"0",
|
||||||
"No more",
|
"No more",
|
||||||
null,
|
null,
|
||||||
trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) )
|
trim( preg_replace( '/^Intro/m', 'No more', self::$sections ) )
|
||||||
],
|
],
|
||||||
[ 'Help:WikiPageTest_testReplaceSection',
|
[ 'Help:WikiPageTest_testReplaceSection',
|
||||||
CONTENT_MODEL_WIKITEXT,
|
CONTENT_MODEL_WIKITEXT,
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mockSearchWithResults( $titleStrings, $limit = 3 ) {
|
private function mockSearchWithResults( $titleStrings, $limit = 3 ) {
|
||||||
$search = $stub = $this->getMockBuilder( SearchEngine::class )
|
$search = $this->getMockBuilder( SearchEngine::class )
|
||||||
->onlyMethods( [ 'completionSearchBackend' ] )->getMock();
|
->onlyMethods( [ 'completionSearchBackend' ] )->getMock();
|
||||||
|
|
||||||
$return = SearchSuggestionSet::fromStrings( $titleStrings );
|
$return = SearchSuggestionSet::fromStrings( $titleStrings );
|
||||||
|
|
|
||||||
|
|
@ -471,7 +471,6 @@ class CookieSessionProviderTest extends MediaWikiIntegrationTestCase {
|
||||||
$backend->setRememberUser( true );
|
$backend->setRememberUser( true );
|
||||||
$backend->setForceHTTPS( true );
|
$backend->setForceHTTPS( true );
|
||||||
$request = new \MediaWiki\Request\FauxRequest();
|
$request = new \MediaWiki\Request\FauxRequest();
|
||||||
$time = time();
|
|
||||||
$provider->persistSession( $backend, $request );
|
$provider->persistSession( $backend, $request );
|
||||||
$this->assertSame( $sessionId, $request->response()->getCookie( 'MySessionName' ) );
|
$this->assertSame( $sessionId, $request->response()->getCookie( 'MySessionName' ) );
|
||||||
$this->assertSame( (string)$user->getId(), $request->response()->getCookie( 'xUserID' ) );
|
$this->assertSame( (string)$user->getId(), $request->response()->getCookie( 'xUserID' ) );
|
||||||
|
|
|
||||||
|
|
@ -439,7 +439,6 @@ class SessionManagerTest extends MediaWikiIntegrationTestCase {
|
||||||
public function testGetEmptySession() {
|
public function testGetEmptySession() {
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$pmanager = TestingAccessWrapper::newFromObject( $manager );
|
$pmanager = TestingAccessWrapper::newFromObject( $manager );
|
||||||
$request = new \MediaWiki\Request\FauxRequest();
|
|
||||||
|
|
||||||
$providerBuilder = $this->getMockBuilder( \DummySessionProvider::class )
|
$providerBuilder = $this->getMockBuilder( \DummySessionProvider::class )
|
||||||
->onlyMethods( [ 'provideSessionInfo', 'newSessionInfo', '__toString' ] );
|
->onlyMethods( [ 'provideSessionInfo', 'newSessionInfo', '__toString' ] );
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,6 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
$this->assertObjectNotHasAttribute( 'ipb_restrictions', $row );
|
$this->assertObjectNotHasAttribute( 'ipb_restrictions', $row );
|
||||||
|
|
||||||
$pageName = 'Victor Frankenstein';
|
|
||||||
$page = $this->getExistingTestPage( 'Victor Frankenstein' );
|
$page = $this->getExistingTestPage( 'Victor Frankenstein' );
|
||||||
$title = $page->getTitle();
|
$title = $page->getTitle();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -530,7 +530,7 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$m = $this->getMigration( $stage );
|
$m = $this->getMigration( $stage );
|
||||||
$result = $m->getWhere( $this->db, 'am1_user', 'Foo' );
|
$m->getWhere( $this->db, 'am1_user', 'Foo' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,6 @@ class BotPasswordTest extends MediaWikiIntegrationTestCase {
|
||||||
$this->assertEquals( '{"IPAddresses":["127.0.0.0/8"]}', $bp->getRestrictions()->toJson() );
|
$this->assertEquals( '{"IPAddresses":["127.0.0.0/8"]}', $bp->getRestrictions()->toJson() );
|
||||||
$this->assertSame( [ 'test' ], $bp->getGrants() );
|
$this->assertSame( [ 'test' ], $bp->getGrants() );
|
||||||
|
|
||||||
$user = $this->testUser->getUser();
|
|
||||||
$bp = BotPassword::newUnsaved( [
|
$bp = BotPassword::newUnsaved( [
|
||||||
'centralId' => 45,
|
'centralId' => 45,
|
||||||
'appId' => 'DoesNotExist'
|
'appId' => 'DoesNotExist'
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,8 @@ class ParsoidOutputAccessTest extends MediaWikiIntegrationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = preg_replace( '/<!--.*?-->/s', '', $value );
|
$html = preg_replace( '/<!--.*?-->/s', '', $value );
|
||||||
$html = trim( preg_replace( '/[\r\n]{2,}/s', "\n", $html ) );
|
$html = trim( preg_replace( '/[\r\n]{2,}/', "\n", $html ) );
|
||||||
$html = trim( preg_replace( '/\s{2,}/s', ' ', $html ) );
|
$html = trim( preg_replace( '/\s{2,}/', ' ', $html ) );
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
|
||||||
$targetToken = $userFactory->newFromUserIdentity( $block->getTargetUserIdentity() )->getToken();
|
$targetToken = $userFactory->newFromUserIdentity( $block->getTargetUserIdentity() )->getToken();
|
||||||
|
|
||||||
$store = $this->getStore( $options );
|
$store = $this->getStore( $options );
|
||||||
$result = $store->insertBlock( $block );
|
$store->insertBlock( $block );
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$expectTokenEqual,
|
$expectTokenEqual,
|
||||||
|
|
|
||||||
|
|
@ -222,8 +222,6 @@ class PoolCounterWorkTest extends MediaWikiIntegrationTestCase {
|
||||||
* @covers ::execute
|
* @covers ::execute
|
||||||
*/
|
*/
|
||||||
public function testDoWorkRaiseException() {
|
public function testDoWorkRaiseException() {
|
||||||
$workerResults = 'SomeStringForResult';
|
|
||||||
|
|
||||||
$worker = $this->configureFixture(
|
$worker = $this->configureFixture(
|
||||||
[ 'doWork' => $this->throwException( new MWException() ) ],
|
[ 'doWork' => $this->throwException( new MWException() ) ],
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -678,7 +678,7 @@ class DumpAsserter {
|
||||||
*/
|
*/
|
||||||
public function stripTestTags( $text ) {
|
public function stripTestTags( $text ) {
|
||||||
$text = preg_replace( '@<!--.*?-->@s', '', $text );
|
$text = preg_replace( '@<!--.*?-->@s', '', $text );
|
||||||
$text = preg_replace( '@</?test:[^>]+>@s', '', $text );
|
$text = preg_replace( '@</?test:[^>]+>@', '', $text );
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,6 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
|
||||||
// Setting up of the dump
|
// Setting up of the dump
|
||||||
$nameStub = $this->setUpStub( 'AllStubs', $wgXmlDumpSchemaVersion );
|
$nameStub = $this->setUpStub( 'AllStubs', $wgXmlDumpSchemaVersion );
|
||||||
$nameFull = $this->getNewTempFile();
|
$nameFull = $this->getNewTempFile();
|
||||||
$expFile = $this->getDumpTemplatePath( 'AllText', $wgXmlDumpSchemaVersion );
|
|
||||||
|
|
||||||
$dumper = new TextPassDumper( [ "--stub=file:" . $nameStub,
|
$dumper = new TextPassDumper( [ "--stub=file:" . $nameStub,
|
||||||
"--output=file:" . $nameFull ] );
|
"--output=file:" . $nameFull ] );
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class ParsoidTestFileSuite extends TestSuite {
|
||||||
}
|
}
|
||||||
$testModes = $t->computeTestModes( $validTestModes );
|
$testModes = $t->computeTestModes( $validTestModes );
|
||||||
$t->testAllModes( $testModes, $runner->getOptions(),
|
$t->testAllModes( $testModes, $runner->getOptions(),
|
||||||
// $options is being ignored but it is identical to $runnerOpts
|
// $options is being ignored but it is identical to $runner->getOptions()
|
||||||
function ( ParserTest $test, string $modeStr, array $options ) use (
|
function ( ParserTest $test, string $modeStr, array $options ) use (
|
||||||
$t, $suite, $fileName, $skipMessage
|
$t, $suite, $fileName, $skipMessage
|
||||||
) {
|
) {
|
||||||
|
|
@ -72,7 +72,6 @@ class ParsoidTestFileSuite extends TestSuite {
|
||||||
// Ensure that updates to knownFailures in $test are reflected in $t
|
// Ensure that updates to knownFailures in $test are reflected in $t
|
||||||
$test->knownFailures = &$t->knownFailures;
|
$test->knownFailures = &$t->knownFailures;
|
||||||
$runner = $this->ptRunner;
|
$runner = $this->ptRunner;
|
||||||
$runnerOpts = $runner->getOptions();
|
|
||||||
$mode = new ParserTestMode( $modeStr, $test->changetree );
|
$mode = new ParserTestMode( $modeStr, $test->changetree );
|
||||||
$pit = new ParserIntegrationTest( $runner, $fileName, $test, $mode, $skipMessage );
|
$pit = new ParserIntegrationTest( $runner, $fileName, $test, $mode, $skipMessage );
|
||||||
$suite->addTest( $pit, [ 'Database', 'Parser', 'ParserTests' ] );
|
$suite->addTest( $pit, [ 'Database', 'Parser', 'ParserTests' ] );
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ class FileSourceTest extends TestCase {
|
||||||
|
|
||||||
public function testLoad() {
|
public function testLoad() {
|
||||||
$source = new FileSource( __DIR__ . '/fixtures/settings.json' );
|
$source = new FileSource( __DIR__ . '/fixtures/settings.json' );
|
||||||
$settings = $source->load();
|
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
[ 'config' => [ 'MySetting' => 'BlaBla' ] ],
|
[ 'config' => [ 'MySetting' => 'BlaBla' ] ],
|
||||||
|
|
@ -28,7 +27,6 @@ class FileSourceTest extends TestCase {
|
||||||
|
|
||||||
public function testLoadFormat() {
|
public function testLoadFormat() {
|
||||||
$source = new FileSource( __DIR__ . '/fixtures/settings.json', new JsonFormat() );
|
$source = new FileSource( __DIR__ . '/fixtures/settings.json', new JsonFormat() );
|
||||||
$settings = $source->load();
|
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
[ 'config' => [ 'MySetting' => 'BlaBla' ] ],
|
[ 'config' => [ 'MySetting' => 'BlaBla' ] ],
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class ChangesListFilterTest extends MediaWikiUnitTestCase {
|
||||||
$this->expectExceptionMessage(
|
$this->expectExceptionMessage(
|
||||||
"Filter names may not contain '_'. Use the naming convention: 'lowercase'"
|
"Filter names may not contain '_'. Use the naming convention: 'lowercase'"
|
||||||
);
|
);
|
||||||
$filter = new MockChangesListFilter(
|
new MockChangesListFilter(
|
||||||
[
|
[
|
||||||
'group' => $this->group,
|
'group' => $this->group,
|
||||||
'name' => 'some_name',
|
'name' => 'some_name',
|
||||||
|
|
|
||||||
|
|
@ -612,7 +612,6 @@ class DatabaseTest extends PHPUnit\Framework\TestCase {
|
||||||
$this->assertEquals( $ud->getId(), $this->db->getDomainID() );
|
$this->assertEquals( $ud->getId(), $this->db->getDomainID() );
|
||||||
|
|
||||||
$oldDomain = $this->db->getDomainID();
|
$oldDomain = $this->db->getDomainID();
|
||||||
$oldDbName = $this->db->getDBname();
|
|
||||||
$oldSchema = $this->db->dbSchema();
|
$oldSchema = $this->db->dbSchema();
|
||||||
$oldPrefix = $this->db->tablePrefix();
|
$oldPrefix = $this->db->tablePrefix();
|
||||||
$this->assertIsString( $oldDomain, 'DB domain is string' );
|
$this->assertIsString( $oldDomain, 'DB domain is string' );
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ function wfProxyThumbnailRequest( $img, $thumbName ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send request to proxied service
|
// Send request to proxied service
|
||||||
$status = $req->execute();
|
$req->execute();
|
||||||
|
|
||||||
\MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
|
\MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue