'ISO-8859-1',
'ISO-8859-2',
'UTF-16',
- 'UTF-32'
+ 'UTF-32',
+ 'WINDOWS-1250',
+ 'WINDOWS-1251',
+ 'WINDOWS-1252',
+ 'WINDOWS-1253',
+ 'WINDOWS-1254',
+ 'WINDOWS-1255',
+ 'WINDOWS-1256',
+ 'WINDOWS-1257',
+ 'WINDOWS-1258',
];
const SUCCESS = 0;
return $this->mLocalFile;
}
+ /**
+ * Like stashFile(), but respects extensions' wishes to prevent the stashing.
+ *
+ * Upload stash exceptions are also caught and converted to an error status.
+ *
+ * @since 1.28
+ * @param User $user
+ * @return Status If successful, value is an UploadStashFile instance
+ */
+ public function tryStashFile( User $user ) {
+ $props = $this->mFileProps;
+ $error = null;
+ Hooks::run( 'UploadStashFile', [ $this, $user, $props, &$error ] );
+ if ( $error ) {
+ if ( !is_array( $error ) ) {
+ $error = [ $error ];
+ }
+ return call_user_func_array( 'Status::newFatal', $error );
+ }
+ try {
+ $file = $this->doStashFile( $user );
+ return Status::newGood( $file );
+ } catch ( UploadStashException $e ) {
+ return Status::newFatal( 'uploadstash-exception', get_class( $e ), $e->getMessage() );
+ }
+ }
+
/**
* If the user does not supply all necessary information in the first upload
* form submission (either by accident or by design) then we may want to
* which can be passed through a form or API request to find this stashed
* file again.
*
+ * @deprecated since 1.28 Use tryStashFile() instead
* @param User $user
* @return UploadStashFile Stashed file
+ * @throws UploadStashBadPathException
+ * @throws UploadStashFileException
+ * @throws UploadStashNotLoggedInException
*/
public function stashFile( User $user = null ) {
- // was stashSessionFile
+ return $this->doStashFile( $user );
+ }
+ /**
+ * Implementation for stashFile() and tryStashFile().
+ *
+ * @param User $user
+ * @return UploadStashFile Stashed file
+ */
+ protected function doStashFile( User $user = null ) {
$stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $user );
$file = $stash->stashFile( $this->mTempPath, $this->getSourceType() );
$this->mLocalFile = $file;
* Stash a file in a temporary directory, returning a key which can be used
* to find the file again. See stashFile().
*
+ * @deprecated since 1.28
* @return string File key
*/
public function stashFileGetKey() {
- return $this->stashFile()->getFileKey();
+ wfDeprecated( __METHOD__, '1.28' );
+ return $this->doStashFile()->getFileKey();
}
/**
* alias for stashFileGetKey, for backwards compatibility
*
+ * @deprecated since 1.28
* @return string File key
*/
public function stashSession() {
- return $this->stashFileGetKey();
+ wfDeprecated( __METHOD__, '1.28' );
+ return $this->doStashFile()->getFileKey();
}
/**