From 7b920c1ec52a9777fcde927acd1def17b07a5a64 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Oct 2018 13:47:42 +0200 Subject: [PATCH 1/3] fix multi-digit seconds fraction handling --- .../Core/DataTransformer/DateTimeToRfc3339Transformer.php | 2 +- .../Core/DataTransformer/DateTimeToRfc3339TransformerTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php index 8d1a92af8b..59e3a765d5 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php @@ -69,7 +69,7 @@ class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer return; } - if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) { + if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) { throw new TransformationFailedException(sprintf('The date "%s" is not a valid date.', $rfc3339)); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php index 5f4043523e..dc1633b844 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php @@ -67,6 +67,7 @@ class DateTimeToRfc3339TransformerTest extends TestCase array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'), array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'), array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T08:30:00Z'), + array('UTC', 'UTC', '2018-10-03T10:00:00.000Z', '2018-10-03T10:00:00.000Z'), )); } From d64bd3b181f83752fae66c1da96a4eead8017872 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 2 Oct 2018 18:52:16 +0200 Subject: [PATCH 2/3] [Process] fix locking of pipe files on Windows --- .../Component/Process/Pipes/WindowsPipes.php | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index f81f65faca..0b2a76387f 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -28,6 +28,7 @@ class WindowsPipes extends AbstractPipes { private $files = array(); private $fileHandles = array(); + private $lockHandles = array(); private $readBytes = array( Process::STDOUT => 0, Process::STDERR => 0, @@ -47,31 +48,33 @@ class WindowsPipes extends AbstractPipes Process::STDOUT => Process::OUT, Process::STDERR => Process::ERR, ); - $tmpCheck = false; $tmpDir = sys_get_temp_dir(); $lastError = 'unknown reason'; set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; }); for ($i = 0;; ++$i) { foreach ($pipes as $pipe => $name) { $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name); - if (file_exists($file) && !unlink($file)) { - continue 2; - } - $h = fopen($file, 'xb'); - if (!$h) { - $error = $lastError; - if ($tmpCheck || $tmpCheck = unlink(tempnam(false, 'sf_check_'))) { - continue; - } + + if (!$h = fopen($file.'.lock', 'w')) { restore_error_handler(); - throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $error)); + throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError)); } - if (!$h || !$this->fileHandles[$pipe] = fopen($file, 'rb')) { + if (!flock($h, LOCK_EX | LOCK_NB)) { continue 2; } - if (isset($this->files[$pipe])) { - unlink($this->files[$pipe]); + if (isset($this->lockHandles[$pipe])) { + flock($this->lockHandles[$pipe], LOCK_UN); + fclose($this->lockHandles[$pipe]); } + $this->lockHandles[$pipe] = $h; + + if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) { + flock($this->lockHandles[$pipe], LOCK_UN); + fclose($this->lockHandles[$pipe]); + unset($this->lockHandles[$pipe]); + continue 2; + } + $this->fileHandles[$pipe] = $h; $this->files[$pipe] = $file; } break; @@ -85,7 +88,6 @@ class WindowsPipes extends AbstractPipes public function __destruct() { $this->close(); - $this->removeFiles(); } /** @@ -145,8 +147,11 @@ class WindowsPipes extends AbstractPipes $read[$type] = $data; } if ($close) { + ftruncate($fileHandle, 0); fclose($fileHandle); - unset($this->fileHandles[$type]); + flock($this->lockHandles[$type], LOCK_UN); + fclose($this->lockHandles[$type]); + unset($this->fileHandles[$type], $this->lockHandles[$type]); } } @@ -167,10 +172,13 @@ class WindowsPipes extends AbstractPipes public function close() { parent::close(); - foreach ($this->fileHandles as $handle) { + foreach ($this->fileHandles as $type => $handle) { + ftruncate($handle, 0); fclose($handle); + flock($this->lockHandles[$type], LOCK_UN); + fclose($this->lockHandles[$type]); } - $this->fileHandles = array(); + $this->fileHandles = $this->lockHandles = array(); } /** @@ -185,17 +193,4 @@ class WindowsPipes extends AbstractPipes { return new static($process->isOutputDisabled(), $input); } - - /** - * Removes temporary files. - */ - private function removeFiles() - { - foreach ($this->files as $filename) { - if (file_exists($filename)) { - @unlink($filename); - } - } - $this->files = array(); - } } From 06295442d1485d06f9013d16c9fdfccbcda2af47 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 21 Sep 2018 17:51:10 +0200 Subject: [PATCH 3/3] Added the Code of Conduct file --- CODE_OF_CONDUCT.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..d211dd419d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,83 @@ +Code of Conduct +=============== + +Our Pledge +---------- + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnic origin, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +religion, or sexual identity and orientation. + +Our Standards +------------- + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +Our Responsibilities +-------------------- + +[CoC Active Response Ensurers, or CARE][1], are responsible for clarifying the +standards of acceptable behavior and are expected to take appropriate and fair +corrective action in response to any instances of unacceptable behavior. + +CARE team members have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +Scope +----- + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by CARE team members. + +Enforcement +----------- + +Instances of abusive, harassing, or otherwise unacceptable behavior +[may be reported][2] by contacting the [CARE team members][1]. +All complaints will be reviewed and investigated and will result in a response +that is deemed necessary and appropriate to the circumstances. The CARE team is +obligated to maintain confidentiality with regard to the reporter of an +incident. Further details of specific enforcement policies may be posted +separately. + +CARE team members who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by the +[core team][3]. + +Attribution +----------- + +This Code of Conduct is adapted from the [Contributor Covenant version 1.4][4]. + +[1]: https://symfony.com/doc/current/contributing/code_of_conduct/care_team.html +[2]: https://symfony.com/doc/current/contributing/code_of_conduct/reporting_guidelines.html +[3]: https://symfony.com/doc/current/contributing/code/core_team.html +[4]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html