# Or we could throw an exception:
# throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
}
-
}
/**
}
}
}
-
}
}
// Allow extensions to modify form data
Hooks::run( 'EditPage::importFormData', [ $this, $request ] );
-
}
/**
* @return bool
*/
private function mergeChangesIntoContent( &$editContent ) {
-
$db = wfGetDB( DB_MASTER );
// This is the revision the editor started from
if ( !$wgUser->getOption( 'previewontop' ) ) {
$this->displayPreviewArea( $previewOutput, false );
}
-
}
/**
return Html::rawElement( 'div', [ 'class' => 'templatesUsed' ],
$templateListFormatter->format( $templates, $type )
);
-
}
/**
$wgOut->addVaryHeader( 'X-Forwarded-Proto' );
}
$wgOut->sendCacheControl();
-
}
/**
} else {
$oldInstance->destroy();
}
-
}
/**
$popts->setTidy( $oldTidy );
$this->addParserOutput( $parserOutput );
-
}
/**
'section' => 'editing/preview',
'label-message' => 'tog-uselivepreview',
];
-
}
/**
* @return string
*/
function getButtons() {
-
$attrs = [ 'id' => 'mw-prefs-restoreprefs' ];
if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
$fragment,
$this->getInterwiki()
);
-
}
/**
# Cycle through all the restrictions.
foreach ( $rows as $row ) {
-
// Don't take care of restrictions types that aren't allowed
if ( !in_array( $row->pr_type, $restrictionTypes ) ) {
continue;
: $wgExemptFromUserRobotsControl;
return !in_array( $this->mNamespace, $bannedNamespaces );
-
}
/**
Xml::label( $msg->text(), $attrs['id'] ),
Xml::tags( 'select', $attrs, $options )
];
-
}
/**
$pager->getNavigationBar()
);
$out->preventClickjacking( $pager->getPreventClickjacking() );
-
}
/**
ApiResult::setIndexedTagName( $data, 'library' );
return $this->getResult()->addValue( 'query', $property, $data );
-
}
protected function appendExtensions( $property ) {
* @param string $caller The calling method
*/
public function doQuery( array $userIds, $options = [], $caller = '' ) {
-
$usersToCheck = [];
$usersToQuery = [];
}
}
$lb->execute();
-
}
/**
* @return array Array with a 'messages' key, or empty array if the file doesn't exist
*/
public function readJSONFile( $fileName ) {
-
if ( !is_readable( $fileName ) ) {
return [];
}
$data = FormatJson::decode( $json, true );
if ( $data === null ) {
-
throw new MWException( __METHOD__ . ": Invalid JSON file: $fileName" );
}
$blobStore = new MessageBlobStore();
$blobStore->clear();
}
-
}
/**
# Perform the actual update
$search->update( $this->id, $normalTitle, $search->normalizeText( $text ) );
}
-
}
/**
* @param string[] $linesAfter
*/
public function __construct( $linesBefore, $linesAfter ) {
-
list( $wordsBefore, $wordsBeforeStripped ) = $this->split( $linesBefore );
list( $wordsAfter, $wordsAfterStripped ) = $this->split( $linesAfter );
$yi += count( $closing );
}
}
-
}
/**
* @return array[]
*/
private function split( $lines ) {
-
$words = [];
$stripped = [];
$first = true;
} else {
$this->fileExists = false;
}
-
}
/**
* Load lazy file metadata from the DB
*/
protected function loadExtraFromDB() {
-
$this->extraDataLoaded = true;
$dbr = $this->repo->getSlaveDB();
$conds = [ 'oi_name' => $this->getName() ];
} else {
throw new MWException( "Could not find data for image '{$this->archive_name}'." );
}
-
}
/**
$this->mOptions = [ $params['other'] => 'other' ] + $this->mOptions;
}
$this->mFlatOptions = self::flattenOptions( $this->getOptions() );
-
}
public function getInputHTML( $value ) {
$this->mAllValue = array_key_exists( 'all', $params )
? $params['all']
: 'all';
-
}
public function getInputHTML( $value ) {
// Have 'other' always as first element
$this->mOptions = [ $msg => 'other' ] + $this->mOptions;
}
-
}
public function getInputHTML( $value ) {
* @return Status
*/
public function execute() {
-
$this->content = "";
if ( strtoupper( $this->method ) == "HEAD" ) {
if ( !isset( $this->reqHeaders['User-Agent'] ) ) {
$this->setUserAgent( Http::userAgent() );
}
-
}
/**
* found in an array in the member variable headerList.
*/
protected function parseHeader() {
-
$lastname = "";
foreach ( $this->headerList as $header ) {
}
$this->parseCookies();
-
}
/**
* Parse the cookies in the response headers and store them in the cookie jar.
*/
protected function parseCookies() {
-
if ( !$this->cookieJar ) {
$this->cookieJar = new CookieJar;
}
$this->cookieJar->parseCookieResponseHeader( $cookie, $url['host'] );
}
}
-
}
/**
$services->redefineService( 'DBLoadBalancerFactory', function() use ( $connection ) {
return LBFactorySingle::newFromConnection( $connection );
} );
-
}
/**
}, $source );
return $source;
-
}
/**
return isset( $params['headers'] )
? $this->getCustomHeaders( $params['headers'] )
: [];
-
}
/**
}
private function validate( $reader ) {
-
// First, move through anything that isn't an element, and
// handle any processing instructions with the callback
do {
// NOTATION, or XML_DECLARATION
// xml_parse didn't send these to the filter, so we won't.
}
-
} while ( $this->readNext( $reader ) );
if ( $this->stackDepth !== 0 ) {
} elseif ( $this->wellFormed === null ) {
$this->wellFormed = true;
}
-
}
/**
continue;
}
if ( $targetWiki !== 'local' ) {
-
throw new Exception( "Only 'local' target wiki is currently supported" );
}
if ( $reqType !== 'page' && $reqType !== 'transform' ) {
* API. We now translate these to the "real" Parsoid v3 API.
*/
public function onParsoid1Request( array $req, Closure $idGeneratorFunc ) {
-
$parts = explode( '/', $req['url'] );
list(
$targetWiki, // 'local'
}
return $req;
-
}
}
}
public function onRequests( array $reqs, Closure $idGenFunc ) {
-
if ( $this->params['parsoidCompat'] ) {
return $this->onParsoidRequests( $reqs, $idGenFunc );
}
* Remaps Parsoid v1/v3 requests to RESTBase v1 requests.
*/
public function onParsoidRequests( array $reqs, Closure $idGeneratorFunc ) {
-
$result = [];
foreach ( $reqs as $key => $req ) {
$version = explode( '/', $req['url'] )[1];
}
return $result;
-
}
/**
}
return $req;
-
}
/**
* * $revision is optional
*/
public function onParsoid3Request( array $req, Closure $idGeneratorFunc ) {
-
$parts = explode( '/', $req['url'] );
list(
$targetWiki, // 'local'
}
return $req;
-
}
}
unset( $tags['ResolutionUnit'] );
foreach ( $tags as $tag => &$vals ) {
-
// This seems ugly to wrap non-array's in an array just to unwrap again,
// especially when most of the time it is not an array
if ( !is_array( $tags[$tag] ) ) {
}
foreach ( $vals as &$val ) {
-
switch ( $tag ) {
case 'Compression':
switch ( $val ) {
protected function getExtendedMetadataFromHook( File $file, array $extendedMetadata,
&$maxCacheTime
) {
-
Hooks::run( 'GetExtendedMetadata', [
&$extendedMetadata,
$file,
$field['value'] = $this->resolveMultivalueValue( $field['value'] );
}
}
-
}
/**
'filepage', // always show the local local Filepage.css, bug 29277
'mediawiki.action.view.filepage', // Add MediaWiki styles for a file page
] );
-
}
/**
* @param string $text
*/
public function replace( &$text ) {
-
$this->replaceInternal( $text );
$this->replaceInterwiki( $text );
-
}
/**
$replacer->cb(),
$text
);
-
}
/**
* @return string
*/
public function replaceText( $text ) {
-
$text = preg_replace_callback(
'/<!--(LINK|IWLINK) (.*?)-->/',
[ &$this, 'replaceTextCallback' ],
$this->mThumbSize = $user->getOption( 'thumbsize' );
$this->mStubThreshold = $user->getStubThreshold();
$this->mUserLang = $lang;
-
}
/**
}
}
}
-
}
/**
// Keep track of their names so that they can be loaded together
$this->testModuleNames[$id] = array_keys( $testModules[$id] );
}
-
}
/**
$this->errors = [];
echo $response;
-
}
/**
protected static function makeLoaderImplementScript(
$name, $scripts, $styles, $messages, $templates
) {
-
if ( $scripts instanceof XmlJsCode ) {
$scripts = new XmlJsCode( "function ( $, jQuery, require, module ) {\n{$scripts->value}\n}" );
} elseif ( !is_string( $scripts ) && !is_array( $scripts ) ) {
* @return string
*/
function parseQuery( $term ) {
-
wfDebug( "parseQuery received: $term \n" );
# # No backslashes allowed
wfDebug( "parseQuery returned: $searchstring \n" );
return $searchstring;
-
}
/**
if ( $content !== '' ) {
echo "<div class='after-portlet after-portlet-$name'>$content</div>";
}
-
}
/**
}
protected function setupTemplateForOutput() {
-
$request = $this->getRequest();
$user = $this->getUser();
$title = $this->getTitle();
if ( $oldContext ) {
$this->setContext( $oldContext );
}
-
}
/**
* @return array
*/
private function buildContentActionUrls( $content_navigation ) {
-
// content_actions has been replaced with content_navigation for backwards
// compatibility and also for skins that just want simple tabs content_actions
// is now built by flattening the content_navigation arrays into one
}
return $template;
-
}
public function onAuthChangeFormFields(
$out->addHTML( "</div>" );
Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] );
-
}
/**
* @return string
*/
protected function showHit( SearchResult $result, $terms, $position ) {
-
if ( $result->isBrokenTitle() ) {
return '';
}
* @return string
*/
protected function showInterwikiHit( $result, $lastInterwiki, $query ) {
-
if ( $result->isBrokenTitle() ) {
return '';
}
* @return bool
*/
protected function startsWithAll( $term ) {
-
$allkeyword = $this->msg( 'searchall' )->inContentLanguage()->text();
$parts = explode( ':', $term );
// Extensions
Hooks::run( 'GetBlockedStatus', [ &$this ] );
-
}
/**
* @return bool True if blacklisted.
*/
public function inDnsBlacklist( $ip, $bases ) {
-
$found = false;
// @todo FIXME: IPv6 ??? (http://bugs.php.net/bug.php?id=33170)
if ( IP::isIPv4( $ip ) ) {
} else {
return false;
}
-
}
}
* @return string
*/
function normalizeForSearch( $string, $autoVariant = 'zh-hans' ) {
-
// always convert to zh-hans before indexing. it should be
// better to use zh-hans for search, since conversion from
// Traditional to Simplified is less ambiguous than the
// LanguageZh_hans::normalizeForSearch
$s = parent::normalizeForSearch( $s );
return $s;
-
}
/**
* Add the default parameters to the scripts
*/
protected function addDefaultParams() {
-
# Generic (non script dependant) options:
$this->addOption( 'help', 'Display this help message', false, false, 'h' );
. "for this script to run: $joined. Please enable them and then try again.";
$this->error( $msg, 1 );
}
-
}
/**
// We couldn't find any out-of-date dependencies, so assume everything is ok!
$this->output( "Your composer.lock file is up to date with current dependencies!\n" );
}
-
}
}
} catch ( \Cdb\Exception $e ) {
$this->error( "Error writing cdb file: " . $e->getMessage(), 2 );
}
-
}
}
$this->sectionLineNum = [];
$this->sectionData = [];
$this->section = null;
-
}
/**
$this->assertEquals( 'master', $gitInfo->getCurrentBranch() );
$this->assertContains( '0123456789abcdef0123456789abcdef01234567',
$gitInfo->getHeadViewUrl() );
-
}
public function testValidJsonData() {
* @covers Html::expandAttributes
*/
public function testExpandAttributesSkipsNullAndFalse() {
-
# ## EMPTY ########
$this->assertEmpty(
Html::expandAttributes( [ 'foo' => null ] ),
Html::expandAttributes( [ 'zero' => 0 ] ),
'Number 0 value needs no quotes'
);
-
}
/**
class LinkFilterTest extends MediaWikiLangTestCase {
protected function setUp() {
-
parent::setUp();
$this->setMwGlobals( 'wgUrlProtocols', [
'mms://',
'//',
] );
-
}
/**
* @return string Regex
*/
function createRegexFromLIKE( $like ) {
-
$regex = '!^';
foreach ( $like as $item ) {
-
if ( $item instanceof LikeMatch ) {
if ( $item->toString() == '%' ) {
$regex .= '.*';
$regex .= '$!';
return $regex;
-
}
/**
* @return array
*/
public static function provideValidPatterns() {
-
return [
// Protocol, Search pattern, URL which matches the pattern
[ 'http://', '*.test.com', 'http://www.test.com' ],
// [ '', 'https://*.wikimedia.org/r/#/q/status:open,n,z',
// 'https://gerrit.wikimedia.org/XXX/r/#/q/status:open,n,z', false ],
];
-
}
/**
* @param bool $shouldBeFound Should the URL be found? (defaults true)
*/
function testMakeLikeArrayWithValidPatterns( $protocol, $pattern, $url, $shouldBeFound = true ) {
-
$indexes = wfMakeUrlIndexes( $url );
$likeArray = LinkFilter::makeLikeArray( $pattern, $protocol );
"Search pattern '$protocol$pattern' should not find url '$url' \n$debugmsg"
);
}
-
}
/**
* @return array
*/
public static function provideInvalidPatterns() {
-
return [
[ '' ],
[ '*' ],
[ 'test.com/*/index' ],
[ 'test.com/dir/index?arg=*' ],
];
-
}
/**
* @param string $pattern Invalid search pattern
*/
function testMakeLikeArrayWithInvalidPatterns( $pattern ) {
-
$this->assertFalse(
LinkFilter::makeLikeArray( $pattern ),
"'$pattern' is not a valid pattern and should be rejected"
);
-
}
}
}
protected function setProperties( $pageID, $properties ) {
-
$rows = [];
foreach ( $properties as $propertyName => $propertyValue ) {
-
$row = [
'pp_page' => $pageID,
'pp_propname' => $propertyName,
}
protected function setProperty( $pageID, $propertyName, $propertyValue ) {
-
$properties = [];
$properties[$propertyName] = $propertyValue;
$this->setProperties( $pageID, $properties );
-
}
}
$title->getParentCategories(),
'Verify that the page is no longer in the category after template deletion'
);
-
}
}
'Expected exception'
);
}
-
}
}
],
],
];
-
}
/**
'two' => 2,
], $arr['foo'] );
}
-
}
class ApiResultTestStringifiableObject {
$this->revs[] = Title::newFromText( self::$page )
->getLatestRevID( Title::GAID_FOR_UPDATE );
}
-
}
public function testHidingRevisions() {
$ex->getMessage()
);
}
-
}
public function testBeginAuthentication() {
$this->manager->removeAuthenticationSessionData( null );
$this->assertNull( $this->manager->getAuthenticationSessionData( 'foo' ) );
$this->assertNull( $this->manager->getAuthenticationSessionData( 'bar' ) );
-
}
public function testCanLinkAccounts() {
$authManager->setAuthenticationSessionData( 'no-email', true );
$provider->setManager( $authManager );
$provider->beginSecondaryAccountCreation( $userNotExpectsConfirmation, $creator, [] );
-
}
}
AuthenticationResponse::newPass( $userName ),
$provider->beginPrimaryAuthentication( $reqs )
);
-
}
/**
$this->assertNull( $provider->finishAccountCreation( $user, $user, $res2 ) );
$ret = $provider->beginPrimaryAuthentication( $reqs );
$this->assertEquals( AuthenticationResponse::PASS, $ret->status, 'new password is set' );
-
}
}
'wrongpassword',
$ret->message->getKey()
);
-
}
/**
$this->assertSame( $email ?: 'default@example.com', $user->getEmail() );
$this->assertSame( $realname ?: 'Fake Name', $user->getRealName() );
}
-
}
public static function providePopulateUser() {
* @dataProvider provideJsonSerializedKeys
*/
public function testJsonserializeexceptionKeys( $expectedKeyType, $exClass, $key ) {
-
# Make sure we log a backtrace:
$this->setMwGlobals( [ 'wgLogExceptionBacktrace' => true ] );
MWExceptionHandler::jsonSerializeException( new Exception() )
);
$this->assertObjectNotHasAttribute( 'backtrace', $json );
-
}
}
'wgScript' => '/w/index.php',
] );
$this->factory = MediaWikiServices::getInstance()->getLinkRendererFactory();
-
}
public function testMergeAttribs() {
$this->setMwGlobals( 'wgShowEXIF', true );
$this->handler = new ExifBitmapHandler;
-
}
/**
$ex->getMessage()
);
}
-
}
public function testHashToSessionId() {
$session->resetAllTokens();
$this->assertArrayNotHasKey( 'wsTokenSecrets', $backend->data );
-
}
/**
// let the user have a few (3) edits
$page = WikiPage::factory( Title::newFromText( 'Help:UserTest_EditCount' ) );
for ( $i = 0; $i < 3; $i++ ) {
-
$page->doEditContent(
ContentHandler::makeContent( (string)$i, $page->getTitle() ),
'test',
public function testGetId() {
$user = static::getTestUser()->getUser();
$this->assertTrue( $user->getId() > 0 );
-
}
/**