* (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.
This commit is contained in:
Brion Vibber 2006-03-11 07:55:42 +00:00
parent 75bc402284
commit 4ba00d60cb
2 changed files with 52 additions and 23 deletions

View 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 ===

View 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() );
}
/**
* 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;
}
/**
* Stop watching a page
* 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