From: Jason Richey Date: Wed, 15 Oct 2008 23:53:38 +0000 (+0000) Subject: added 'UnwatchArticle', 'WatchArticle' and 'WatchArticleComplete' in response to... X-Git-Tag: 1.31.0-rc.0~44727 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=b3d1fe3fb4bbc8079f92e46cb865ce90c7a43dad;p=lhc%2Fweb%2Fwiklou.git added 'UnwatchArticle', 'WatchArticle' and 'WatchArticleComplete' in response to code review of rev 42109 --- diff --git a/includes/WatchlistEditor.php b/includes/WatchlistEditor.php index 9877844fbc..9e044a8ca5 100644 --- a/includes/WatchlistEditor.php +++ b/includes/WatchlistEditor.php @@ -269,10 +269,18 @@ 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 ), @@ -288,6 +296,10 @@ class WatchlistEditor { } } $dbw->insert( 'watchlist', $rows, __METHOD__, 'IGNORE' ); + foreach( $articleIds as $articleId ){ + $article = Article::newFromID($articleId); + wfRunHooks('WatchArticleComplete',array(&$user,&$article)); + } } /** @@ -305,6 +317,10 @@ 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( @@ -323,7 +339,6 @@ class WatchlistEditor { ), __METHOD__ ); - $article = new Article($title); wfRunHooks('UnwatchArticleComplete',array(&$user,&$article)); } }