fabpot/Twig — Issue #620: Edge case template render bug.
Author: KendallHopkins
Created: 2012-02-02 00:10:59+00:00
State: open

After staging to our production servers (after which we clear the cache), I often get this type of error: `File exists in /path/../Twig/lib/Twig/Environment.php at 950.` The error only happens once and I'm assuming it's an edge case where `is_dir` returns `false` on two threads at once, and then one thread fails the `mkdir`.

if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, true); // this is line 950
}

Is there a way to avoid this type of error in the give framework? Would it be possible to only allow PHP thread to render a template at the same time to prevent duplicate rendering and preventing errors like this?