r76443 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76442‎ | r76443 | r76444 >
Date:14:48, 10 November 2010
Author:ialex
Status:ok
Tags:
Comment:
Fixed some doxygen warnings (and some whitespaces removal I forgot to commit in r76386)
Modified paths:
  • /trunk/phase3/includes/specials/SpecialUploadStash.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUploadStash.php
@@ -1,10 +1,10 @@
22 <?php
33 /**
4 - * Special:UploadStash
 4+ * Implements Special:UploadStash
55 *
66 * Web access for files temporarily stored by UploadStash.
77 *
8 - * For example -- files that were uploaded with the UploadWizard extension are stored temporarily
 8+ * For example -- files that were uploaded with the UploadWizard extension are stored temporarily
99 * before committing them to the db. But we want to see their thumbnails and get other information
1010 * about them.
1111 *
@@ -34,13 +34,13 @@
3535 /**
3636 * If file available in stash, cats it out to the client as a simple HTTP response.
3737 * n.b. Most sanity checking done in UploadStashLocalFile, so this is straightforward.
38 - *
39 - * @param {String} $subPage: subpage, e.g. in http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part
40 - * @return {Boolean} success
 38+ *
 39+ * @param $subPage String: subpage, e.g. in http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part
 40+ * @return Boolean: success
4141 */
4242 public function execute( $subPage ) {
4343 global $wgOut, $wgUser;
44 -
 44+
4545 if ( !$this->userCanExecute( $wgUser ) ) {
4646 $this->displayRestrictionError();
4747 return;
@@ -49,7 +49,7 @@
5050 // prevent callers from doing standard HTML output -- we'll take it from here
5151 $wgOut->disable();
5252
53 - try {
 53+ try {
5454 $file = $this->getStashFile( $subPage );
5555 if ( $file->getSize() > $this->maxServeFileSize ) {
5656 throw new MWException( 'file size too large' );
@@ -64,21 +64,23 @@
6565 } catch( Exception $e ) {
6666 $code = 500;
6767 }
68 -
 68+
6969 wfHttpError( $code, OutputPage::getStatusMessage( $code ), $e->getMessage() );
7070 return false;
7171 }
7272
7373
74 - /**
75 - * Convert the incoming url portion (subpage of Special page) into a stashed file, if available.
76 - * @param {String} $subPage
77 - * @return {File} file object
 74+ /**
 75+ * Convert the incoming url portion (subpage of Special page) into a stashed file,
 76+ * if available.
 77+ *
 78+ * @param $subPage String
 79+ * @return File object
7880 * @throws MWException, UploadStashFileNotFoundException, UploadStashBadPathException
7981 */
8082 private function getStashFile( $subPage ) {
81 - // due to an implementation quirk (and trying to be compatible with older method)
82 - // the stash key doesn't have an extension
 83+ // due to an implementation quirk (and trying to be compatible with older method)
 84+ // the stash key doesn't have an extension
8385 $key = $subPage;
8486 $n = strrpos( $subPage, '.' );
8587 if ( $n !== false ) {
@@ -87,12 +89,12 @@
8890
8991 try {
9092 $file = $this->stash->getFile( $key );
91 - } catch ( UploadStashFileNotFoundException $e ) {
 93+ } catch ( UploadStashFileNotFoundException $e ) {
9294 // if we couldn't find it, and it looks like a thumbnail,
9395 // and it looks like we have the original, go ahead and generate it
9496 $matches = array();
9597 if ( ! preg_match( '/^(\d+)px-(.*)$/', $key, $matches ) ) {
96 - // that doesn't look like a thumbnail. re-raise exception
 98+ // that doesn't look like a thumbnail. re-raise exception
9799 throw $e;
98100 }
99101
@@ -102,11 +104,11 @@
103105 // let exceptions propagate to caller.
104106 $origFile = $this->stash->getFile( $origKey );
105107
106 - // ok we're here so the original must exist. Generate the thumbnail.
 108+ // ok we're here so the original must exist. Generate the thumbnail.
107109 // because the file is a UploadStashFile, this thumbnail will also be stashed,
108110 // and a thumbnailFile will be created in the thumbnailImage composite object
109111 $thumbnailImage = $origFile->transform( array( 'width' => $width ) );
110 - if ( !$thumbnailImage ) {
 112+ if ( !$thumbnailImage ) {
111113 throw new MWException( 'Could not obtain thumbnail' );
112114 }
113115 $file = $thumbnailImage->thumbnailFile;
@@ -118,9 +120,10 @@
119121 /**
120122 * Output HTTP response for file
121123 * Side effects, obviously, of echoing lots of stuff to stdout.
122 - * @param {File} file
 124+ *
 125+ * @param $file File object
123126 */
124 - private function outputFile( $file ) {
 127+ private function outputFile( $file ) {
125128 header( 'Content-Type: ' . $file->getMimeType(), true );
126129 header( 'Content-Transfer-Encoding: binary', true );
127130 header( 'Expires: Sun, 17-Jan-2038 19:14:07 GMT', true );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r76386* Marked Special:UploadStash unlisted since accessing it only subpage param o...ialex12:56, 9 November 2010

Status & tagging log