r33387 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33386‎ | r33387 | r33388 >
Date:19:02, 15 April 2008
Author:brion
Status:old
Tags:
Comment:
* (bug 13725) Upload form watch checkbox state set correctly with wpDestFile

r33330 just disabled the check for wpDestFile, so that the 'watch pages i create'
setting would watch *all* uploads. The system now checks the actual value, so
it sets the watch checkbox if the requested file doesn't exist locally and you
have it set for creations, or if you've already got the file watched.

There are still some minor issues:
* Since you have the chance to change the target filename on the form, the
initial checkbox state can get out of sync if you switch from an empty file
to an existing file or vice-versa.
* Unlike the edit form, the upload form doesn't _unwatch_ a previously-watched
page when the box is unchecked.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUpload.php
@@ -1016,8 +1016,7 @@
10171017
10181018 $encDestName = htmlspecialchars( $this->mDesiredDestName );
10191019
1020 - $watchChecked =
1021 - ( $wgUser->getOption( 'watchdefault' ) || $wgUser->getOption( 'watchcreations' ) )
 1020+ $watchChecked = $this->watchCheck()
10221021 ? 'checked="checked"'
10231022 : '';
10241023 $warningChecked = $this->mIgnoreWarning ? 'checked' : '';
@@ -1192,6 +1191,35 @@
11931192 }
11941193
11951194 /* -------------------------------------------------------------- */
 1195+
 1196+ /**
 1197+ * See if we should check the 'watch this page' checkbox on the form
 1198+ * based on the user's preferences and whether we're being asked
 1199+ * to create a new file or update an existing one.
 1200+ *
 1201+ * In the case where 'watch edits' is off but 'watch creations' is on,
 1202+ * we'll leave the box unchecked.
 1203+ *
 1204+ * Note that the page target can be changed *on the form*, so our check
 1205+ * state can get out of sync.
 1206+ */
 1207+ function watchCheck() {
 1208+ global $wgUser;
 1209+ if( $wgUser->getOption( 'watchdefault' ) ) {
 1210+ // Watch all edits!
 1211+ return true;
 1212+ }
 1213+
 1214+ $local = wfLocalFile( $this->mDesiredDestName );
 1215+ if( $local && $local->exists() ) {
 1216+ // We're uploading a new version of an existing file.
 1217+ // No creation, so don't watch it if we're not already.
 1218+ return $local->getTitle()->userIsWatching();
 1219+ } else {
 1220+ // New page should get watched if that's our option.
 1221+ return $wgUser->getOption( 'watchcreations' );
 1222+ }
 1223+ }
11961224
11971225 /**
11981226 * Split a file into a base name and all dot-delimited 'extensions'
Index: trunk/phase3/RELEASE-NOTES
@@ -184,7 +184,9 @@
185185 * (bug 13728) Don't trim initial whitespace during section edits
186186 * (bug 13727) Don't delete log entries from recentchanges on page deletion
187187 * (bug 13752) Section redirects now works again
 188+* (bug 13725) Upload form watch checkbox state set correctly with wpDestFile
188189
 190+
189191 === API changes in 1.13 ===
190192
191193 * Fixing main page display in meta=siteinfo

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r33330Revert strange dest check from r17248 (bug 13725)aaron06:23, 15 April 2008

Status & tagging log