Skip to content

Commit

Permalink
bug #11726 [Filesystem Component] mkdir race condition fix #11626 (kc…
Browse files Browse the repository at this point in the history
…assam)

This PR was squashed before being merged into the 2.3 branch (closes #11726).

Discussion
----------

[Filesystem Component] mkdir race condition fix #11626

[Filesystem Component] Fix mkdir race condition

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11626
| License       | MIT
| Doc PR        | none

Commits
-------

0483452 [Filesystem Component] mkdir race condition fix #11626
  • Loading branch information
fabpot committed Aug 27, 2014
2 parents 8990ac6 + 0483452 commit bb97903
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ public function mkdir($dirs, $mode = 0777)
}

if (true !== @mkdir($dir, $mode, true)) {
throw new IOException(sprintf('Failed to create %s', $dir));
$error = error_get_last();
if (!is_dir($dir)) {
// The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one
if ($error) {
throw new IOException(sprintf('Failed to create "%s": %s.', $dir, $error['message']));
}
throw new IOException(sprintf('Failed to create "%s"', $dir));
}
}
}
}
Expand Down

0 comments on commit bb97903

Please sign in to comment.