From 4ba00d60cbbd27ec1b6e6af04c0ace54df016eb1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 11 Mar 2006 07:55:42 +0000 Subject: [PATCH] * (bug 5228) Workaround for broken LanguageConverter title overrides; avoid unnecessary hidden UI work when watch/unwatch is performed on edit This was changing the title to the 'addedwatch' or 'removedwatch' messages when checking/unchecking the watch box when saving edits. This bogus title got saved in the parser cache and served back up. Affected sr, didn't test zh. --- RELEASE-NOTES | 2 ++ includes/Article.php | 73 ++++++++++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c8ac041a3f..04c2d86d50 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -681,6 +681,8 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 4855) Section edit links now have the section name in the title attribute. * (bug 2115) Support shift-selecting multiple checkboxes with JavaScript. * (bug 5161) Don't try to load template list for nonexistent pages +* (bug 5228) Workaround for broken LanguageConverter title overrides; avoid + unnecessary hidden UI work when watch/unwatch is performed on edit === Caveats === diff --git a/includes/Article.php b/includes/Article.php index 06d165a465..8b48d50ac3 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1185,10 +1185,10 @@ class Article { } if ($watchthis) { - if(!$this->mTitle->userIsWatching()) $this->watch(); + if(!$this->mTitle->userIsWatching()) $this->doWatch(); } else { if ( $this->mTitle->userIsWatching() ) { - $this->unwatch(); + $this->doUnwatch(); } } @@ -1411,14 +1411,14 @@ class Article { if (!$this->mTitle->userIsWatching()) { $dbw->immediateCommit(); $dbw->begin(); - $this->watch(); + $this->doWatch(); $dbw->commit(); } } else { if ( $this->mTitle->userIsWatching() ) { $dbw->immediateCommit(); $dbw->begin(); - $this->unwatch(); + $this->doUnwatch(); $dbw->commit(); } } @@ -1526,7 +1526,7 @@ class Article { } /** - * Add this page to $wgUser's watchlist + * User-interface handler for the "watch" action */ function watch() { @@ -1541,14 +1541,8 @@ class Article { $wgOut->readOnlyPage(); return; } - - if (wfRunHooks('WatchArticle', array(&$wgUser, &$this))) { - - $wgUser->addWatch( $this->mTitle ); - $wgUser->saveSettings(); - - wfRunHooks('WatchArticleComplete', array(&$wgUser, &$this)); - + + if( $this->doWatch() ) { $wgOut->setPagetitle( wfMsg( 'addedwatch' ) ); $wgOut->setRobotpolicy( 'noindex,follow' ); @@ -1559,11 +1553,30 @@ class Article { $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() ); } - + /** - * Stop watching a page + * Add this page to $wgUser's watchlist + * @return bool true on successful watch operation */ + function doWatch() { + global $wgUser; + if( $wgUser->isAnon() ) { + return false; + } + + if (wfRunHooks('WatchArticle', array(&$wgUser, &$this))) { + $wgUser->addWatch( $this->mTitle ); + $wgUser->saveSettings(); + return wfRunHooks('WatchArticleComplete', array(&$wgUser, &$this)); + } + + return false; + } + + /** + * User interface handler for the "unwatch" action. + */ function unwatch() { global $wgUser, $wgOut; @@ -1576,14 +1589,8 @@ class Article { $wgOut->readOnlyPage(); return; } - - if (wfRunHooks('UnwatchArticle', array(&$wgUser, &$this))) { - - $wgUser->removeWatch( $this->mTitle ); - $wgUser->saveSettings(); - - wfRunHooks('UnwatchArticleComplete', array(&$wgUser, &$this)); - + + if( $this->doUnwatch() ) { $wgOut->setPagetitle( wfMsg( 'removedwatch' ) ); $wgOut->setRobotpolicy( 'noindex,follow' ); @@ -1594,6 +1601,26 @@ class Article { $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() ); } + + /** + * Stop watching a page + * @return bool true on successful unwatch + */ + function doUnwatch() { + global $wgUser; + if( $wgUser->isAnon() ) { + return false; + } + + if (wfRunHooks('UnwatchArticle', array(&$wgUser, &$this))) { + $wgUser->removeWatch( $this->mTitle ); + $wgUser->saveSettings(); + + return wfRunHooks('UnwatchArticleComplete', array(&$wgUser, &$this)); + } + + return false; + } /** * action=protect handler -- 2.20.1