From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/upload/UploadStash.php | 48 +++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'includes/upload/UploadStash.php') diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index ad153d2f..c7fd23a9 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -1,4 +1,26 @@ text() ); + $errorMsg = array_shift( $error ); + throw new UploadStashFileException( "Error storing file in '$path': " . wfMessage( $errorMsg, $error )->text() ); } $stashPath = $storeStatus->value; + // we have renamed the file so we have to cleanup once done + unlink($path); + // fetch the current user ID if ( !$this->isLoggedIn ) { throw new UploadStashNotLoggedInException( __METHOD__ . ' No user is logged in, files must belong to users' ); @@ -391,6 +419,7 @@ class UploadStash { * with an extension. * XXX this is somewhat redundant with the checks that ApiUpload.php does with incoming * uploads versus the desired filename. Maybe we can get that passed to us... + * @return string */ public static function getExtensionForPath( $path ) { // Does this have an extension? @@ -419,6 +448,7 @@ class UploadStash { * Helper function: do the actual database query to fetch file metadata. * * @param $key String: key + * @param $readFromDB: constant (default: DB_SLAVE) * @return boolean */ protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) { @@ -451,7 +481,6 @@ class UploadStash { /** * Helper function: Initialize the UploadStashFile for a given file. * - * @param $path String: path to file * @param $key String: key under which to store the object * @throws UploadStashZeroLengthFileException * @return bool @@ -498,7 +527,7 @@ class UploadStashFile extends UnregisteredLocalFile { } // check if path exists! and is a plain file. - if ( ! $repo->fileExists( $path, FileRepo::FILES_ONLY ) ) { + if ( ! $repo->fileExists( $path ) ) { wfDebug( "UploadStash: tried to construct an UploadStashFile from a file that should already exist at '$path', but path is not found\n" ); throw new UploadStashFileNotFoundException( 'cannot find path, or not a plain file' ); } @@ -543,16 +572,17 @@ class UploadStashFile extends UnregisteredLocalFile { * ugly file name. * * @param $params Array: handler-specific parameters + * @param $flags integer Bitfield that supports THUMB_* constants * @return String: base name for URL, like '120px-12345.jpg', or null if there is no handler */ - function thumbName( $params ) { + function thumbName( $params, $flags = 0 ) { return $this->generateThumbName( $this->getUrlName(), $params ); } /** * Helper function -- given a 'subpage', return the local URL e.g. /wiki/Special:UploadStash/subpage - * @param {String} $subPage - * @return {String} local URL for this subpage in the Special:UploadStash space. + * @param $subPage String + * @return String: local URL for this subpage in the Special:UploadStash space. */ private function getSpecialUrl( $subPage ) { return SpecialPage::getTitleFor( 'UploadStash', $subPage )->getLocalURL(); @@ -622,7 +652,7 @@ class UploadStashFile extends UnregisteredLocalFile { * @return Status: success */ public function remove() { - if ( !$this->repo->fileExists( $this->path, FileRepo::FILES_ONLY ) ) { + if ( !$this->repo->fileExists( $this->path ) ) { // Maybe the file's already been removed? This could totally happen in UploadBase. return true; } @@ -631,7 +661,7 @@ class UploadStashFile extends UnregisteredLocalFile { } public function exists() { - return $this->repo->fileExists( $this->path, FileRepo::FILES_ONLY ); + return $this->repo->fileExists( $this->path ); } } -- cgit v1.2.2