Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15284888
D10329.id24869.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10329.id24869.diff
View Options
diff --git a/src/filesystem/TempFile.php b/src/filesystem/TempFile.php
--- a/src/filesystem/TempFile.php
+++ b/src/filesystem/TempFile.php
@@ -19,6 +19,7 @@
private $dir;
private $file;
private $preserve;
+ private $destroyed = false;
/* -( Creating a Temporary File )------------------------------------------ */
@@ -39,6 +40,10 @@
$this->file = $this->dir.'/'.$filename;
}
+ // If we fatal (e.g., call a method on NULL), destructors are not called.
+ // Make sure our destructor is invoked.
+ register_shutdown_function(array($this, '__destruct'));
+
Filesystem::writeFile($this, '');
}
@@ -82,9 +87,14 @@
* @task internal
*/
public function __destruct() {
+ if ($this->destroyed) {
+ return;
+ }
+
if ($this->preserve) {
return;
}
+
Filesystem::remove($this->dir);
// NOTE: tempnam() doesn't guarantee it will return a file inside the
@@ -92,6 +102,10 @@
// explicitly.
Filesystem::remove($this->file);
+
+ $this->file = null;
+ $this->dir = null;
+ $this->destroyed = true;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 10:52 AM (3 d, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7225204
Default Alt Text
D10329.id24869.diff (1 KB)
Attached To
Mode
D10329: Make sure TempFiles are destroyed after a PHP fatal error
Attached
Detach File
Event Timeline
Log In to Comment