Followup to r64962: Fixed watchlist parameter in API. User options watchdeletions...
[lhc/web/wiklou.git] / includes / api / ApiDelete.php
index 9689c97..f5294dd 100644 (file)
@@ -82,11 +82,16 @@ class ApiDelete extends ApiBase {
                                $this->dieUsageMsg( reset( $retval ) ); // We don't care about multiple errors, just report one of them
                        }
 
-                       if ( $params['watch'] || $wgUser->getOption( 'watchdeletion' ) ) {
-                               $articleObj->doWatch();
+                       $watch = 'nochange';
+                       // Deprecated parameters
+                       if ( $params['watch'] ) {
+                               $watch = 'watch';
                        } elseif ( $params['unwatch'] ) {
-                               $articleObj->doUnwatch();
+                               $watch = 'unwatch';
+                       } else {
+                               $watch = $params['watchlist'];
                        }
+                       $this->setWatch( $watch, $titleObj, 'watchdeletion' );
                }
 
                $r = array( 'title' => $titleObj->getPrefixedText(), 'reason' => $reason );
@@ -197,7 +202,19 @@ class ApiDelete extends ApiBase {
                        ),
                        'token' => null,
                        'reason' => null,
-                       'watch' => false,
+                       'watch' => array(
+                               ApiBase::PARAM_DFLT => false,
+                               ApiBase::PARAM_DEPRECATED => true,
+                       ),
+                       'watchlist' => array(
+                               ApiBase::PARAM_DFLT => 'preferences',
+                               ApiBase::PARAM_TYPE => array(
+                                       'watch',
+                                       'unwatch',
+                                       'preferences',
+                                       'nochange'
+                               ),
+                       ),
                        'unwatch' => false,
                        'oldimage' => null
                );
@@ -210,6 +227,7 @@ class ApiDelete extends ApiBase {
                        'token' => 'A delete token previously retrieved through prop=info',
                        'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used.',
                        'watch' => 'Add the page to your watchlist',
+                       'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
                        'unwatch' => 'Remove the page from your watchlist',
                        'oldimage' => 'The name of the old image to delete as provided by iiprop=archivename'
                );