Change-Id: I1e6325b628359a557ceaa1e1ae30043aa5fc1402
$data = $this->getResultData();
if ( isset( $data['error'] ) ) {
$this->mErrorFallback->execute();
$data = $this->getResultData();
if ( isset( $data['error'] ) ) {
$this->mErrorFallback->execute();
// to avoid this.
$expected = "<wddxPacket version='1.0'><header/><data><string>\xc2\xa0</string></data></wddxPacket>";
if ( function_exists( 'wddx_serialize_value' )
// to avoid this.
$expected = "<wddxPacket version='1.0'><header/><data><string>\xc2\xa0</string></data></wddxPacket>";
if ( function_exists( 'wddx_serialize_value' )
- && !$this->getIsHtml()
- && wddx_serialize_value( "\xc2\xa0" ) == $expected ) {
+ && !$this->getIsHtml()
+ && wddx_serialize_value( "\xc2\xa0" ) == $expected
+ ) {
$this->printText( wddx_serialize_value( $this->getResultData() ) );
} else {
// Don't do newlines and indentation if we weren't asked
$this->printText( wddx_serialize_value( $this->getResultData() ) );
} else {
// Don't do newlines and indentation if we weren't asked
$this->printText(
self::recXmlPrint( $this->mRootElemName,
$data,
$this->printText(
self::recXmlPrint( $this->mRootElemName,
$data,
- $this->getIsHtml() ? - 2 : null
+ $this->getIsHtml() ? -2 : null
$retval .= $indstr . Xml::element( $elemName, null, $elemValue );
}
}
$retval .= $indstr . Xml::element( $elemName, null, $elemValue );
}
}
$nt = Title::newFromText( $this->mXslt );
if ( is_null( $nt ) || !$nt->exists() ) {
$this->setWarning( 'Invalid or non-existent stylesheet specified' );
$nt = Title::newFromText( $this->mXslt );
if ( is_null( $nt ) || !$nt->exists() ) {
$this->setWarning( 'Invalid or non-existent stylesheet specified' );
return;
}
if ( $nt->getNamespace() != NS_MEDIAWIKI ) {
$this->setWarning( 'Stylesheet should be in the MediaWiki namespace.' );
return;
}
if ( $nt->getNamespace() != NS_MEDIAWIKI ) {
$this->setWarning( 'Stylesheet should be in the MediaWiki namespace.' );
- if ( substr( $nt->getText(), - 4 ) !== '.xsl' ) {
+ if ( substr( $nt->getText(), -4 ) !== '.xsl' ) {
$this->setWarning( 'Stylesheet should have .xsl extension.' );
$this->setWarning( 'Stylesheet should have .xsl extension.' );
return;
}
$this->printText( '<?xml-stylesheet href="' . htmlspecialchars( $nt->getLocalURL( 'action=raw' ) ) . '" type="text/xsl" ?>' );
return;
}
$this->printText( '<?xml-stylesheet href="' . htmlspecialchars( $nt->getLocalURL( 'action=raw' ) ) . '" type="text/xsl" ?>' );
}
if ( $module === null ) {
if ( count( $subNames ) === 2
}
if ( $module === null ) {
if ( count( $subNames ) === 2
- && $i === 1
- && $subNames[0] === 'query'
- && in_array( $subNames[1], $queryModules )
+ && $i === 1
+ && $subNames[0] === 'query'
+ && in_array( $subNames[1], $queryModules )
) {
// Legacy: This is one of the renamed 'querymodule=...' parameters,
// do not use '+' notation in the output, use submodule's name instead.
) {
// Legacy: This is one of the renamed 'querymodule=...' parameters,
// do not use '+' notation in the output, use submodule's name instead.
if ( $this->mPageSet === null ) {
$this->mPageSet = new ApiPageSet( $this, 0, NS_FILE );
}
if ( $this->mPageSet === null ) {
$this->mPageSet = new ApiPageSet( $this, 0, NS_FILE );
}
return $this->mPageSet;
}
return $this->mPageSet;
}
if ( $permissionErrors ) {
// Just return the first error
$msg = $this->parseMsg( $permissionErrors[0] );
if ( $permissionErrors ) {
// Just return the first error
$msg = $this->parseMsg( $permissionErrors[0] );
if ( $flags ) {
$result += $this->getPageSet()->getFinalParams( $flags );
}
if ( $flags ) {
$result += $this->getPageSet()->getFinalParams( $flags );
}
return $result;
}
public function getParamDescription() {
$pageSet = $this->getPageSet();
return $result;
}
public function getParamDescription() {
$pageSet = $this->getPageSet();
return $pageSet->getFinalParamDescription() + array(
'rotation' => 'Degrees to rotate image clockwise',
'token' => 'Edit token. You can get one of these through action=tokens',
return $pageSet->getFinalParamDescription() + array(
'rotation' => 'Degrees to rotate image clockwise',
'token' => 'Edit token. You can get one of these through action=tokens',
public function getPossibleErrors() {
$pageSet = $this->getPageSet();
public function getPossibleErrors() {
$pageSet = $this->getPageSet();
return array_merge(
parent::getPossibleErrors(),
$pageSet->getFinalPossibleErrors()
return array_merge(
parent::getPossibleErrors(),
$pageSet->getFinalPossibleErrors()
public function getAllowedParams() {
global $wgImportSources;
public function getAllowedParams() {
global $wgImportSources;
return array(
'token' => array(
ApiBase::PARAM_TYPE => 'string',
return array(
'token' => array(
ApiBase::PARAM_TYPE => 'string',
'result' => 'Aborted',
'reason' => 'Cannot log in when using a callback',
) );
'result' => 'Aborted',
'reason' => 'Cannot log in when using a callback',
) );
$this->mResult = new ApiResult( $this );
$this->mEnableWrite = $enableWrite;
$this->mResult = new ApiResult( $this );
$this->mEnableWrite = $enableWrite;
- $this->mSquidMaxage = - 1; // flag for executeActionWithErrorHandling()
+ $this->mSquidMaxage = -1; // flag for executeActionWithErrorHandling()
$this->mCommit = false;
}
$this->mCommit = false;
}
public function setCacheMode( $mode ) {
if ( !in_array( $mode, array( 'private', 'public', 'anon-public-user-private' ) ) ) {
wfDebug( __METHOD__ . ": unrecognised cache mode \"$mode\"\n" );
public function setCacheMode( $mode ) {
if ( !in_array( $mode, array( 'private', 'public', 'anon-public-user-private' ) ) ) {
wfDebug( __METHOD__ . ": unrecognised cache mode \"$mode\"\n" );
// Ignore for forwards-compatibility
return;
}
// Ignore for forwards-compatibility
return;
}
// Private wiki, only private headers
if ( $mode !== 'private' ) {
wfDebug( __METHOD__ . ": ignoring request for $mode cache mode, private wiki\n" );
// Private wiki, only private headers
if ( $mode !== 'private' ) {
wfDebug( __METHOD__ . ": ignoring request for $mode cache mode, private wiki\n" );
if ( $printer === null ) {
$this->dieUsage( "Unrecognized format: {$format}", 'unknown_format' );
}
if ( $printer === null ) {
$this->dieUsage( "Unrecognized format: {$format}", 'unknown_format' );
}
$response->header( "HTTP/1.1 403 $message", true, 403 );
$response->header( 'Cache-Control: no-cache' );
echo "'origin' parameter does not match Origin header\n";
$response->header( "HTTP/1.1 403 $message", true, 403 );
$response->header( 'Cache-Control: no-cache' );
echo "'origin' parameter does not match Origin header\n";
return false;
}
if ( self::matchOrigin( $originParam, $wgCrossSiteAJAXdomains, $wgCrossSiteAJAXdomainExceptions ) ) {
return false;
}
if ( self::matchOrigin( $originParam, $wgCrossSiteAJAXdomains, $wgCrossSiteAJAXdomainExceptions ) ) {
$response->header( 'Access-Control-Allow-Credentials: true' );
$this->getOutput()->addVaryHeader( 'Origin' );
}
$response->header( 'Access-Control-Allow-Credentials: true' );
$this->getOutput()->addVaryHeader( 'Origin' );
}
array( '.*?', '.' ),
$wildcard
);
array( '.*?', '.' ),
$wildcard
);
return "/https?:\/\/$wildcard/";
}
return "/https?:\/\/$wildcard/";
}
if ( $this->mCacheMode == 'private' ) {
$response->header( 'Cache-Control: private' );
if ( $this->mCacheMode == 'private' ) {
$response->header( 'Cache-Control: private' );
if ( $out->haveCacheVaryCookies() ) {
// Logged in, mark this request private
$response->header( 'Cache-Control: private' );
if ( $out->haveCacheVaryCookies() ) {
// Logged in, mark this request private
$response->header( 'Cache-Control: private' );
return;
}
// Logged out, send normal public headers below
return;
}
// Logged out, send normal public headers below
// Logged in or otherwise has session (e.g. anonymous users who have edited)
// Mark request private
$response->header( 'Cache-Control: private' );
// Logged in or otherwise has session (e.g. anonymous users who have edited)
// Mark request private
$response->header( 'Cache-Control: private' );
return;
} // else no XVO and anonymous, send public headers below
}
return;
} // else no XVO and anonymous, send public headers below
}
// Sending a Vary header in this case is harmless, and protects us
// against conditional calls of setCacheMaxAge().
$response->header( 'Cache-Control: private' );
// Sending a Vary header in this case is harmless, and protects us
// against conditional calls of setCacheMaxAge().
$response->header( 'Cache-Control: private' );
} else {
$this->dieUsage( "Waiting for a database server: $lag seconds lagged", 'maxlag' );
}
} else {
$this->dieUsage( "Waiting for a database server: $lag seconds lagged", 'maxlag' );
}
protected function checkExecutePermissions( $module ) {
$user = $this->getUser();
if ( $module->isReadMode() && !User::isEveryoneAllowed( 'read' ) &&
protected function checkExecutePermissions( $module ) {
$user = $this->getUser();
if ( $module->isReadMode() && !User::isEveryoneAllowed( 'read' ) &&
- !$user->isAllowed( 'read' ) )
- {
+ !$user->isAllowed( 'read' )
+ ) {
$this->dieUsageMsg( 'readrequired' );
}
if ( $module->isWriteMode() ) {
$this->dieUsageMsg( 'readrequired' );
}
if ( $module->isWriteMode() ) {
$table[rawurlencode( $chars[$i] )] = $chars[$i];
}
}
$table[rawurlencode( $chars[$i] )] = $chars[$i];
}
}
return strtr( rawurlencode( $s ), $table );
}
return strtr( rawurlencode( $s ), $table );
}
*/
public function getVal( $name, $default = null ) {
$this->mParamsUsed[$name] = true;
*/
public function getVal( $name, $default = null ) {
$this->mParamsUsed[$name] = true;
return $this->getRequest()->getVal( $name, $default );
}
return $this->getRequest()->getVal( $name, $default );
}
*/
public function getCheck( $name ) {
$this->mParamsUsed[$name] = true;
*/
public function getCheck( $name ) {
$this->mParamsUsed[$name] = true;
return $this->getRequest()->getCheck( $name );
}
return $this->getRequest()->getCheck( $name );
}
*/
public function getUpload( $name ) {
$this->mParamsUsed[$name] = true;
*/
public function getUpload( $name ) {
$this->mParamsUsed[$name] = true;
return $this->getRequest()->getUpload( $name );
}
return $this->getRequest()->getUpload( $name );
}
// Printer has not yet executed; don't warn that its parameters are unused
$printerParams = array_map(
array( $this->mPrinter, 'encodeParamName' ),
// Printer has not yet executed; don't warn that its parameters are unused
$printerParams = array_map(
array( $this->mPrinter, 'encodeParamName' ),
- array_keys( $this->mPrinter->getFinalParams() ?: array() )
+ array_keys( $this->mPrinter->getFinalParams() ? : array() )
);
$unusedParams = array_diff( $allParams, $paramsUsed, $printerParams );
} else {
);
$unusedParams = array_diff( $allParams, $paramsUsed, $printerParams );
} else {
if ( $wgAPICacheHelpTimeout > 0 ) {
$wgMemc->set( $key, $retval, $wgAPICacheHelpTimeout );
}
if ( $wgAPICacheHelpTimeout > 0 ) {
$wgMemc->set( $key, $retval, $wgAPICacheHelpTimeout );
}
foreach ( self::$mRights as $right => $rightMsg ) {
$groups = User::getGroupsWithPermission( $right );
$msg .= "* " . $right . " *\n " . wfMsgReplaceArgs( $rightMsg['msg'], $rightMsg['params'] ) .
foreach ( self::$mRights as $right => $rightMsg ) {
$groups = User::getGroupsWithPermission( $right );
$msg .= "* " . $right . " *\n " . wfMsgReplaceArgs( $rightMsg['msg'], $rightMsg['params'] ) .
- "\nGranted to:\n " . str_replace( '*', 'all', implode( ', ', $groups ) ) . "\n\n";
+ "\nGranted to:\n " . str_replace( '*', 'all', implode( ', ', $groups ) ) . "\n\n";
}
$msg .= "\n$astriks Formats $astriks\n\n";
}
$msg .= "\n$astriks Formats $astriks\n\n";
*/
public function getShowVersions() {
wfDeprecated( __METHOD__, '1.21' );
*/
public function getShowVersions() {
wfDeprecated( __METHOD__, '1.21' );
if ( is_array( $this->mExtraData ) ) {
$result = array_merge( $result, $this->mExtraData );
}
if ( is_array( $this->mExtraData ) ) {
$result = array_merge( $result, $this->mExtraData );
}
// cache this instance in case it is needed later
$this->mInstances[$moduleName] = $instance;
}
// cache this instance in case it is needed later
$this->mInstances[$moduleName] = $instance;
}
$result[$name] = $grpCls[1];
}
}
$result[$name] = $grpCls[1];
}
}
if ( $toTitle->getNamespace() == NS_FILE
&& !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle )
if ( $toTitle->getNamespace() == NS_FILE
&& !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle )
- && wfFindFile( $toTitle ) )
- {
+ && wfFindFile( $toTitle )
+ ) {
if ( !$params['ignorewarnings'] && $user->isAllowed( 'reupload-shared' ) ) {
$this->dieUsageMsg( 'sharedfile-exists' );
} elseif ( !$user->isAllowed( 'reupload-shared' ) ) {
if ( !$params['ignorewarnings'] && $user->isAllowed( 'reupload-shared' ) ) {
$this->dieUsageMsg( 'sharedfile-exists' );
} elseif ( !$user->isAllowed( 'reupload-shared' ) ) {
// Move subpages
if ( $params['movesubpages'] ) {
$r['subpages'] = $this->moveSubpages( $fromTitle, $toTitle,
// Move subpages
if ( $params['movesubpages'] ) {
$r['subpages'] = $this->moveSubpages( $fromTitle, $toTitle,
- $params['reason'], $params['noredirect'] );
+ $params['reason'], $params['noredirect'] );
$result->setIndexedTagName( $r['subpages'], 'subpage' );
if ( $params['movetalk'] ) {
$result->setIndexedTagName( $r['subpages'], 'subpage' );
if ( $params['movetalk'] ) {
public function getParamDescription() {
$p = $this->getModulePrefix();
public function getParamDescription() {
$p = $this->getModulePrefix();
return array(
'from' => "Title of the page you want to move. Cannot be used together with {$p}fromid",
'fromid' => "Page ID of the page you want to move. Cannot be used together with {$p}from",
return array(
'from' => "Title of the page you want to move. Cannot be used together with {$p}fromid",
'fromid' => "Page ID of the page you want to move. Cannot be used together with {$p}from",