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/filebackend/TempFSFile.php | 121 ++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 includes/filebackend/TempFSFile.php (limited to 'includes/filebackend/TempFSFile.php') diff --git a/includes/filebackend/TempFSFile.php b/includes/filebackend/TempFSFile.php new file mode 100644 index 00000000..5032bf68 --- /dev/null +++ b/includes/filebackend/TempFSFile.php @@ -0,0 +1,121 @@ += 5 ) { + wfProfileOut( __METHOD__ ); + return null; // give up + } + } + $tmpFile = new self( $path ); + $tmpFile->canDelete = true; // safely instantiated + wfProfileOut( __METHOD__ ); + return $tmpFile; + } + + /** + * Purge this file off the file system + * + * @return bool Success + */ + public function purge() { + $this->canDelete = false; // done + wfSuppressWarnings(); + $ok = unlink( $this->path ); + wfRestoreWarnings(); + return $ok; + } + + /** + * Clean up the temporary file only after an object goes out of scope + * + * @param $object Object + * @return void + */ + public function bind( $object ) { + if ( is_object( $object ) ) { + $object->tempFSFileReferences[] = $this; + } + } + + /** + * Set flag to not clean up after the temporary file + * + * @return void + */ + public function preserve() { + $this->canDelete = false; + } + + /** + * Set flag clean up after the temporary file + * + * @return void + */ + public function autocollect() { + $this->canDelete = true; + } + + /** + * Cleans up after the temporary file by deleting it + */ + function __destruct() { + if ( $this->canDelete ) { + wfSuppressWarnings(); + unlink( $this->path ); + wfRestoreWarnings(); + } + } +} -- cgit v1.2.3-54-g00ecf