r110778 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110777‎ | r110778 | r110779 >
Date:20:55, 6 February 2012
Author:reedy
Status:ok
Tags:
Comment:
Bug 34227 - Undefined property: stdClass::$rev_len

Apply the patch that Brion wrote

Also refactor out all the duplicate fields, tables and joins code
Modified paths:
  • /trunk/extensions/OAI/OAIRepo_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OAI/OAIRepo_body.php
@@ -578,18 +578,11 @@
579579 function fetchRecord( $pageid ) {
580580 $db = $this->_db;
581581
582 - $tables = array( 'updates', 'page', 'revision', 'text' );
583 - $fields = array( 'page_namespace', 'page_title', 'old_text', 'old_flags',
584 - 'rev_id', 'rev_deleted', 'rev_comment', 'rev_user',
585 - 'rev_user_text', 'rev_timestamp', 'page_restrictions',
586 - 'rev_minor_edit', 'page_is_redirect', 'up_sequence',
587 - 'page_id', 'up_timestamp', 'up_action', 'up_page',
588 - 'page_len', 'page_touched', 'page_counter', 'page_latest',);
 582+ $tables = $this->getTables();
 583+ $fields = $this->getFields();
589584 $conds = array();
590585 $options = array();
591 - $join_conds = array( 'page' => array( 'LEFT JOIN', 'page_id=up_page' ),
592 - 'revision' => array( 'LEFT JOIN', 'page_latest=rev_id' ),
593 - 'text' => array( 'LEFT JOIN', 'rev_text_id=old_id' ) );
 586+ $join_conds = $this->getJoinConds();
594587
595588 $conds['up_page'] = $pageid;
596589
@@ -602,22 +595,44 @@
603596 $options, $join_conds );
604597 }
605598
 599+ /**
 600+ * @return array
 601+ */
 602+ private function getFields() {
 603+ return array( 'page_namespace', 'page_title', 'old_text', 'old_flags',
 604+ 'rev_id', 'rev_deleted', 'rev_comment', 'rev_user',
 605+ 'rev_user_text', 'rev_timestamp', 'page_restrictions',
 606+ 'rev_minor_edit', 'rev_len', 'page_is_redirect', 'up_sequence',
 607+ 'page_id', 'up_timestamp', 'up_action', 'up_page',
 608+ 'page_len', 'page_touched', 'page_counter', 'page_latest'
 609+ );
 610+ }
 611+
 612+ /**
 613+ * @return array
 614+ */
 615+ private function getJoinConds() {
 616+ return array( 'page' => array( 'LEFT JOIN', 'page_id=up_page' ),
 617+ 'revision' => array( 'LEFT JOIN', 'page_latest=rev_id' ),
 618+ 'text' => array( 'LEFT JOIN', 'rev_text_id=old_id' )
 619+ );
 620+ }
 621+
 622+ /**
 623+ * @return array
 624+ */
 625+ private function getTables() {
 626+ return array( 'updates', 'page', 'revision', 'text' );
 627+ }
 628+
606629 function fetchRows( $from, $until, $chunk, $token = null ) {
607630
608631 $db = $this->_db;
609 -
610 - $tables = array( 'updates', 'page', 'revision', 'text' );
611 - $fields = array( 'page_namespace', 'page_title', 'old_text', 'old_flags',
612 - 'rev_id', 'rev_deleted', 'rev_comment', 'rev_user',
613 - 'rev_user_text', 'rev_timestamp', 'page_restrictions',
614 - 'rev_minor_edit', 'page_is_redirect', 'up_sequence',
615 - 'page_id', 'up_timestamp', 'up_action', 'up_page',
616 - 'page_len', 'page_touched', 'page_counter', 'page_latest',);
 632+ $tables = $this->getTables();
 633+ $fields = $this->getFields();
617634 $conds = array();
618635 $options = array();
619 - $join_conds = array( 'page' => array( 'LEFT JOIN', 'page_id=up_page' ),
620 - 'revision' => array( 'LEFT JOIN', 'page_latest=rev_id' ),
621 - 'text' => array( 'LEFT JOIN', 'rev_text_id=old_id' ) );
 636+ $join_conds = $this->getJoinConds();
622637
623638 if( $token ) {
624639 $conds[] = 'up_sequence>=' . $db->addQuotes( $token );

Status & tagging log