From e5a511089d0b9f41287f0a585ebd7492d280bf49 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 22 Jun 2012 18:39:33 +0200 Subject: [PATCH] Special:EditWatchlist/raw now make use of GenderCache 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 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index b7f1e61686..77e1dc71cf 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -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; -- 2.20.1