Merge "Fix wrong @return type hints in Language::tsTo… methods"
[lhc/web/wiklou.git] / includes / api / ApiUpload.php
index 79e88c6..1571b27 100644 (file)
@@ -257,7 +257,7 @@ class ApiUpload extends ApiBase {
                                        'offset' => $this->mUpload->getOffset(),
                                ];
 
-                               $this->dieUsage( $status->getWikiText(), 'stashfailed', 0, $extradata );
+                               $this->dieUsage( $status->getWikiText( false, false, 'en' ), 'stashfailed', 0, $extradata );
                        }
                }
 
@@ -288,7 +288,7 @@ class ApiUpload extends ApiBase {
                                                $filekey,
                                                [ 'result' => 'Failure', 'stage' => 'assembling', 'status' => $status ]
                                        );
-                                       $this->dieUsage( $status->getWikiText(), 'stashfailed' );
+                                       $this->dieUsage( $status->getWikiText( false, false, 'en' ), 'stashfailed' );
                                }
 
                                // The fully concatenated file has a new filekey. So remove
@@ -391,7 +391,7 @@ class ApiUpload extends ApiBase {
                        if ( !$progress ) {
                                $this->dieUsage( 'No result in status data', 'missingresult' );
                        } elseif ( !$progress['status']->isGood() ) {
-                               $this->dieUsage( $progress['status']->getWikiText(), 'stashfailed' );
+                               $this->dieUsage( $progress['status']->getWikiText( false, false, 'en' ), 'stashfailed' );
                        }
                        if ( isset( $progress['status']->value['verification'] ) ) {
                                $this->checkVerification( $progress['status']->value['verification'] );
@@ -542,9 +542,9 @@ class ApiUpload extends ApiBase {
                                ];
                                ApiResult::setIndexedTagName( $extradata['allowed'], 'ext' );
 
-                               $msg = "Filetype not permitted: ";
+                               $msg = 'Filetype not permitted: ';
                                if ( isset( $verification['blacklistedExt'] ) ) {
-                                       $msg .= join( ', ', $verification['blacklistedExt'] );
+                                       $msg .= implode( ', ', $verification['blacklistedExt'] );
                                        $extradata['blacklisted'] = array_values( $verification['blacklistedExt'] );
                                        ApiResult::setIndexedTagName( $extradata['blacklisted'], 'ext' );
                                } else {
@@ -664,7 +664,7 @@ class ApiUpload extends ApiBase {
                                $this->dieUsage( 'No such filekey: ' . $e->getMessage(), 'stashnosuchfilekey' );
                                break;
                        default:
-                               $this->dieUsage( $exceptionType . ": " . $e->getMessage(), 'stasherror' );
+                               $this->dieUsage( $exceptionType . ': ' . $e->getMessage(), 'stasherror' );
                                break;
                }
        }
@@ -685,16 +685,19 @@ class ApiUpload extends ApiBase {
                /** @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' )
                        );
                }
 
@@ -714,7 +717,7 @@ class ApiUpload extends ApiBase {
                if ( $this->mParams['async'] ) {
                        $progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] );
                        if ( $progress && $progress['result'] === 'Poll' ) {
-                               $this->dieUsage( "Upload from stash already in progress.", 'publishfailed' );
+                               $this->dieUsage( 'Upload from stash already in progress.', 'publishfailed' );
                        }
                        UploadBase::setSessionStatus(
                                $this->getUser(),