Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major 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

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Benjamin Eberlei
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: