jenkins-bot has submitted this change and it was merged.

Change subject: Add preference for watching uploaded files
......................................................................


Add preference for watching uploaded files

Adds a preference in the Watchlist section for watching uploaded files
for an account. Also works from API-based upload methods, so
UploadWizard and other tools should work fine.

Bug: T33313
Change-Id: If962e667de12b35904b2d1b2d9e99c26b588ec2a
---
M RELEASE-NOTES-1.27
M includes/DefaultSettings.php
M includes/Preferences.php
M includes/api/ApiUpload.php
M includes/specials/SpecialUpload.php
M languages/i18n/en.json
M languages/i18n/qqq.json
7 files changed, 21 insertions(+), 8 deletions(-)

Approvals:
  Anomie: Looks good to me, but someone else must approve
  Bartosz Dziewoński: Looks good to me, but someone else must approve
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 915b93b..4918ac9 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -181,6 +181,8 @@
   and error messages. It is available client-side via mw.config.get( 
'wgRequestId' ).
   The request ID supplants exception IDs. Accordingly, 
MWExceptionHandler::getLogId()
   is deprecated.
+* (T33313) Add a preference for watching uploads by default, also applies
+  to API-based upload tools.
 
 === External library changes in 1.27 ===
 
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 711967e..26a6676 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -4563,6 +4563,7 @@
        'watchcreations' => 1,
        'watchdefault' => 1,
        'watchdeletion' => 0,
+       'watchuploads' => 1,
        'watchlistdays' => 3.0,
        'watchlisthideanons' => 0,
        'watchlisthidebots' => 0,
diff --git a/includes/Preferences.php b/includes/Preferences.php
index 54176a6..d076219 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -1042,10 +1042,14 @@
                        $watchTypes['rollback'] = 'watchrollback';
                }
 
+               if ( $user->isAllowed( 'upload' ) ) {
+                       $watchTypes['upload'] = 'watchuploads';
+               }
+
                foreach ( $watchTypes as $action => $pref ) {
                        if ( $user->isAllowed( $action ) ) {
                                // Messages:
-                               // tog-watchdefault, tog-watchmoves, 
tog-watchdeletion, tog-watchcreations
+                               // tog-watchdefault, tog-watchmoves, 
tog-watchdeletion, tog-watchcreations, tog-watchuploads
                                // tog-watchrollback
                                $defaultPreferences[$pref] = [
                                        'type' => 'toggle',
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index 326f8ba..a5e2fbb 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -685,16 +685,19 @@
                /** @var $file File */
                $file = $this->mUpload->getLocalFile();
 
-               // For preferences mode, we want to watch if 'watchdefault' is 
set or
-               // if the *file* doesn't exist and 'watchcreations' is set. But
-               // getWatchlistValue()'s automatic handling checks if the 
*title*
-               // exists or not, so we need to check both prefs manually.
+               // For preferences mode, we want to watch if 'watchdefault' is 
set,
+               // or if the *file* doesn't exist, and either 'watchuploads' or
+               // 'watchcreations' is set. But getWatchlistValue()'s automatic
+               // handling checks if the *title* exists or not, so we need to 
check
+               // all three preferences manually.
                $watch = $this->getWatchlistValue(
                        $this->mParams['watchlist'], $file->getTitle(), 
'watchdefault'
                );
+
                if ( !$watch && $this->mParams['watchlist'] == 'preferences' && 
!$file->exists() ) {
-                       $watch = $this->getWatchlistValue(
-                               $this->mParams['watchlist'], $file->getTitle(), 
'watchcreations'
+                       $watch = (
+                               $this->getWatchlistValue( 'preferences', 
$file->getTitle(), 'watchuploads' ) ||
+                               $this->getWatchlistValue( 'preferences', 
$file->getTitle(), 'watchcreations' )
                        );
                }
 
diff --git a/includes/specials/SpecialUpload.php 
b/includes/specials/SpecialUpload.php
index 2754b13..82e07fd 100644
--- a/includes/specials/SpecialUpload.php
+++ b/includes/specials/SpecialUpload.php
@@ -622,7 +622,8 @@
                        return false;
                } else {
                        // New page should get watched if that's our option.
-                       return $this->getUser()->getOption( 'watchcreations' );
+                       return $this->getUser()->getOption( 'watchcreations' ) 
||
+                               $this->getUser()->getOption( 'watchuploads' );
                }
        }
 
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 51d4659..1d97ee9 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -18,6 +18,7 @@
        "tog-watchdefault": "Add pages and files I edit to my watchlist",
        "tog-watchmoves": "Add pages and files I move to my watchlist",
        "tog-watchdeletion": "Add pages and files I delete to my watchlist",
+       "tog-watchuploads": "Add new files I upload to my watchlist",
        "tog-watchrollback": "Add pages where I have performed a rollback to my 
watchlist",
        "tog-minordefault": "Mark all edits minor by default",
        "tog-previewontop": "Show preview before edit box",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 3eca961..0b18352 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -194,6 +194,7 @@
        "tog-watchdefault": "[[Special:Preferences]], tab 'Watchlist'. Offers 
user to add edited pages to watchlist. {{Gender}}",
        "tog-watchmoves": "[[Special:Preferences]], tab 'Watchlist'. Offers 
user to add moved pages to watchlist. {{Gender}}",
        "tog-watchdeletion": "[[Special:Preferences]], tab 'Watchlist'. Offers 
user to add deleted pages to watchlist. {{Gender}}",
+       "tog-watchuploads": "[[Special:Preferences]], tab 'Watchlist'. Offers 
user to add their uploaded files to watchlist. {{Gender}}",
        "tog-watchrollback": "[[Special:Preferences]], tab 'Watchlist'. Offers 
user to add pages where the user has rollbacked an edit to watchlist. 
{{Gender}}\n\nSee also {{msg-mw|tog-watchdefault}}, 
{{msg-mw|tog-watchcreations}}.",
        "tog-minordefault": "[[Special:Preferences]], tab 'Edit'. Offers user 
to mark all edits minor by default.  {{Gender}}",
        "tog-previewontop": "Toggle option used in [[Special:Preferences]]. 
{{Gender}}",

-- 
To view, visit https://gerrit.wikimedia.org/r/11063
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If962e667de12b35904b2d1b2d9e99c26b588ec2a
Gerrit-PatchSet: 18
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Aaron Pramana <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Eloquence <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: btongminh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to