* (bug 13728) Don't trim initial whitespace during section edits
* (bug 13727) Don't delete log entries from recentchanges on page deletion
* (bug 13752) Section redirects now works again
+* (bug 13725) Upload form watch checkbox state set correctly with wpDestFile
+
=== API changes in 1.13 ===
$encDestName = htmlspecialchars( $this->mDesiredDestName );
- $watchChecked =
- ( $wgUser->getOption( 'watchdefault' ) || $wgUser->getOption( 'watchcreations' ) )
+ $watchChecked = $this->watchCheck()
? 'checked="checked"'
: '';
$warningChecked = $this->mIgnoreWarning ? 'checked' : '';
}
/* -------------------------------------------------------------- */
+
+ /**
+ * See if we should check the 'watch this page' checkbox on the form
+ * based on the user's preferences and whether we're being asked
+ * to create a new file or update an existing one.
+ *
+ * In the case where 'watch edits' is off but 'watch creations' is on,
+ * we'll leave the box unchecked.
+ *
+ * Note that the page target can be changed *on the form*, so our check
+ * state can get out of sync.
+ */
+ function watchCheck() {
+ global $wgUser;
+ if( $wgUser->getOption( 'watchdefault' ) ) {
+ // Watch all edits!
+ return true;
+ }
+
+ $local = wfLocalFile( $this->mDesiredDestName );
+ if( $local && $local->exists() ) {
+ // We're uploading a new version of an existing file.
+ // No creation, so don't watch it if we're not already.
+ return $local->getTitle()->userIsWatching();
+ } else {
+ // New page should get watched if that's our option.
+ return $wgUser->getOption( 'watchcreations' );
+ }
+ }
/**
* Split a file into a base name and all dot-delimited 'extensions'