From ddbb184d467de550bda935370f48ea6a6523e957 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Mon, 13 Nov 2017 21:26:24 +0100 Subject: [PATCH 1/4] Php Inspecions (EA Extended): rpotential race conditions cases fixed --- src/Symfony/Component/Cache/Traits/PhpArrayTrait.php | 2 +- src/Symfony/Component/ClassLoader/ClassMapGenerator.php | 2 +- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- .../Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php index ae634d6baa295..07fd81085e3c0 100644 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php @@ -102,7 +102,7 @@ public function warmUp(array $values) $tmpFile = uniqid($this->file, true); - file_put_contents($tmpFile, $dump); + file_put_contents($tmpFile, $dump, LOCK_EX); @chmod($tmpFile, 0666 & ~umask()); unset($serialized, $unserialized, $value, $dump); diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index dba7b2b468d17..9266e7b0fe3f3 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -37,7 +37,7 @@ public static function dump($dirs, $file) $maps = array_merge($maps, static::createMap($dir)); } - file_put_contents($file, sprintf('warmupDir ?: $this->getCacheDir()).'/classes.map', sprintf('warmupDir ?: $this->getCacheDir()).'/classes.map', sprintf('warmupDir ?: $this->getCacheDir()).'/annotations.map', sprintf('warmupDir ?: $this->getCacheDir()).'/annotations.map', sprintf(' Date: Mon, 13 Nov 2017 21:29:42 +0100 Subject: [PATCH 2/4] Php Inspecions (EA Extended): greedy regexes fixed --- src/Symfony/Component/Workflow/Definition.php | 2 +- src/Symfony/Component/Workflow/DefinitionBuilder.php | 2 +- src/Symfony/Component/Workflow/Transition.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Workflow/Definition.php b/src/Symfony/Component/Workflow/Definition.php index 5f8571b329a09..e366407638594 100644 --- a/src/Symfony/Component/Workflow/Definition.php +++ b/src/Symfony/Component/Workflow/Definition.php @@ -82,7 +82,7 @@ private function setInitialPlace($place) private function addPlace($place) { - if (!preg_match('{^[\w\d_-]+$}', $place)) { + if (!preg_match('{^[\w_-]+$}', $place)) { throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place)); } diff --git a/src/Symfony/Component/Workflow/DefinitionBuilder.php b/src/Symfony/Component/Workflow/DefinitionBuilder.php index f663c16d1a255..16d66286efb4c 100644 --- a/src/Symfony/Component/Workflow/DefinitionBuilder.php +++ b/src/Symfony/Component/Workflow/DefinitionBuilder.php @@ -77,7 +77,7 @@ public function setInitialPlace($place) */ public function addPlace($place) { - if (!preg_match('{^[\w\d_-]+$}', $place)) { + if (!preg_match('{^[\w_-]+$}', $place)) { throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place)); } diff --git a/src/Symfony/Component/Workflow/Transition.php b/src/Symfony/Component/Workflow/Transition.php index fb4786c88a267..f673517f32e6c 100644 --- a/src/Symfony/Component/Workflow/Transition.php +++ b/src/Symfony/Component/Workflow/Transition.php @@ -30,7 +30,7 @@ class Transition */ public function __construct($name, $froms, $tos) { - if (!preg_match('{^[\w\d_-]+$}', $name)) { + if (!preg_match('{^[\w_-]+$}', $name)) { throw new InvalidArgumentException(sprintf('The transition "%s" contains invalid characters.', $name)); } From 8663828436e1921ab4455ddcb00c9b1d94a71209 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Mon, 13 Nov 2017 21:42:58 +0100 Subject: [PATCH 3/4] Php Inspecions (EA Extended): revert LOCK_EX for randomly named file. --- src/Symfony/Component/Cache/Traits/PhpArrayTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php index 07fd81085e3c0..ae634d6baa295 100644 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php @@ -102,7 +102,7 @@ public function warmUp(array $values) $tmpFile = uniqid($this->file, true); - file_put_contents($tmpFile, $dump, LOCK_EX); + file_put_contents($tmpFile, $dump); @chmod($tmpFile, 0666 & ~umask()); unset($serialized, $unserialized, $value, $dump); From 161f2d474c696d4ca85128370440769152fa44ab Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Fri, 17 Nov 2017 21:52:07 +0100 Subject: [PATCH 4/4] Php Inspecions (EA Extended): revert LOCK_EX for deprecated and dev-code. --- src/Symfony/Component/ClassLoader/ClassMapGenerator.php | 2 +- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- .../Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 9266e7b0fe3f3..dba7b2b468d17 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -37,7 +37,7 @@ public static function dump($dirs, $file) $maps = array_merge($maps, static::createMap($dir)); } - file_put_contents($file, sprintf('warmupDir ?: $this->getCacheDir()).'/classes.map', sprintf('warmupDir ?: $this->getCacheDir()).'/classes.map', sprintf('