From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/api/ApiQueryRecentChanges.php | 43 +++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'includes/api/ApiQueryRecentChanges.php') diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 8aceab22..6b10bdc6 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -39,7 +39,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false, $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false, $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false, - $fld_tags = false, $token = array(); + $fld_tags = false, $fld_sha1 = false, $token = array(); private $tokenFunctions; @@ -121,6 +121,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->fld_patrolled = isset( $prop['patrolled'] ); $this->fld_loginfo = isset( $prop['loginfo'] ); $this->fld_tags = isset( $prop['tags'] ); + $this->fld_sha1 = isset( $prop['sha1'] ); } public function execute() { @@ -273,6 +274,12 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addFields( 'ts_tags' ); } + if ( $this->fld_sha1 ) { + $this->addTables( 'revision' ); + $this->addJoinConds( array( 'revision' => array( 'LEFT JOIN', array( 'rc_this_oldid=rev_id' ) ) ) ); + $this->addFields( array( 'rev_sha1', 'rev_deleted' ) ); + } + if ( $params['toponly'] || $showRedirects ) { $this->addTables( 'page' ); $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) ); @@ -287,8 +294,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addTables( 'change_tag' ); $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) ); $this->addWhereFld( 'ct_tag', $params['tag'] ); - global $wgOldChangeTagsIndex; - $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id'; + $index['change_tag'] = 'change_tag_tag_id'; } $this->token = $params['token']; @@ -475,6 +481,19 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { } } + if ( $this->fld_sha1 && $row->rev_sha1 !== null ) { + // The RevDel check should currently never pass due to the + // rc_deleted = 0 condition in the WHERE clause, but in case that + // ever changes we check it here too. + if ( $row->rev_deleted & Revision::DELETED_TEXT ) { + $vals['sha1hidden'] = ''; + } elseif ( $row->rev_sha1 !== '' ) { + $vals['sha1'] = wfBaseConvert( $row->rev_sha1, 36, 16, 40 ); + } else { + $vals['sha1'] = ''; + } + } + if ( !is_null( $this->token ) ) { $tokenFunctions = $this->getTokenFunctions(); foreach ( $this->token as $t ) { @@ -499,7 +518,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { } return $retval; } - switch( $type ) { + switch ( $type ) { case 'edit': return RC_EDIT; case 'new': @@ -571,7 +590,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { 'redirect', 'patrolled', 'loginfo', - 'tags' + 'tags', + 'sha1', ) ), 'token' => array( @@ -638,6 +658,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { ' patrolled - Tags edits that have been patrolled', ' loginfo - Adds log information (logid, logtype, etc) to log entries', ' tags - Lists tags for the entry', + ' sha1 - Adds the content checksum for entries associated with a revision', ), 'token' => 'Which tokens to obtain for each change', 'show' => array( @@ -735,7 +756,17 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { ApiBase::PROP_TYPE => 'string', ApiBase::PROP_NULLABLE => true ) - ) + ), + 'sha1' => array( + 'sha1' => array( + ApiBase::PROP_TYPE => 'string', + ApiBase::PROP_NULLABLE => true + ), + 'sha1hidden' => array( + ApiBase::PROP_TYPE => 'boolean', + ApiBase::PROP_NULLABLE => true + ), + ), ); self::addTokenProperties( $props, $this->getTokenFunctions() ); -- cgit v1.2.3-54-g00ecf