Merge "Add method parameter type documentation"
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index e6e784f..ce6ecda 100644 (file)
@@ -823,7 +823,7 @@ abstract class ApiBase extends ContextSource {
         */
        protected function getWatchlistValue( $watchlist, $titleObj, $userOption = null ) {
 
-               $userWatching = $this->getUser()->isWatched( $titleObj );
+               $userWatching = $this->getUser()->isWatched( $titleObj, WatchedItem::IGNORE_USER_RIGHTS );
 
                switch ( $watchlist ) {
                        case 'watch':
@@ -865,12 +865,7 @@ abstract class ApiBase extends ContextSource {
                        return;
                }
 
-               $user = $this->getUser();
-               if ( $value ) {
-                       WatchAction::doWatch( $titleObj, $user );
-               } else {
-                       WatchAction::doUnwatch( $titleObj, $user );
-               }
+               WatchAction::doWatchOrUnwatch( $value, $titleObj, $this->getUser() );
        }
 
        /**
@@ -1409,6 +1404,7 @@ abstract class ApiBase extends ContextSource {
                'uploaddisabled' => array( 'code' => 'uploaddisabled', 'info' => 'Uploads are not enabled. Make sure $wgEnableUploads is set to true in LocalSettings.php and the PHP ini setting file_uploads is true' ),
                'copyuploaddisabled' => array( 'code' => 'copyuploaddisabled', 'info' => 'Uploads by URL is not enabled. Make sure $wgAllowCopyUploads is set to true in LocalSettings.php.' ),
                'copyuploadbaddomain' => array( 'code' => 'copyuploadbaddomain', 'info' => 'Uploads by URL are not allowed from this domain.' ),
+               'copyuploadbadurl' => array( 'code' => 'copyuploadbadurl', 'info' => 'Upload not allowed from this URL.' ),
 
                'filename-tooshort' => array( 'code' => 'filename-tooshort', 'info' => 'The filename is too short' ),
                'filename-toolong' => array( 'code' => 'filename-toolong', 'info' => 'The filename is too long' ),
@@ -1507,7 +1503,7 @@ abstract class ApiBase extends ContextSource {
         * @param string $message Error message
         */
        protected static function dieDebug( $method, $message ) {
-               wfDebugDieBacktrace( "Internal error in $method: $message" );
+               throw new MWException( "Internal error in $method: $message" );
        }
 
        /**
@@ -1583,6 +1579,9 @@ abstract class ApiBase extends ContextSource {
                        if ( !$this->getUser()->isLoggedIn() ) {
                                $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
                        }
+                       if ( !$this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
+                               $this->dieUsage( 'You don\'t have permission to view your watchlist', 'permissiondenied' );
+                       }
                        $user = $this->getUser();
                }
                return $user;