Bug #25776

Doctrine proxy class files can't be overwritten by other SAPI type

Added by Robert Lemke over 4 years ago. Updated over 4 years ago.

Status:Resolved Start date:2011-04-05
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:Persistence
Target version:TYPO3 Flow Base Distribution - 1.0 beta 1
PHP Version: Complexity:
Has patch: Affected Flow version:

Description

When you run FLOW3 with empty caches for example from the command line, Doctrine proxy classes will be created. However, these files can't be overwritten or trashed by FLOW3 when it's running in web mode because the files are created with read-only permissions for the group. The same happens vice versa (first hit with Web).

The solution would be to create Doctrine proxy files with -rw-rw-r-- permissions.

Associated revisions

Revision 30151e02
Added by Karsten Dambekalns over 4 years ago

[TASK] 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.

Fixes: #25776
Change-Id: Icec4e1a7ecebf96cf07a9be09f3c9510b0679f63

History

#1 Updated by Karsten Dambekalns over 4 years ago

  • Status changed from New to Accepted

#2 Updated by Karsten Dambekalns over 4 years ago

For reference, this is what we use, the trick is the umask in combination with our recommended permissions (sticky group bit):

if (!is_dir($path) && strlen($path) > 0) {
            $oldMask = umask(000);
            mkdir($path, 0777, TRUE);
            umask($oldMask);
            if (!is_dir($path)) throw new \F3\FLOW3\Utility\Exception('Could not create directory "' . $path . '"!', 1170251400);
        }

#3 Updated by Karsten Dambekalns over 4 years ago

No, it's a more general problem. All files, also the cache files FLOW3 creates, are not writeable by the group, thus the problem exists for those as well.

#4 Updated by Mr. Hudson over 4 years ago

Patch set 1 of change Icec4e1a7ecebf96cf07a9be09f3c9510b0679f63 has been pushed to the review server.
It is available at http://review.typo3.org/1580

#5 Updated by Karsten Dambekalns over 4 years ago

  • Status changed from Accepted to Under Review

#6 Updated by Karsten Dambekalns over 4 years ago

Karsten Dambekalns wrote:

All files, also the cache files FLOW3 creates, are not writeable by the group, thus the problem exists for those as well.

Turns out that this is true, but still the cache files can be replaced, because we use rename to move a temporary file in place of the old file. The DOctrine ProxyFactory does not do this.

#7 Updated by Karsten Dambekalns over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF