Index: branches/uploadwizard/phase3/includes/upload/SessionStash.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | $this->repo = $repo; |
41 | 41 | |
42 | 42 | if ( ! isset( $_SESSION ) ) { |
43 | | - throw new SessionStashNotAvailableException( 'no session var' ); |
| 43 | + throw new SessionStashNotAvailableException( 'no session variable' ); |
44 | 44 | } |
45 | 45 | |
46 | 46 | if ( !isset( $_SESSION[UploadBase::SESSION_KEYNAME] ) ) { |
— | — | @@ -68,13 +68,13 @@ |
69 | 69 | public function getFile( $key ) { |
70 | 70 | if ( !isset( $this->files[$key] ) ) { |
71 | 71 | if ( !isset( $_SESSION[UploadBase::SESSION_KEYNAME][$key] ) ) { |
72 | | - throw new SessionStashFileNotFoundException(); |
| 72 | + throw new SessionStashFileNotFoundException( "key '$key' not found in session" ); |
73 | 73 | } |
74 | 74 | |
75 | 75 | $data = $_SESSION[UploadBase::SESSION_KEYNAME][$key]; |
76 | 76 | // guards against PHP class changing while session data doesn't |
77 | 77 | if ($data['version'] !== UploadBase::SESSION_VERSION ) { |
78 | | - throw new SessionStashBadVersionException(); |
| 78 | + throw new SessionStashBadVersionException( $data['version'] . " does not match current version " . UploadBase::SESSION_VERSION ); |
79 | 79 | } |
80 | 80 | |
81 | 81 | // separate the stashData into the path, and then the rest of the data |
— | — | @@ -82,6 +82,7 @@ |
83 | 83 | unset( $data['mTempPath'] ); |
84 | 84 | |
85 | 85 | $file = new SessionStashFile( $this, $this->repo, $path, $key, $data ); |
| 86 | + |
86 | 87 | $this->files[$key] = $file; |
87 | 88 | |
88 | 89 | } |
— | — | @@ -100,7 +101,7 @@ |
101 | 102 | */ |
102 | 103 | public function stashFile( $path, $data = array(), $key = null ) { |
103 | 104 | if ( ! file_exists( $path ) ) { |
104 | | - throw new SessionStashBadPathException(); |
| 105 | + throw new SessionStashBadPathException( "path '$path' doesn't exist" ); |
105 | 106 | } |
106 | 107 | $fileProps = File::getPropsFromPath( $path ); |
107 | 108 | |
— | — | @@ -157,21 +158,22 @@ |
158 | 159 | $this->sessionStash = $stash; |
159 | 160 | $this->sessionKey = $key; |
160 | 161 | $this->sessionData = $data; |
161 | | - |
| 162 | + |
162 | 163 | // resolve mwrepo:// urls |
163 | 164 | if ( $repo->isVirtualUrl( $path ) ) { |
164 | 165 | $path = $repo->resolveVirtualUrl( $path ); |
165 | 166 | } |
166 | 167 | |
167 | 168 | // check if path appears to be sane, no parent traversals, and is in this repo's temp zone. |
| 169 | + $repoTempPath = $repo->getZonePath( 'temp' ); |
168 | 170 | if ( ( ! $repo->validateFilename( $path ) ) || |
169 | | - ( strpos( $path, $repo->getZonePath( 'temp' ) ) !== 0 ) ) { |
170 | | - throw new SessionStashBadPathException(); |
| 171 | + ( strpos( $path, $repoTempPath ) !== 0 ) ) { |
| 172 | + throw new SessionStashBadPathException( "path '$path' is not valid or is not in repo temp area: '$repoTempPath'" ); |
171 | 173 | } |
172 | 174 | |
173 | 175 | // check if path exists! and is a plain file. |
174 | 176 | if ( ! $repo->fileExists( $path, FileRepo::FILES_ONLY ) ) { |
175 | | - throw new SessionStashFileNotFoundException(); |
| 177 | + throw new SessionStashFileNotFoundException( "cannot find path '$path'" ); |
176 | 178 | } |
177 | 179 | |
178 | 180 | parent::__construct( false, $repo, $path, false ); |
— | — | @@ -186,10 +188,12 @@ |
187 | 189 | /** |
188 | 190 | * A method needed by the file transforming and scaling routines in File.php |
189 | 191 | * We do not necessarily care about doing the description at this point |
190 | | - * @return {String} the empty string |
| 192 | + * However, we also can't return the empty string, as the rest of MediaWiki demands this (and calls to imagemagick |
| 193 | + * convert require it to be there) |
| 194 | + * @return {String} dummy value |
191 | 195 | */ |
192 | 196 | public function getDescriptionUrl() { |
193 | | - return ''; |
| 197 | + return $this->getUrl(); |
194 | 198 | } |
195 | 199 | |
196 | 200 | /** |
— | — | @@ -220,7 +224,7 @@ |
221 | 225 | } |
222 | 226 | |
223 | 227 | if ( is_null( $extension ) ) { |
224 | | - throw new SessionStashFileException(); |
| 228 | + throw new SessionStashFileException( "extension '$extension' is null" ); |
225 | 229 | } |
226 | 230 | |
227 | 231 | $this->extension = parent::normalizeExtension( $extension ); |
Index: branches/uploadwizard/extensions/UploadWizard/ApiQueryStashImageInfo.php |
— | — | @@ -60,11 +60,11 @@ |
61 | 61 | } |
62 | 62 | |
63 | 63 | } catch ( SessionStashNotAvailableException $e ) { |
64 | | - $this->dieUsage( "Session not available", "nosession" ); |
| 64 | + $this->dieUsage( "Session not available: " . $e->getMessage(), "nosession" ); |
65 | 65 | } catch ( SessionStashFileNotFoundException $e ) { |
66 | | - $this->dieUsage( "File not found", "nosuchpageid" ); |
| 66 | + $this->dieUsage( "File not found: " . $e->getMessage(), "nosuchpageid" ); |
67 | 67 | } catch ( SessionStashBadPathException $e ) { |
68 | | - $this->dieUsage( "Bad path", "nosuchpageid" ); |
| 68 | + $this->dieUsage( "Bad path: " . $e->getMessage(), "nosuchpageid" ); |
69 | 69 | } |
70 | 70 | |
71 | 71 | } |