From 2ffcd1d25c9f1eeb49ce1c6a4119104a8a2f14f1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 19 Oct 2008 23:08:23 +0000 Subject: [PATCH] Backing out r42128 for now "added 'UnwatchArticle', 'WatchArticle' and 'WatchArticleComplete' in response to code review of rev 42109" Article::newFromId() does an individual id->title lookup in the database, making this potentially very expensive -- we could run thousands of queries in a row. --- includes/WatchlistEditor.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/includes/WatchlistEditor.php b/includes/WatchlistEditor.php index 9e044a8ca5..9877844fbc 100644 --- a/includes/WatchlistEditor.php +++ b/includes/WatchlistEditor.php @@ -269,18 +269,10 @@ class WatchlistEditor { private function watchTitles( $titles, $user ) { $dbw = wfGetDB( DB_MASTER ); $rows = array(); - $articles = array(); foreach( $titles as $title ) { if( !$title instanceof Title ) $title = Title::newFromText( $title ); if( $title instanceof Title ) { - $article = new Article( $title ); - if ( !wfRunHooks('WatchArticle',array( &$user, &$article ) ) ){ - continue; - } - // queue the ids rather than the objects, since the hook could potentially - // load the entire object and make memory trouble - $articleIds[] = $article->getID(); $rows[] = array( 'wl_user' => $user->getId(), 'wl_namespace' => ( $title->getNamespace() & ~1 ), @@ -296,10 +288,6 @@ class WatchlistEditor { } } $dbw->insert( 'watchlist', $rows, __METHOD__, 'IGNORE' ); - foreach( $articleIds as $articleId ){ - $article = Article::newFromID($articleId); - wfRunHooks('WatchArticleComplete',array(&$user,&$article)); - } } /** @@ -317,10 +305,6 @@ class WatchlistEditor { if( !$title instanceof Title ) $title = Title::newFromText( $title ); if( $title instanceof Title ) { - $article = new Article($title); - if(!wfRunHooks('UnwatchArticle',array(&$user,&$article))){ - continue; - } $dbw->delete( 'watchlist', array( @@ -339,6 +323,7 @@ class WatchlistEditor { ), __METHOD__ ); + $article = new Article($title); wfRunHooks('UnwatchArticleComplete',array(&$user,&$article)); } } -- 2.20.1