*/
class ApiSetNotificationTimestamp extends ApiBase {
+ private $mPageSet;
+
public function execute() {
$user = $this->getUser();
$params = $this->extractRequestParams();
$this->requireMaxOneParameter( $params, 'timestamp', 'torevid', 'newerthanrevid' );
- $pageSet = new ApiPageSet( $this );
+ $pageSet = $this->getPageSet();
$args = array_merge( array( $params, 'entirewatchlist' ), array_keys( $pageSet->getAllowedParams() ) );
call_user_func_array( array( $this, 'requireOnlyOneParameter' ), $args );
$result['notificationtimestamp'] = ( is_null( $timestamp ) ? '' : wfTimestamp( TS_ISO_8601, $timestamp ) );
} else {
// First, log the invalid titles
- foreach( $pageSet->getInvalidTitles() as $title ) {
+ foreach ( $pageSet->getInvalidTitles() as $title ) {
$r = array();
$r['title'] = $title;
$r['invalid'] = '';
$result[] = $r;
}
- foreach( $pageSet->getMissingPageIDs() as $p ) {
+ foreach ( $pageSet->getMissingPageIDs() as $p ) {
$page = array();
$page['pageid'] = $p;
$page['missing'] = '';
$page['notwatched'] = '';
$result[] = $page;
}
- foreach( $pageSet->getMissingRevisionIDs() as $r ) {
+ foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
$rev = array();
$rev['revid'] = $r;
$rev['missing'] = '';
$apiResult->addValue( null, $this->getModuleName(), $result );
}
+ /**
+ * Get a cached instance of an ApiPageSet object
+ * @return ApiPageSet
+ */
+ private function getPageSet() {
+ if ( !isset( $this->mPageSet ) ) {
+ $this->mPageSet = new ApiPageSet( $this );
+ }
+ return $this->mPageSet;
+ }
+
public function mustBePosted() {
return true;
}
return '';
}
- public function getAllowedParams() {
- $psModule = new ApiPageSet( $this );
- return $psModule->getAllowedParams() + array(
+ public function getAllowedParams( $flags = 0 ) {
+ $result = array(
'entirewatchlist' => array(
ApiBase::PARAM_TYPE => 'boolean'
),
ApiBase::PARAM_TYPE => 'integer'
),
);
+ if ( $flags ) {
+ $result += $this->getPageSet()->getFinalParams( $flags );
+ }
+ return $result;
+
}
public function getParamDescription() {
- $psModule = new ApiPageSet( $this );
- return $psModule->getParamDescription() + array(
+ return $this->getPageSet()->getParamDescription() + array(
'entirewatchlist' => 'Work on all watched pages',
'timestamp' => 'Timestamp to which to set the notification timestamp',
'torevid' => 'Revision to set the notification timestamp to (one page only)',
}
public function getPossibleErrors() {
- $psModule = new ApiPageSet( $this );
+ $ps = $this->getPageSet();
return array_merge(
parent::getPossibleErrors(),
- $psModule->getPossibleErrors(),
- $this->getRequireMaxOneParameterErrorMessages( array( 'timestamp', 'torevid', 'newerthanrevid' ) ),
- $this->getRequireOnlyOneParameterErrorMessages( array_merge( array( 'entirewatchlist' ), array_keys( $psModule->getAllowedParams() ) ) ),
+ $ps->getPossibleErrors(),
+ $this->getRequireMaxOneParameterErrorMessages(
+ array( 'timestamp', 'torevid', 'newerthanrevid' ) ),
+ $this->getRequireOnlyOneParameterErrorMessages(
+ array_merge( array( 'entirewatchlist' ), array_keys( $ps->getFinalParams() ) ) ),
array(
array( 'code' => 'notloggedin', 'info' => 'Anonymous users cannot use watchlist change notifications' ),
array( 'code' => 'multpages', 'info' => 'torevid may only be used with a single page' ),