Remove return value from SpecialUploadStash::execute
authorUmherirrender <umherirrender_de.wp@web.de>
Mon, 3 Jun 2019 19:14:13 +0000 (21:14 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Fri, 7 Jun 2019 14:42:28 +0000 (16:42 +0200)
SpecialPage::execute never returns anything
Also remove the return value from the functions called here.
The special page is using exceptions instead of a bool to indicate
failure and success

Change-Id: Ia271fe06b8ce888a8448099020f7aedf23af30db

includes/specials/SpecialUploadStash.php

index c278bab..dac19a3 100644 (file)
@@ -62,7 +62,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         *
         * @param string|null $subPage Subpage, e.g. in
         *   https://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part
-        * @return bool Success
         */
        public function execute( $subPage ) {
                $this->useTransactionalTimeLimit();
@@ -71,10 +70,10 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                $this->checkPermissions();
 
                if ( $subPage === null || $subPage === '' ) {
-                       return $this->showUploads();
+                       $this->showUploads();
+               } else {
+                       $this->showUpload( $subPage );
                }
-
-               return $this->showUpload( $subPage );
        }
 
        /**
@@ -83,7 +82,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         *
         * @param string $key The key of a particular requested file
         * @throws HttpError
-        * @return bool
         */
        public function showUpload( $key ) {
                // prevent callers from doing standard HTML output -- we'll take it from here
@@ -92,10 +90,11 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                try {
                        $params = $this->parseKey( $key );
                        if ( $params['type'] === 'thumb' ) {
-                               return $this->outputThumbFromStash( $params['file'], $params['params'] );
+                               $this->outputThumbFromStash( $params['file'], $params['params'] );
                        } else {
-                               return $this->outputLocalFile( $params['file'] );
+                               $this->outputLocalFile( $params['file'] );
                        }
+                       return;
                } catch ( UploadStashFileNotFoundException $e ) {
                        $code = 404;
                        $message = $e->getMessage();
@@ -187,7 +186,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * @param array $params Scaling parameters ( e.g. [ width => '50' ] );
         * @param int $flags Scaling flags ( see File:: constants )
         * @throws MWException|UploadStashFileNotFoundException
-        * @return bool Success
         */
        private function outputLocallyScaledThumb( $file, $params, $flags ) {
                // n.b. this is stupid, we insist on re-transforming the file every time we are invoked. We rely
@@ -219,7 +217,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                        );
                }
 
-               return $this->outputLocalFile( $thumbFile );
+               $this->outputLocalFile( $thumbFile );
        }
 
        /**
@@ -239,7 +237,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * @param array $params Scaling parameters ( e.g. [ width => '50' ] );
         * @param int $flags Scaling flags ( see File:: constants )
         * @throws MWException
-        * @return bool Success
         */
        private function outputRemoteScaledThumb( $file, $params, $flags ) {
                // This option probably looks something like
@@ -303,7 +300,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                        );
                }
 
-               return $this->outputContents( $req->getContent(), $contentType );
+               $this->outputContents( $req->getContent(), $contentType );
        }
 
        /**
@@ -313,7 +310,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * @param File $file File object with a local path (e.g. UnregisteredLocalFile,
         *   LocalFile. Oddly these don't share an ancestor!)
         * @throws SpecialUploadStashTooLargeException
-        * @return bool
         */
        private function outputLocalFile( File $file ) {
                if ( $file->getSize() > self::MAX_SERVE_BYTES ) {
@@ -322,10 +318,10 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                        );
                }
 
-               return $file->getRepo()->streamFileWithStatus( $file->getPath(),
+               $file->getRepo()->streamFileWithStatus( $file->getPath(),
                        [ 'Content-Transfer-Encoding: binary',
                                'Expires: Sun, 17-Jan-2038 19:14:07 GMT' ]
-               )->isOK();
+               );
        }
 
        /**
@@ -334,7 +330,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * @param string $content
         * @param string $contentType MIME type
         * @throws SpecialUploadStashTooLargeException
-        * @return bool
         */
        private function outputContents( $content, $contentType ) {
                $size = strlen( $content );
@@ -347,8 +342,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                wfResetOutputBuffers();
                self::outputFileHeaders( $contentType, $size );
                print $content;
-
-               return true;
        }
 
        /**
@@ -394,7 +387,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
        /**
         * Default action when we don't have a subpage -- just show links to the uploads we have,
         * Also show a button to clear stashed files
-        * @return bool
         */
        private function showUploads() {
                // sets the title, etc.
@@ -459,7 +451,5 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                                . $refreshHtml
                        ) );
                }
-
-               return true;
        }
 }