r80809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80808‎ | r80809 | r80810 >
Date:10:39, 23 January 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Improve raw SQL usage :)
Modified paths:
  • /trunk/extensions/OAI/OAIRepo_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OAI/OAIRepo_body.php
@@ -645,25 +645,25 @@
646646
647647 function fetchReferenceData( $rows ) {
648648 $page_ids = array();
649 - foreach($rows as $row){
 649+ foreach( $rows as $row ){
650650 $page_ids[] = $row->up_page;
651651 }
652652
653 - if(count($page_ids) == 1)
654 - $pages_where = " AND up_page = $page_ids[0] ";
655 - else
656 - $pages_where = " AND up_page IN (".implode(",",$page_ids).") ";
 653+ $res = $this->_db->select(
 654+ array( 'updates', 'page', 'redirect' ),
 655+ array( 'up_page,up_sequence', 'rp.page_namespace AS page_namespace',
 656+ 'rp.page_title AS page_title' ),
 657+ array(
 658+ 'u.up_page=p.page_id',
 659+ 'p.page_namespace=r.rd_namespace',
 660+ 'p.page_title=r.rd_title',
 661+ 'r.rd_from=rp.page_id',
 662+ 'up_page' => $page_ids
 663+ ),
 664+ __METHOD__
 665+ );
657666
658 - extract( $this->_db->tableNames( 'updates', 'page', 'redirect' ) );
659 - $sql = "SELECT up_page,up_sequence,
660 - rp.page_namespace AS page_namespace,
661 - rp.page_title AS page_title
662 - FROM $updates AS u, $page AS p, $redirect AS r, $page AS rp
663 - WHERE u.up_page=p.page_id AND p.page_namespace=r.rd_namespace
664 - AND p.page_title=r.rd_title AND r.rd_from=rp.page_id
665 - $pages_where";
666 -
667 - return $this->_db->resultObject( $this->_db->query( $sql ) );
 667+ return $this->_db->resultObject( $res );
668668 }
669669
670670

Follow-up revisions

RevisionCommit summaryAuthorDate
r80810Bleh, spaces to tabs from r80809reedy10:41, 23 January 2011
r86314Fix table alias' from r80809reedy15:20, 18 April 2011

Comments

#Comment by MZMcBride (talk | contribs)   22:38, 23 January 2011

Reedy: Take a look at bugzilla:26670#c3 when you get a chance.

#Comment by 😂 (talk | contribs)   15:14, 18 April 2011

This doesn't look right. You're removing the table aliases.

Status & tagging log