r93222 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93221‎ | r93222 | r93223 >
Date:17:32, 26 July 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Add param to code review api so that tags for a revision are also
available.
Modified paths:
  • /trunk/extensions/CodeReview/api/ApiQueryCodeRevisions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/api/ApiQueryCodeRevisions.php
@@ -82,23 +82,23 @@
8383 $count = 0;
8484 $start = 0;
8585 $defaultSort = $pager->getDefaultSort();
 86+ $result = $this->getResult();
8687 foreach ( $revisions as $row ) {
8788 if ( !$revsSet && $count == $limit ) {
8889 $this->setContinueEnumParameter( 'start', $start );
8990 break;
9091 }
9192
92 - $data[] = $this->formatRow( $row );
 93+ $data[] = $this->formatRow( $row, $repo, $result );
9394 $start = $row->$defaultSort;
9495 $count++;
9596 }
9697
97 - $result = $this->getResult();
9898 $result->setIndexedTagName( $data, 'revision' );
9999 $result->addValue( 'query', $this->getModuleName(), $data );
100100 }
101101
102 - private function formatRow( $row ) {
 102+ private function formatRow( $row, $repo, $result ) {
103103 $item = array();
104104 if ( isset( $this->props['revid'] ) ) {
105105 $item['revid'] = intval( $row->cr_id );
@@ -121,6 +121,11 @@
122122 if ( isset( $this->props['timestamp'] ) ) {
123123 $item['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cr_timestamp );
124124 }
 125+ if ( isset( $this->props['tags'] ) ) {
 126+ $rev = CodeRevision::newFromRow( $repo, $row );
 127+ $item['tags'] = $rev->getTags( );
 128+ $result->setIndexedTagName( $item, 'tags' );
 129+ }
125130 return $item;
126131 }
127132
@@ -156,6 +161,7 @@
157162 'path',
158163 'message',
159164 'author',
 165+ 'tags',
160166 'timestamp',
161167 ),
162168 ),
@@ -188,7 +194,7 @@
189195 public function getExamples() {
190196 return array(
191197 'api.php?action=query&list=coderevisions&crrepo=MediaWiki',
192 - 'api.php?action=query&list=coderevisions&crrepo=MediaWiki&crprop=revid|author|status|timestamp',
 198+ 'api.php?action=query&list=coderevisions&crrepo=MediaWiki&crprop=revid|author|status|timestamp|tags',
193199 );
194200 }
195201

Sign-offs

UserFlagDate
Reedyinspected10:56, 28 July 2011
Reedytested10:56, 28 July 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r93381Followup r93222...reedy10:56, 28 July 2011

Comments

#Comment by Reedy (talk | contribs)   10:53, 28 July 2011

api.php?action=query&list=coderevisions&crrepo=MediaWiki&crrevs=82146&crprop=revid|author|tags

<?xml version="1.0"?>
<api xmlns="[http://www.mediawiki.org/xml/api/ http://www.mediawiki.org/xml/api/]" servedby="ubuntu64-esxi">
  <error code="internal_api_error_MWException" info="Exception Caught: Internal error in ApiFormatXml::recXmlPrint: (tags, ...) has integer keys without _element value. Use ApiResult::setIndexedTagName()." xml:space="preserve">

#0 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiBase.php(1235): wfDebugDieBacktrace('Internal error ...')
#1 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiFormatXml.php(148): ApiBase::dieDebug('ApiFormatXml::r...', '(tags, ...) has...')
#2 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiFormatXml.php(163): ApiFormatXml::recXmlPrint('tags', Array, 6)
#3 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiFormatXml.php(167): ApiFormatXml::recXmlPrint('revision', Array, 4)
#4 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiFormatXml.php(163): ApiFormatXml::recXmlPrint('coderevisions', Array, 2)
#5 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiFormatXml.php(163): ApiFormatXml::recXmlPrint('query', Array, 0)
#6 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiFormatXml.php(73): ApiFormatXml::recXmlPrint('api', Array, -2, false)
#7 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiMain.php(709): ApiFormatXml->execute()
#8 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiMain.php(685): ApiMain->printResult(false)
#9 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiMain.php(358): ApiMain->executeAction()
#10 /home/reedy/mediawiki/trunk/phase3/includes/api/ApiMain.php(342): ApiMain->executeActionWithErrorHandling()
#11 /home/reedy/mediawiki/trunk/phase3/api.php(115): ApiMain->execute()
#12 {main}

</error>
</api>

Works fine with no tags...

Status & tagging log