* (bug 26541) Generator-ise ApiQueryRecentChanges
This commit is contained in:
parent
785eb32056
commit
589a3f24ba
2 changed files with 34 additions and 16 deletions
|
|
@ -59,6 +59,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
|
|||
* (bug 24287) Wrap API Help output at 100 characters
|
||||
* Add a realname uiprop option to query=userinfo so a user's realname can be extracted
|
||||
* Add a &watchuser option to ApiBlock
|
||||
* (bug 26541) Generator-ise ApiQueryRecentChanges
|
||||
|
||||
=== Languages updated in 1.18 ===
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
|
|||
*
|
||||
* @ingroup API
|
||||
*/
|
||||
class ApiQueryRecentChanges extends ApiQueryBase {
|
||||
class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
|
||||
|
||||
public function __construct( $query, $moduleName ) {
|
||||
parent::__construct( $query, $moduleName, 'rc' );
|
||||
|
|
@ -108,10 +108,18 @@ class ApiQueryRecentChanges extends ApiQueryBase {
|
|||
$this->fld_tags = isset( $prop['tags'] );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$this->run();
|
||||
}
|
||||
|
||||
public function executeGenerator( $resultPageSet ) {
|
||||
$this->run( $resultPageSet );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and outputs the result of this query based upon the provided parameters.
|
||||
*/
|
||||
public function execute() {
|
||||
public function run( $resultPageSet = null ) {
|
||||
global $wgUser;
|
||||
/* Get the parameters of the request. */
|
||||
$params = $this->extractRequestParams();
|
||||
|
|
@ -252,6 +260,8 @@ class ApiQueryRecentChanges extends ApiQueryBase {
|
|||
/* Perform the actual query. */
|
||||
$res = $this->select( __METHOD__ );
|
||||
|
||||
$titles = array();
|
||||
|
||||
/* Iterate through the rows, adding data extracted from them to our query result. */
|
||||
foreach ( $res as $row ) {
|
||||
if ( ++ $count > $params['limit'] ) {
|
||||
|
|
@ -260,22 +270,30 @@ class ApiQueryRecentChanges extends ApiQueryBase {
|
|||
break;
|
||||
}
|
||||
|
||||
/* Extract the data from a single row. */
|
||||
$vals = $this->extractRowInfo( $row );
|
||||
if ( is_null( $resultPageSet ) ) {
|
||||
/* Extract the data from a single row. */
|
||||
$vals = $this->extractRowInfo( $row );
|
||||
|
||||
/* Add that row's data to our final output. */
|
||||
if ( !$vals ) {
|
||||
continue;
|
||||
}
|
||||
$fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
|
||||
if ( !$fit ) {
|
||||
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
|
||||
break;
|
||||
/* Add that row's data to our final output. */
|
||||
if ( !$vals ) {
|
||||
continue;
|
||||
}
|
||||
$fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
|
||||
if ( !$fit ) {
|
||||
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title );
|
||||
}
|
||||
}
|
||||
|
||||
/* Format the result */
|
||||
$this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
|
||||
if ( is_null( $resultPageSet ) ) {
|
||||
/* Format the result */
|
||||
$this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
|
||||
} else {
|
||||
$resultPageSet->populateFromTitles( $titles );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -288,8 +306,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
|
|||
public function extractRowInfo( $row ) {
|
||||
/* If page was moved somewhere, get the title of the move target. */
|
||||
$movedToTitle = false;
|
||||
if ( isset( $row->rc_moved_to_title ) && $row->rc_moved_to_title !== '' )
|
||||
{
|
||||
if ( isset( $row->rc_moved_to_title ) && $row->rc_moved_to_title !== '' ) {
|
||||
$movedToTitle = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue