dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "API: Warn when unsupported PHP array syntax is used"
[lhc/web/wiklou.git]
/
includes
/
api
/
ApiMain.php
diff --git
a/includes/api/ApiMain.php
b/includes/api/ApiMain.php
index
5cdcd51
..
554bfa6
100644
(file)
--- a/
includes/api/ApiMain.php
+++ b/
includes/api/ApiMain.php
@@
-147,9
+147,9
@@
class ApiMain extends ApiBase {
/**
* Constructs an instance of ApiMain that utilizes the module and format specified by $request.
*
/**
* Constructs an instance of ApiMain that utilizes the module and format specified by $request.
*
- * @param
$context IContextSource|WebRequest - i
f this is an instance of
+ * @param
IContextSource|WebRequest $context I
f this is an instance of
* FauxRequest, errors are thrown and no printing occurs
* FauxRequest, errors are thrown and no printing occurs
- * @param bool $enableWrite
s
hould be set to true if the api may modify data
+ * @param bool $enableWrite
S
hould be set to true if the api may modify data
*/
public function __construct( $context = null, $enableWrite = false ) {
if ( $context === null ) {
*/
public function __construct( $context = null, $enableWrite = false ) {
if ( $context === null ) {
@@
-238,7
+238,7
@@
class ApiMain extends ApiBase {
/**
* Set how long the response should be cached.
*
/**
* Set how long the response should be cached.
*
- * @param $maxage
+ * @param
int
$maxage
*/
public function setCacheMaxAge( $maxage ) {
$this->setCacheControl( array(
*/
public function setCacheMaxAge( $maxage ) {
$this->setCacheControl( array(
@@
-301,7
+301,7
@@
class ApiMain extends ApiBase {
* Cache control values set here will only be used if the cache mode is not
* private, see setCacheMode().
*
* Cache control values set here will only be used if the cache mode is not
* private, see setCacheMode().
*
- * @param
$directives array
+ * @param
array $directives
*/
public function setCacheControl( $directives ) {
$this->mCacheControl = $directives + $this->mCacheControl;
*/
public function setCacheControl( $directives ) {
$this->mCacheControl = $directives + $this->mCacheControl;
@@
-310,7
+310,7
@@
class ApiMain extends ApiBase {
/**
* Create an instance of an output formatter by its name
*
/**
* Create an instance of an output formatter by its name
*
- * @param
$format string
+ * @param
string $format
*
* @return ApiFormatBase
*/
*
* @return ApiFormatBase
*/
@@
-387,7
+387,10
@@
class ApiMain extends ApiBase {
*/
protected function handleException( Exception $e ) {
// Bug 63145: Rollback any open database transactions
*/
protected function handleException( Exception $e ) {
// Bug 63145: Rollback any open database transactions
- MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+ if ( !( $e instanceof UsageException ) ) {
+ // UsageExceptions are intentional, so don't rollback if that's the case
+ MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+ }
// Allow extra cleanup and logging
wfRunHooks( 'ApiMain::onException', array( $this, $e ) );
// Allow extra cleanup and logging
wfRunHooks( 'ApiMain::onException', array( $this, $e ) );
@@
-637,7
+640,7
@@
class ApiMain extends ApiBase {
/**
* Replace the result data with the information about an exception.
* Returns the error code
/**
* Replace the result data with the information about an exception.
* Returns the error code
- * @param
$e Exception
+ * @param
Exception $e
* @return string
*/
protected function substituteResultWithError( $e ) {
* @return string
*/
protected function substituteResultWithError( $e ) {
@@
-782,9
+785,9
@@
class ApiMain extends ApiBase {
/**
* Check the max lag if necessary
/**
* Check the max lag if necessary
- * @param
$module ApiBase object:
Api module being used
- * @param array $params an array containing the request parameters.
- * @return bool
ean
True on success, false should exit immediately
+ * @param
ApiBase $module
Api module being used
+ * @param array $params
Array
an array containing the request parameters.
+ * @return bool True on success, false should exit immediately
*/
protected function checkMaxLag( $module, $params ) {
if ( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) ) {
*/
protected function checkMaxLag( $module, $params ) {
if ( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) ) {
@@
-811,7
+814,7
@@
class ApiMain extends ApiBase {
/**
* Check for sufficient permissions to execute
/**
* Check for sufficient permissions to execute
- * @param
$module ApiBas
e An Api module
+ * @param
ApiBase $modul
e An Api module
*/
protected function checkExecutePermissions( $module ) {
$user = $this->getUser();
*/
protected function checkExecutePermissions( $module ) {
$user = $this->getUser();
@@
-841,7
+844,7
@@
class ApiMain extends ApiBase {
/**
* Check asserts of the user's rights
/**
* Check asserts of the user's rights
- * @param
$params array
+ * @param
array $params
*/
protected function checkAsserts( $params ) {
if ( isset( $params['assert'] ) ) {
*/
protected function checkAsserts( $params ) {
if ( isset( $params['assert'] ) ) {
@@
-863,7
+866,7
@@
class ApiMain extends ApiBase {
/**
* Check POST for external response and setup result printer
/**
* Check POST for external response and setup result printer
- * @param
$module ApiBas
e An Api module
+ * @param
ApiBase $modul
e An Api module
* @param array $params an array with the request parameters
*/
protected function setupExternalResponse( $module, $params ) {
* @param array $params an array with the request parameters
*/
protected function setupExternalResponse( $module, $params ) {
@@
-953,6
+956,8
@@
class ApiMain extends ApiBase {
/**
* Encode a value in a format suitable for a space-separated log line.
/**
* Encode a value in a format suitable for a space-separated log line.
+ * @param string $s
+ * return string
*/
protected function encodeRequestLogValue( $s ) {
static $table;
*/
protected function encodeRequestLogValue( $s ) {
static $table;
@@
-969,6
+974,7
@@
class ApiMain extends ApiBase {
/**
* Get the request parameters used in the course of the preceding execute() request
/**
* Get the request parameters used in the course of the preceding execute() request
+ * @return array
*/
protected function getParamsUsed() {
return array_keys( $this->mParamsUsed );
*/
protected function getParamsUsed() {
return array_keys( $this->mParamsUsed );
@@
-976,6
+982,9
@@
class ApiMain extends ApiBase {
/**
* Get a request value, and register the fact that it was used, for logging.
/**
* Get a request value, and register the fact that it was used, for logging.
+ * @param string $name
+ * @param mixed $default
+ * @return mixed
*/
public function getVal( $name, $default = null ) {
$this->mParamsUsed[$name] = true;
*/
public function getVal( $name, $default = null ) {
$this->mParamsUsed[$name] = true;
@@
-997,6
+1006,8
@@
class ApiMain extends ApiBase {
/**
* Get a boolean request value, and register the fact that the parameter
* was used, for logging.
/**
* Get a boolean request value, and register the fact that the parameter
* was used, for logging.
+ * @param string $name
+ * @return bool
*/
public function getCheck( $name ) {
return $this->getVal( $name, null ) !== null;
*/
public function getCheck( $name ) {
return $this->getVal( $name, null ) !== null;
@@
-1043,7
+1054,7
@@
class ApiMain extends ApiBase {
/**
* Print results using the current printer
*
/**
* Print results using the current printer
*
- * @param
$isError bool
+ * @param
bool $isError
*/
protected function printResult( $isError ) {
global $wgDebugAPI;
*/
protected function printResult( $isError ) {
global $wgDebugAPI;
@@
-1233,7
+1244,7
@@
class ApiMain extends ApiBase {
/**
* Sets whether the pretty-printer should format *bold* and $italics$
*
/**
* Sets whether the pretty-printer should format *bold* and $italics$
*
- * @param
$help bool
+ * @param
bool $help
*/
public function setHelp( $help = true ) {
$this->mPrinter->setHelp( $help );
*/
public function setHelp( $help = true ) {
$this->mPrinter->setHelp( $help );
@@
-1311,7
+1322,7
@@
class ApiMain extends ApiBase {
}
/**
}
/**
- * @param
$module ApiBas
e
+ * @param
ApiBase $modul
e
* @param string $paramName What type of request is this? e.g. action,
* query, list, prop, meta, format
* @return string
* @param string $paramName What type of request is this? e.g. action,
* query, list, prop, meta, format
* @return string
@@
-1365,7
+1376,7
@@
class ApiMain extends ApiBase {
*
* @deprecated since 1.21, Use getModuleManager()->addModule() instead.
* @param string $name The identifier for this module.
*
* @deprecated since 1.21, Use getModuleManager()->addModule() instead.
* @param string $name The identifier for this module.
- * @param
$class ApiBase
The class where this module is implemented.
+ * @param
ApiBase $class
The class where this module is implemented.
*/
protected function addModule( $name, $class ) {
$this->getModuleManager()->addModule( $name, 'action', $class );
*/
protected function addModule( $name, $class ) {
$this->getModuleManager()->addModule( $name, 'action', $class );
@@
-1377,7
+1388,7
@@
class ApiMain extends ApiBase {
*
* @deprecated since 1.21, Use getModuleManager()->addModule() instead.
* @param string $name The identifier for this format.
*
* @deprecated since 1.21, Use getModuleManager()->addModule() instead.
* @param string $name The identifier for this format.
- * @param
$class ApiFormatBase
The class implementing this format.
+ * @param
ApiFormatBase $class
The class implementing this format.
*/
protected function addFormat( $name, $class ) {
$this->getModuleManager()->addModule( $name, 'format', $class );
*/
protected function addFormat( $name, $class ) {
$this->getModuleManager()->addModule( $name, 'format', $class );
@@
-1420,10
+1431,10
@@
class UsageException extends MWException {
private $mExtraData;
/**
private $mExtraData;
/**
- * @param
$message string
- * @param
$codestr string
- * @param
$code int
- * @param
$extradata array|null
+ * @param
string $message
+ * @param
string $codestr
+ * @param
int $code
+ * @param
array|null $extradata
*/
public function __construct( $message, $codestr, $code = 0, $extradata = null ) {
parent::__construct( $message, $code );
*/
public function __construct( $message, $codestr, $code = 0, $extradata = null ) {
parent::__construct( $message, $code );