Skip to content

Commit af2938e

Browse files
Merge branch '2.8' into 3.4
* 2.8: Added the Code of Conduct file [Process] fix locking of pipe files on Windows fix multi-digit seconds fraction handling
2 parents cb7dedf + c57e4e1 commit af2938e

File tree

4 files changed

+111
-32
lines changed

4 files changed

+111
-32
lines changed

CODE_OF_CONDUCT.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Code of Conduct
2+
===============
3+
4+
Our Pledge
5+
----------
6+
7+
In the interest of fostering an open and welcoming environment, we as
8+
contributors and maintainers pledge to making participation in our project and
9+
our community a harassment-free experience for everyone, regardless of age, body
10+
size, disability, ethnic origin, gender identity and expression, level of
11+
experience, education, socio-economic status, nationality, personal appearance,
12+
religion, or sexual identity and orientation.
13+
14+
Our Standards
15+
-------------
16+
17+
Examples of behavior that contributes to creating a positive environment
18+
include:
19+
20+
* Using welcoming and inclusive language
21+
* Being respectful of differing viewpoints and experiences
22+
* Gracefully accepting constructive criticism
23+
* Focusing on what is best for the community
24+
* Showing empathy towards other community members
25+
26+
Examples of unacceptable behavior by participants include:
27+
28+
* The use of sexualized language or imagery and unwelcome sexual attention or
29+
advances
30+
* Trolling, insulting/derogatory comments, and personal or political attacks
31+
* Public or private harassment
32+
* Publishing others' private information, such as a physical or electronic
33+
address, without explicit permission
34+
* Other conduct which could reasonably be considered inappropriate in a
35+
professional setting
36+
37+
Our Responsibilities
38+
--------------------
39+
40+
[CoC Active Response Ensurers, or CARE][1], are responsible for clarifying the
41+
standards of acceptable behavior and are expected to take appropriate and fair
42+
corrective action in response to any instances of unacceptable behavior.
43+
44+
CARE team members have the right and responsibility to remove, edit, or reject
45+
comments, commits, code, wiki edits, issues, and other contributions that are
46+
not aligned to this Code of Conduct, or to ban temporarily or permanently any
47+
contributor for other behaviors that they deem inappropriate, threatening,
48+
offensive, or harmful.
49+
50+
Scope
51+
-----
52+
53+
This Code of Conduct applies both within project spaces and in public spaces
54+
when an individual is representing the project or its community. Examples of
55+
representing a project or community include using an official project e-mail
56+
address, posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event. Representation of a project may be
58+
further defined and clarified by CARE team members.
59+
60+
Enforcement
61+
-----------
62+
63+
Instances of abusive, harassing, or otherwise unacceptable behavior
64+
[may be reported][2] by contacting the [CARE team members][1].
65+
All complaints will be reviewed and investigated and will result in a response
66+
that is deemed necessary and appropriate to the circumstances. The CARE team is
67+
obligated to maintain confidentiality with regard to the reporter of an
68+
incident. Further details of specific enforcement policies may be posted
69+
separately.
70+
71+
CARE team members who do not follow or enforce the Code of Conduct in good
72+
faith may face temporary or permanent repercussions as determined by the
73+
[core team][3].
74+
75+
Attribution
76+
-----------
77+
78+
This Code of Conduct is adapted from the [Contributor Covenant version 1.4][4].
79+
80+
[1]: https://symfony.com/doc/current/contributing/code_of_conduct/care_team.html
81+
[2]: https://symfony.com/doc/current/contributing/code_of_conduct/reporting_guidelines.html
82+
[3]: https://symfony.com/doc/current/contributing/code/core_team.html
83+
[4]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function reverseTransform($rfc3339)
6868
return;
6969
}
7070

71-
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) {
71+
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) {
7272
throw new TransformationFailedException(sprintf('The date "%s" is not a valid date.', $rfc3339));
7373
}
7474

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function reverseTransformProvider()
6767
array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'),
6868
array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'),
6969
array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T08:30:00Z'),
70+
array('UTC', 'UTC', '2018-10-03T10:00:00.000Z', '2018-10-03T10:00:00.000Z'),
7071
));
7172
}
7273

src/Symfony/Component/Process/Pipes/WindowsPipes.php

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class WindowsPipes extends AbstractPipes
2828
{
2929
private $files = array();
3030
private $fileHandles = array();
31+
private $lockHandles = array();
3132
private $readBytes = array(
3233
Process::STDOUT => 0,
3334
Process::STDERR => 0,
@@ -47,31 +48,33 @@ public function __construct($input, $haveReadSupport)
4748
Process::STDOUT => Process::OUT,
4849
Process::STDERR => Process::ERR,
4950
);
50-
$tmpCheck = false;
5151
$tmpDir = sys_get_temp_dir();
5252
$lastError = 'unknown reason';
5353
set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
5454
for ($i = 0;; ++$i) {
5555
foreach ($pipes as $pipe => $name) {
5656
$file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
57-
if (file_exists($file) && !unlink($file)) {
58-
continue 2;
59-
}
60-
$h = fopen($file, 'xb');
61-
if (!$h) {
62-
$error = $lastError;
63-
if ($tmpCheck || $tmpCheck = unlink(tempnam(false, 'sf_check_'))) {
64-
continue;
65-
}
57+
58+
if (!$h = fopen($file.'.lock', 'w')) {
6659
restore_error_handler();
67-
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $error));
60+
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
6861
}
69-
if (!$h || !$this->fileHandles[$pipe] = fopen($file, 'rb')) {
62+
if (!flock($h, LOCK_EX | LOCK_NB)) {
7063
continue 2;
7164
}
72-
if (isset($this->files[$pipe])) {
73-
unlink($this->files[$pipe]);
65+
if (isset($this->lockHandles[$pipe])) {
66+
flock($this->lockHandles[$pipe], LOCK_UN);
67+
fclose($this->lockHandles[$pipe]);
7468
}
69+
$this->lockHandles[$pipe] = $h;
70+
71+
if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
72+
flock($this->lockHandles[$pipe], LOCK_UN);
73+
fclose($this->lockHandles[$pipe]);
74+
unset($this->lockHandles[$pipe]);
75+
continue 2;
76+
}
77+
$this->fileHandles[$pipe] = $h;
7578
$this->files[$pipe] = $file;
7679
}
7780
break;
@@ -85,7 +88,6 @@ public function __construct($input, $haveReadSupport)
8588
public function __destruct()
8689
{
8790
$this->close();
88-
$this->removeFiles();
8991
}
9092

9193
/**
@@ -145,8 +147,11 @@ public function readAndWrite($blocking, $close = false)
145147
$read[$type] = $data;
146148
}
147149
if ($close) {
150+
ftruncate($fileHandle, 0);
148151
fclose($fileHandle);
149-
unset($this->fileHandles[$type]);
152+
flock($this->lockHandles[$type], LOCK_UN);
153+
fclose($this->lockHandles[$type]);
154+
unset($this->fileHandles[$type], $this->lockHandles[$type]);
150155
}
151156
}
152157

@@ -175,22 +180,12 @@ public function areOpen()
175180
public function close()
176181
{
177182
parent::close();
178-
foreach ($this->fileHandles as $handle) {
183+
foreach ($this->fileHandles as $type => $handle) {
184+
ftruncate($handle, 0);
179185
fclose($handle);
186+
flock($this->lockHandles[$type], LOCK_UN);
187+
fclose($this->lockHandles[$type]);
180188
}
181-
$this->fileHandles = array();
182-
}
183-
184-
/**
185-
* Removes temporary files.
186-
*/
187-
private function removeFiles()
188-
{
189-
foreach ($this->files as $filename) {
190-
if (file_exists($filename)) {
191-
@unlink($filename);
192-
}
193-
}
194-
$this->files = array();
189+
$this->fileHandles = $this->lockHandles = array();
195190
}
196191
}

0 commit comments

Comments
 (0)