Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Security Level: All
-
Labels:None
Description
From 265e5086ea51ebcafc73f91abc64334d17e2f416 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns <karsten@typo3.org> Date: Wed, 25 May 2011 12:11:55 +0200 Subject: [PATCH 4/5] Use temporary file and rename for proxy class creation Instead of a simple file_put_contents() the proxy class code is written to a temporary file and renamed to the final filename. This allows file access even if only allowed by the directory permission. --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index f0cf19c..b2d42fb 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -152,7 +152,15 @@ class ProxyFactory $file = str_replace($placeholders, $replacements, $file); - file_put_contents($fileName, $file, LOCK_EX); + $temporaryFileName = $fileName . uniqid( ) . '.temp'; + $result = file_put_contents( $temporaryFileName, $file ); + + if($result === FALSE) throw new \RuntimeException('The temporary proxy class file "' . $temporaryFileName . '" could not be written.'); + $i = 0; + while(!rename( $temporaryFileName, $fileName ) && $i < 5) { + $i++; + } + if($result === FALSE) throw new \RuntimeException('The proxy class file "' . $fileName . '" could not be written.'); } /** -- 1.7.4.1
Activity
Benjamin Eberlei
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Workflow | jira [ 12802 ] | jira-feedback [ 13947 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback [ 13947 ] | jira-feedback2 [ 15811 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 15811 ] | jira-feedback3 [ 18067 ] |
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1259, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
Nette Framework uses a safe stream: https://github.com/nette/nette/blob/master/Nette/Utils/SafeStream.php