* (bug 5228) Workaround for broken LanguageConverter title overrides; avoid
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 11 Mar 2006 07:55:42 +0000 (07:55 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 11 Mar 2006 07:55:42 +0000 (07:55 +0000)
  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
includes/Article.php

index c8ac041..04c2d86 100644 (file)
@@ -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 ===
index 06d165a..8b48d50 100644 (file)
@@ -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