r75459 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75458‎ | r75459 | r75460 >
Date:19:31, 26 October 2010
Author:btongminh
Status:ok
Tags:
Comment:
Follow-up r75282
* Use addWhere instead of addWhereFld
* Don't add properties twice if there is a continue
* Add comments
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryPageProps.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryPageProps.php
@@ -45,6 +45,7 @@
4646 public function execute() {
4747 $this->params = $this->extractRequestParams();
4848
 49+ # Only operate on existing pages
4950 $pages = $this->getPageSet()->getGoodTitles();
5051
5152 $this->addTables( 'page_props' );
@@ -52,32 +53,43 @@
5354 $this->addWhereFld( 'pp_page', array_keys( $pages ) );
5455
5556 if ( $this->params['continue'] ) {
56 - $this->addWhereFld( 'pp_page >=' . intval( $this->params['continue'] ) );
 57+ $this->addWhere( 'pp_page >=' . intval( $this->params['continue'] ) );
5758 }
5859
 60+ # Force a sort order to ensure that properties are grouped by page
5961 $this->addOption( 'ORDER BY', 'pp_page' );
6062
6163 $res = $this->select( __METHOD__ );
62 - $currentPage = 0;
 64+ $currentPage = 0; # Id of the page currently processed
6365 $props = array();
6466 $result = $this->getResult();
 67+
6568 foreach ( $res as $row ) {
6669 if ( $currentPage != $row->pp_page ) {
 70+ # Different page than previous row, so add the properties to
 71+ # the result and save the new page id
 72+
6773 if ( $currentPage ) {
6874 if ( !$this->addPageProps( $result, $currentPage, $props ) ) {
 75+ # addPageProps() indicated that the result did not fit
 76+ # so stop adding data. Reset props so that it doesn't
 77+ # get added again after loop exit
 78+
 79+ $props = array();
6980 break;
7081 }
7182
7283 $props = array();
73 - } else {
74 - $currentPage = $row->pp_page;
7584 }
 85+
 86+ $currentPage = $row->pp_page;
7687 }
7788
7889 $props[$row->pp_propname] = $row->pp_value;
7990 }
8091
8192 if ( count( $props ) ) {
 93+ # Add any remaining properties to the results
8294 $this->addPageProps( $result, $currentPage, $props );
8395 }
8496 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75282Follow-up r70638:...btongminh18:53, 23 October 2010

Status & tagging log