oracle: missing table prefix
[mediawiki.git] / includes / upload / UploadFromStash.php
blob37789bd5ab9a0c59d33d1fe3d1114b94490b2c28
1 <?php
2 /**
3 * @file
4 * @ingroup upload
6 * Implements uploading from previously stored file.
8 * @author Bryan Tong Minh
9 */
11 class UploadFromStash extends UploadBase {
12 public static function isValidSessionKey( $key, $sessionData ) {
13 return !empty( $key ) &&
14 is_array( $sessionData ) &&
15 isset( $sessionData[$key] ) &&
16 isset( $sessionData[$key]['version'] ) &&
17 $sessionData[$key]['version'] == self::SESSION_VERSION;
20 public static function isValidRequest( $request ) {
21 $sessionData = $request->getSessionData( 'wsUploadData' );
22 return self::isValidSessionKey(
23 $request->getInt( 'wpSessionKey' ),
24 $sessionData
28 * some $na vars for uploadBase method compatibility.
30 public function initialize( $name, $sessionData, $na=false, $na2=false ) {
31 /**
32 * Confirming a temporarily stashed upload.
33 * We don't want path names to be forged, so we keep
34 * them in the session on the server and just give
35 * an opaque key to the user agent.
38 $this->initializePathInfo( $name,
39 $this->getRealPath ( $sessionData['mTempPath'] ),
40 $sessionData['mFileSize'],
41 false
44 $this->mVirtualTempPath = $sessionData['mTempPath'];
45 $this->mFileProps = $sessionData['mFileProps'];
48 public function initializeFromRequest( &$request ) {
49 $this->mSessionKey = $request->getInt( 'wpSessionKey' );
50 $sessionData = $request->getSessionData('wsUploadData');
52 $desiredDestName = $request->getText( 'wpDestFile' );
53 if( !$desiredDestName )
54 $desiredDestName = $request->getText( 'wpUploadFile' );
55 return $this->initialize( $desiredDestName, $sessionData[$this->mSessionKey], false );
58 /**
59 * File has been previously verified so no need to do so again.
61 protected function verifyFile() {
62 return true;
66 /**
67 * There is no need to stash the image twice
69 public function stashSession() {
70 if ( !empty( $this->mSessionKey ) )
71 return $this->mSessionKey;
72 return parent::stashSession();
75 /**
76 * Remove a temporarily kept file stashed by saveTempUploadedFile().
77 * @return success
79 public function unsaveUploadedFile() {
80 $repo = RepoGroup::singleton()->getLocalRepo();
81 $success = $repo->freeTemp( $this->mVirtualTempPath );
82 return $success;