Index: trunk/extensions/ConfirmAccount/frontend/specialpages/actions/UserCredentials_body.php |
— | — | @@ -202,8 +202,8 @@ |
203 | 203 | $request->response()->header( 'Pragma: no-cache' ); |
204 | 204 | |
205 | 205 | $repo = new FSRepo( $wgConfirmAccountFSRepos['accountcreds'] ); |
206 | | - $path = $repo->getZonePath( 'public' ).'/'. |
207 | | - $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
| 206 | + $path = $repo->getZonePath( 'public' ) . '/' . |
| 207 | + UserAccountRequest::relPathFromKey( $key ); |
208 | 208 | StreamFile::stream( $path ); |
209 | 209 | } |
210 | 210 | |
Index: trunk/extensions/ConfirmAccount/frontend/specialpages/actions/ConfirmAccount_body.php |
— | — | @@ -430,8 +430,8 @@ |
431 | 431 | $request->response()->header( 'Pragma: no-cache' ); |
432 | 432 | |
433 | 433 | $repo = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
434 | | - $path = $repo->getZonePath( 'public' ).'/'. |
435 | | - $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
| 434 | + $path = $repo->getZonePath( 'public' ) . '/' . |
| 435 | + UserAccountRequest::relPathFromKey( $key ); |
436 | 436 | |
437 | 437 | StreamFile::stream( $path ); |
438 | 438 | } |
Index: trunk/extensions/ConfirmAccount/backend/ConfirmAccount.class.php |
— | — | @@ -21,8 +21,8 @@ |
22 | 22 | foreach ( $res as $row ) { |
23 | 23 | $key = $row->acr_storage_key; |
24 | 24 | if ( $key ) { |
25 | | - $path = $repo->getZonePath( 'public' ).'/'. |
26 | | - $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
| 25 | + $path = $repo->getZonePath( 'public' ) . '/' . |
| 26 | + UserAccountRequest::relPathFromKey( $key ); |
27 | 27 | if ( $path && file_exists($path) ) { |
28 | 28 | unlink($path); |
29 | 29 | } |
Index: trunk/extensions/ConfirmAccount/backend/UserAccountRequest.php |
— | — | @@ -452,4 +452,14 @@ |
453 | 453 | unset( $list[count( $list ) - 1] ); |
454 | 454 | return $list; |
455 | 455 | } |
| 456 | + |
| 457 | + /** |
| 458 | + * Get path relative to zone for an account request attachment file. |
| 459 | + * This assures compatibility with the old FileStore sytem. |
| 460 | + * @param $key string File storage key |
| 461 | + * @return string |
| 462 | + */ |
| 463 | + public static function relPathFromKey( $key ) { |
| 464 | + return "{$key[0]}/{$key[0]}{$key[1]}/{$key[0]}{$key[1]}{$key[2]}/{$key}"; |
| 465 | + } |
456 | 466 | } |
Index: trunk/extensions/ConfirmAccount/business/AccountRequestSubmission.php |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | # Start a transaction, move file from temp to account request directory. |
166 | 166 | $repo = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
167 | 167 | $key = sha1_file( $this->attachmentTempPath ) . '.' . $finalExt; |
168 | | - $pathRel = $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
| 168 | + $pathRel = UserAccountRequest::relPathFromKey( $key ); |
169 | 169 | $triplet = array( $this->attachmentTempPath, 'public', $pathRel ); |
170 | 170 | $status = $repo->storeBatch( array( $triplet ), FSRepo::OVERWRITE_SAME ); // save! |
171 | 171 | if ( !$status->isOk() ) { |
Index: trunk/extensions/ConfirmAccount/business/AccountConfirmSubmission.php |
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | $repoOld = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
192 | 192 | $repoNew = new FSRepo( $wgConfirmAccountFSRepos['accountcreds'] ); |
193 | 193 | |
194 | | - $pathRel = $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
| 194 | + $pathRel = UserAccountRequest::relPathFromKey( $key ); |
195 | 195 | $oldPath = $repoOld->getZonePath( 'public' ) . '/' . $pathRel; |
196 | 196 | |
197 | 197 | $triplet = array( $oldPath, 'public', $pathRel ); |
— | — | @@ -299,7 +299,7 @@ |
300 | 300 | $key = $accReq->getFileStorageKey(); |
301 | 301 | if ( $key ) { |
302 | 302 | $repoOld = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
303 | | - $pathRel = $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
| 303 | + $pathRel = UserAccountRequest::relPathFromKey( $key ); |
304 | 304 | $oldPath = $repoOld->getZonePath( 'public' ) . '/' . $pathRel; |
305 | 305 | if ( file_exists( $oldPath ) ) { |
306 | 306 | unlink( $oldPath ); // delete! |