http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88849

Revision: 88849
Author:   yuvipanda
Date:     2011-05-25 22:28:23 +0000 (Wed, 25 May 2011)
Log Message:
-----------
Moved to fetchObject consistently

Modified Paths:
--------------
    trunk/extensions/ShortUrl/ShortUrl.functions.php
    trunk/extensions/ShortUrl/populateShortUrlTable.php

Modified: trunk/extensions/ShortUrl/ShortUrl.functions.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.functions.php    2011-05-25 22:19:14 UTC 
(rev 88848)
+++ trunk/extensions/ShortUrl/ShortUrl.functions.php    2011-05-25 22:28:23 UTC 
(rev 88849)
@@ -29,8 +29,8 @@
                        array( 'su_namespace' => $title->getNamespace(), 
'su_title' => $title->getDBkey() ),
                        __METHOD__ );
                if ( $dbr->numRows( $query ) > 0 ) {
-                       $entry = $dbr->fetchRow( $query );
-                       $id = $entry['su_id'];
+                       $entry = $dbr->fetchObject( $query );
+                       $id = $entry->su_id;
                } else {
                        $dbw = wfGetDB( DB_MASTER );
                        $row_data = array(
@@ -64,7 +64,7 @@
                        __METHOD__
                );
 
-               $entry = $dbr->fetchRow( $query );
+               $entry = $dbr->fetchRow( $query ); // Less overhead on 
memcaching
                $wgMemc->set( wfMemcKey( 'shorturls', 'id', $id ), $entry, 0 );
        }
        return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] );

Modified: trunk/extensions/ShortUrl/populateShortUrlTable.php
===================================================================
--- trunk/extensions/ShortUrl/populateShortUrlTable.php 2011-05-25 22:19:14 UTC 
(rev 88848)
+++ trunk/extensions/ShortUrl/populateShortUrlTable.php 2011-05-25 22:28:23 UTC 
(rev 88849)
@@ -24,19 +24,18 @@
 
     //FIXME: Refactor out code in ShortUrl.functions.php so it can be used here
        public function execute() {
-               $rowCount = 1;
+               $rowCount = 0;
                $dbr = wfGetDB( DB_SLAVE );
         $all_titles = $dbr->select(
                        "page",
                        array( "page_namespace", "page_title" )
                );
                $insert_buffer = array();
-               $row = $dbr->fetchRow( $all_titles );
 
-               while( $row ) {
+               foreach( $res as $row ) {
                        $row_data = array(
-                               'su_namespace' => $row['page_namespace'],
-                               'su_title' => $row['page_title']
+                               'su_namespace' => $row->page_namespace,
+                               'su_title' => $row->page_title
                        );
                        array_push( $insert_buffer, $row_data );
                        if( count( $insert_buffer ) % 100 == 0) {
@@ -45,7 +44,6 @@
                        }
                        $this->output( $rowCount . " titles done\n" );
                        
-                       $row = $dbr->fetchRow( $all_titles );
                        $rowCount++;
                }
                if( count( $insert_buffer ) > 0 ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to