$this->mPages = $this->db->selectField( 'page', 'COUNT(*)', '', __METHOD__ );
return $this->mPages;
}
-
+
/**
* Count total users
* @return Integer
$this->mUsers = $this->db->selectField( 'user', 'COUNT(*)', '', __METHOD__ );
return $this->mUsers;
}
-
+
/**
* Count views
* @return Integer
* @param $warning string Warning message
*/
public function setWarning( $warning ) {
- $data = $this->getResult()->getData();
+ $result = $this->getResult();
+ $data = $result->getData();
if ( isset( $data['warnings'][$this->getModuleName()] ) ) {
// Don't add duplicate warnings
$warn_regex = preg_quote( $warning, '/' );
$oldwarning = $data['warnings'][$this->getModuleName()]['*'];
// If there is a warning already, append it to the existing one
$warning = "$oldwarning\n$warning";
- $this->getResult()->unsetValue( 'warnings', $this->getModuleName() );
+ $result->unsetValue( 'warnings', $this->getModuleName() );
}
$msg = array();
ApiResult::setContent( $msg, $warning );
- $this->getResult()->disableSizeCheck();
- $this->getResult()->addValue( 'warnings', $this->getModuleName(), $msg );
- $this->getResult()->enableSizeCheck();
+ $result->disableSizeCheck();
+ $result->addValue( 'warnings', $this->getModuleName(), $msg );
+ $result->enableSizeCheck();
}
/**
* @return string
*/
public function makeHelpMsg() {
- $msg = '';
-
// Make sure the internal object is empty
// (just in case a sub-module decides to optimize during instantiation)
$this->mPageSet = null;
$querySeparator = str_repeat( '--- ', 12 );
$moduleSeparator = str_repeat( '*** ', 14 );
- $msg .= "\n$querySeparator Query: Prop $querySeparator\n\n";
+ $msg = "\n$querySeparator Query: Prop $querySeparator\n\n";
$msg .= $this->makeHelpMsgHelper( $this->mQueryPropModules, 'prop' );
$msg .= "\n$querySeparator Query: List $querySeparator\n\n";
$msg .= $this->makeHelpMsgHelper( $this->mQueryListModules, 'list' );
$count = 0;
$res = $this->select( __METHOD__ );
+ $result = $this->getResult();
foreach ( $res as $row ) {
if ( ++ $count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
if ( !$vals ) {
continue;
}
- $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
+ $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->log_timestamp ) );
break;
}
}
- $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' );
+ $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' );
}
/**
global $wgContLang;
$s = $wgContLang->normalize( $s );
}
-
/**
* Converts a Status object to an array suitable for addValue
if ( $status->isGood() ) {
return array();
}
-
+
$result = array();
foreach ( $status->getErrorsByType( $errorType ) as $error ) {
$this->setIndexedTagName( $error['params'], 'param' );
}
return $sessionKey;
}
-
+
/**
- * Throw an error that the user can recover from by providing a better
+ * Throw an error that the user can recover from by providing a better
* value for $parameter
- *
+ *
* @param $error array Error array suitable for passing to dieUsageMsg()
* @param $parameter string Parameter that needs revising
* @param $data array Optional extra data to pass to the user
$data['stashfailed'] = $e->getMessage();
}
$data['invalidparameter'] = $parameter;
-
+
$parsed = $this->parseMsg( $error );
$this->dieUsage( $parsed['info'], $parsed['code'], 0, $data );
}
if ( $this->mParams['statuskey'] ) {
$this->checkAsyncDownloadEnabled();
-
+
// Status request for an async upload
$sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] );
if ( !isset( $sessionData['result'] ) ) {
$async = false;
if ( $this->mParams['asyncdownload'] ) {
$this->checkAsyncDownloadEnabled();
-
+
if ( $this->mParams['leavemessage'] && !$this->mParams['ignorewarnings'] ) {
$this->dieUsage( 'Using leavemessage without ignorewarnings is not supported',
'missing-ignorewarnings' );
// Recoverable errors
case UploadBase::MIN_LENGTH_PARTNAME:
$this->dieRecoverableError( 'filename-tooshort', 'filename' );
- break;
+ break;
case UploadBase::ILLEGAL_FILENAME:
$this->dieRecoverableError( 'illegal-filename', 'filename',
array( 'filename' => $verification['filtered'] ) );
case UploadBase::WINDOWS_NONASCII_FILENAME:
$this->dieRecoverableError( 'windows-nonascii-filename', 'filename' );
break;
-
+
// Unrecoverable errors
case UploadBase::EMPTY_FILE:
$this->dieUsage( 'The file you submitted was empty', 'empty-file' );
}
return $this->transformWarnings( $warnings );
}
-
+
protected function transformWarnings( $warnings ) {
if ( $warnings ) {
// Add indices
- $this->getResult()->setIndexedTagName( $warnings, 'warning' );
+ $result = $this->getResult();
+ $result->setIndexedTagName( $warnings, 'warning' );
if ( isset( $warnings['duplicate'] ) ) {
$dupes = array();
foreach ( $warnings['duplicate'] as $dupe ) {
$dupes[] = $dupe->getName();
}
- $this->getResult()->setIndexedTagName( $dupes, 'duplicate' );
+ $result->setIndexedTagName( $dupes, 'duplicate' );
$warnings['duplicate'] = $dupes;
}
return $result;
}
-
+
/**
* Checks if asynchronous copy uploads are enabled and throws an error if they are not.
*/
$user, (array)$params['add'],
(array)$params['remove'], $params['reason'] );
- $this->getResult()->setIndexedTagName( $r['added'], 'group' );
- $this->getResult()->setIndexedTagName( $r['removed'], 'group' );
- $this->getResult()->addValue( null, $this->getModuleName(), $r );
+ $result = $this->getResult();
+ $result->setIndexedTagName( $r['added'], 'group' );
+ $result->setIndexedTagName( $r['removed'], 'group' );
+ $result->addValue( null, $this->getModuleName(), $r );
}
/**