Special:EditWatchlist/raw now make use of GenderCache
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 22 Jun 2012 16:39:33 +0000 (18:39 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 22 Jun 2012 16:39:33 +0000 (18:39 +0200)
Without GenderCache, each user page on the watchlist produce a
database query to get the gender.

Not changing to compare titles, because there is a comment, that titles
are memory-heavy and that makes problems

Change-Id: I1acda84eb3a63116ea1aa2d28d19a66cc3577afd

includes/specials/SpecialEditWatchlist.php

index b7f1e61..77e1dc7 100644 (file)
@@ -129,21 +129,28 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         * @return array
         */
        private function extractTitles( $list ) {
-               $titles = array();
                $list = explode( "\n", trim( $list ) );
                if( !is_array( $list ) ) {
                        return array();
                }
+               $titles = array();
                foreach( $list as $text ) {
                        $text = trim( $text );
                        if( strlen( $text ) > 0 ) {
                                $title = Title::newFromText( $text );
                                if( $title instanceof Title && $title->isWatchable() ) {
-                                       $titles[] = $title->getPrefixedText();
+                                       $titles[] = $title;
                                }
                        }
                }
-               return array_unique( $titles );
+
+               GenderCache::singleton()->doTitlesArray( $titles );
+
+               $list = array();
+               foreach( $titles as $title ) {
+                       $list[] = $title->getPrefixedText();
+               }
+               return array_unique( $list );
        }
 
        public function submitRaw( $data ){
@@ -248,15 +255,22 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        __METHOD__
                );
                if( $res->numRows() > 0 ) {
+                       $titles = array();
                        foreach ( $res as $row ) {
                                $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
                                if ( $this->checkTitle( $title, $row->wl_namespace, $row->wl_title )
                                        && !$title->isTalkPage()
                                ) {
-                                       $list[] = $title->getPrefixedText();
+                                       $titles[] = $title;
                                }
                        }
                        $res->free();
+
+                       GenderCache::singleton()->doTitlesArray( $titles );
+
+                       foreach( $titles as $title ) {
+                               $list[] = $title->getPrefixedText();
+                       }
                }
                $this->cleanupWatchlist();
                return $list;