Revert r30162 for now.
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 26 Jan 2008 00:54:50 +0000 (00:54 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 26 Jan 2008 00:54:50 +0000 (00:54 +0000)
A problem with this is that it *un*watches a previously watched image under the following
circumstances:

* 'watch pages I edit' is not enabled (eg, default state)
* go to Special:Upload and select the file
* hit 'upload'

The initial check state is unchecked (since there was no initial destination name set), and this doesn't get updated to reflect the existing watch state of the previous image.

There are a couple possible ways around this. One is to compare the form's actual initial check state with the submitted check state and only apply an unwatch if there was a difference.

Another might be to do a watch state update via AJAX when a new destination filename is set in the form. This would allow the checkmark's default state to be set 'properly' for those with JS enabled in modern browsers.

Perhaps a combination should be used.

includes/SpecialUpload.php

index ed851be..657a1a5 100644 (file)
@@ -552,15 +552,10 @@ class UploadForm {
                        $resultDetails = array( 'internal' => $status->getWikiText() );
                        return self::INTERNAL_ERROR;
                } else {
-                       
-                       // Check if "Watch this page" is checked or not and process.
-                       global $wgUser;
                        if ( $this->mWatchthis ) {
+                               global $wgUser;
                                $wgUser->addWatch( $this->mLocalFile->getTitle() );
-                       } else {
-                               $wgUser->removeWatch( $this->mLocalFile->getTitle() );
                        }
-                       
                        // Success, redirect to description page
                        $img = null; // @todo: added to avoid passing a ref to null - should this be defined somewhere?
                        wfRunHooks( 'UploadComplete', array( &$img ) );
@@ -1015,8 +1010,7 @@ wgAjaxLicensePreview = {$alp};
 
                $watchChecked =
                        ( $wgUser->getOption( 'watchdefault' ) ||
-                               ( $wgUser->getOption( 'watchcreations' ) && $this->mDesiredDestName == '' ) ||
-                               ( isset( $title ) && $title->userIsWatching() ) )
+                               ( $wgUser->getOption( 'watchcreations' ) && $this->mDesiredDestName == '' ) )
                        ? 'checked="checked"'
                        : '';
                $warningChecked = $this->mIgnoreWarning ? 'checked' : '';