r22891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22890‎ | r22891 | r22892 >
Date:21:23, 10 June 2007
Author:rainman
Status:old
Tags:
Comment:
Removed expensive group by query, fetch redirect names only.
Modified paths:
  • /trunk/extensions/OAI/OAIRepo_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OAI/OAIRepo_body.php
@@ -659,20 +659,13 @@
660660 else
661661 $pages_where = " AND up_page IN (".implode(",",$page_ids).") ";
662662
663 - extract( $this->_db->tableNames( 'updates', 'page', 'pagelinks' ) );
 663+ extract( $this->_db->tableNames( 'updates', 'page', 'redirect' ) );
664664 $sql = "SELECT up_page,up_sequence,
665 - r.page_namespace AS page_namespace,
666 - r.page_title AS page_title,
667 - COUNT(pl.pl_from) AS num_page_ref
668 - FROM $updates
669 - LEFT JOIN $page AS p ON p.page_id=up_page
670 - LEFT JOIN $pagelinks AS pl ON p.page_namespace=pl.pl_namespace AND p.page_title=pl.pl_title
671 - LEFT JOIN $page AS ns ON pl.pl_from=ns.page_id
672 - LEFT JOIN $page AS r ON pl.pl_from=r.page_id AND r.page_is_redirect=1
673 - LEFT JOIN $pagelinks AS rpl ON r.page_namespace=rpl.pl_namespace AND r.page_title=rpl.pl_title
674 - WHERE p.page_namespace != 0 OR p.page_namespace = ns.page_namespace
675 - $pages_where
676 - GROUP BY up_page,r.page_id";
 665+ rp.page_namespace AS page_namespace,
 666+ rp.page_title AS page_title
 667+ FROM $updates AS u, $page AS p, $redirect AS r, $page AS rp
 668+ WHERE u.up_page=p.page_id AND p.page_namespace=r.rd_namespace
 669+ AND p.page_title=r.rd_title AND r.rd_from=rp.page_id";
677670
678671 return $this->_db->resultObject( $this->_db->query( $sql ) );
679672 }
@@ -954,14 +947,9 @@
955948 function __construct($resultSet){
956949 parent::__construct();
957950 $this->_redirects = array();
958 - $this->_references = array();
959951 for($i = 0 ; $i < $resultSet->numRows(); $i++){
960952 $row = $resultSet->fetchObject();
961 - if(isset($row->page_title))
962 - $this->_redirects[$row->up_page][] = $row;
963 - else
964 - $this->_references[$row->up_page] = $row;
965 -
 953+ $this->_redirects[$row->up_page][] = $row;
966954 }
967955 }
968956
@@ -982,11 +970,8 @@
983971
984972 function openPage( $row ) {
985973 $out = parent::openPage( $row );
986 - if(isset($this->_references[$row->up_page]) && isset($this->_references[$row->up_page]->num_page_ref))
987 - $page_ref = $this->_references[$row->up_page]->num_page_ref;
988 - else
989 - $page_ref = 0;
990 - $out .= ' ' . wfElement( 'references', array(), strval( $page_ref ) ) . "\n";
 974+ if(isset($row->num_page_ref))
 975+ $out .= ' ' . wfElement( 'references', array(), strval( $row->num_page_ref ) ) . "\n";
991976 return $out;
992977 }
993978

Status & tagging log