r14303 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14302‎ | r14303 | r14304 >
Date:02:14, 20 May 2006
Author:yurik
Status:old
Tags:
Comment:
Added a query to find pages without any interwikies.
Modified paths:
  • /trunk/extensions/BotQuery/query.php (modified) (history)

Diff [purge]

Index: trunk/extensions/BotQuery/query.php
@@ -149,6 +149,16 @@
150150 "apnamespaces - limits which namespace to enumerate. Default 0 (Main)",
151151 "Example: query.php?what=allpages&aplimit=50",
152152 )),
 153+ 'nolanglinks' => array( "genMetaNoLangLinksPages", true,
 154+ array( 'nllimit', 'nlfromid' ),
 155+ array( 50, 0 ),
 156+ array(
 157+ "Enumerates pages without language links to the output list.",
 158+ "Parameters supported:",
 159+ "nllimit - how many total pages to return",
 160+ "nlfromid - the page id to start enumerating from. Default is 0",
 161+ "Example: query.php?what=nolanglinks&nllimit=50",
 162+ )),
153163 'users' => array( "genUserPages", true,
154164 array( 'usfrom', 'uslimit' ),
155165 array( null, 50 ),
@@ -692,6 +702,47 @@
693703 }
694704
695705 //
 706+ // TODO: This is very inefficient - we can get the actual page information, instead we make two identical query.
 707+ //
 708+ function genMetaNoLangLinksPages(&$prop, &$genInfo) {
 709+ global $wgContLang;
 710+ extract( $this->getParams( $prop, $genInfo ));
 711+
 712+ extract( $this->db->tableNames( 'page', 'langlinks' ) );
 713+
 714+ //
 715+ // Find all pages without any rows in the langlinks table
 716+ //
 717+ $sql = 'SELECT'
 718+ . ' page_id'
 719+ . " FROM $page LEFT JOIN $langlinks ON page_id = ll_from"
 720+ . ' WHERE'
 721+ . ' ll_from IS NULL AND page_id >= ' . intval($nlfromid)
 722+ . ' ORDER BY page_id'
 723+ . ' LIMIT ' . intval($nllimit+1);
 724+
 725+ $this->startProfiling();
 726+ $res = $this->db->query( $sql, $this->classname . '::genMetaNoLangLinksPages' );
 727+ $this->endProfiling($prop);
 728+
 729+ // Add found page ids to the list of requested titles - they will be auto-populated later
 730+ $count = 0;
 731+ while ( $row = $this->db->fetchObject( $res ) ) {
 732+ if( ++$count >= $nllimit ) {
 733+ // We've reached the one extra which shows that there are
 734+ // additional pages to be had. Stop here...
 735+ break;
 736+ }
 737+ $this->addRaw( 'pageids', $row->page_id );
 738+ }
 739+ if( $count < $nllimit || !$row ) {
 740+ $this->addStatusMessage( $prop, array('next' => 0) );
 741+ } else {
 742+ $this->addStatusMessage( $prop, array('next' => $row->page_id) );
 743+ }
 744+ $this->db->freeResult( $res );
 745+ }
 746+ //
696747 // ************************************* PAGE INFO GENERATORS *************************************
697748 //
698749

Status & tagging log