Browse Source

Fixes #15270: Resolved potential race conditions when writing generated php-files

tags/2.0.14
Vladimir Reznichenko 7 years ago committed by Alexander Makarov
parent
commit
185209957e
  1. 1
      framework/CHANGELOG.md
  2. 2
      framework/UPGRADE.md
  3. 4
      framework/console/controllers/AssetController.php
  4. 2
      framework/console/controllers/BaseMigrateController.php
  5. 4
      framework/console/controllers/MessageController.php
  6. 3
      framework/db/oci/Schema.php
  7. 3
      framework/requirements/YiiRequirementChecker.php
  8. 3
      framework/web/MultipartFormDataParser.php

1
framework/CHANGELOG.md

@ -20,6 +20,7 @@ Yii Framework 2 Change Log
- Enh #15221: Added support for specifying `--camelCase` console options in `--kebab-case` (brandonkelly)
- Enh #15221: Added support for the `--<option> <value>` console option syntax (brandonkelly)
- Enh #15221: Improved the `help/list-action-options` console command output for command options without a description (brandonkelly)
- Bug #15270: Resolved potential race conditions when writing generated php-files (kalessil)
2.0.13.1 November 14, 2017
--------------------------

2
framework/UPGRADE.md

@ -492,7 +492,7 @@ new ones save the following code as `convert.php` that should be placed in the s
$out = var_export($data, true);
$out = "<?php\nreturn " . $out . ';';
$out = str_replace(['array (', ')'], ['[', ']'], $out);
file_put_contents($fileName, $out);
file_put_contents($fileName, $out, LOCK_EX);
}
$items = [];

4
framework/console/controllers/AssetController.php

@ -494,7 +494,7 @@ class AssetController extends Controller
*/
return {$array};
EOD;
if (!file_put_contents($bundleFile, $bundleFileContent)) {
if (!file_put_contents($bundleFile, $bundleFileContent, LOCK_EX)) {
throw new Exception("Unable to write output bundle configuration at '{$bundleFile}'.");
}
$this->stdout("Output bundle configuration created at '{$bundleFile}'.\n", Console::FG_GREEN);
@ -738,7 +738,7 @@ EOD;
return ExitCode::OK;
}
}
if (!file_put_contents($configFile, $template)) {
if (!file_put_contents($configFile, $template, LOCK_EX)) {
throw new Exception("Unable to write template file '{$configFile}'.");
}

2
framework/console/controllers/BaseMigrateController.php

@ -643,7 +643,7 @@ abstract class BaseMigrateController extends Controller
'namespace' => $namespace,
]);
FileHelper::createDirectory($migrationPath);
file_put_contents($file, $content);
file_put_contents($file, $content, LOCK_EX);
$this->stdout("New migration created successfully.\n", Console::FG_GREEN);
}
}

4
framework/console/controllers/MessageController.php

@ -241,7 +241,7 @@ return $array;
EOD;
if (file_put_contents($filePath, $content) === false) {
if (file_put_contents($filePath, $content, LOCK_EX) === false) {
$this->stdout("Configuration file was NOT created: '{$filePath}'.\n\n", Console::FG_RED);
return ExitCode::UNSPECIFIED_ERROR;
}
@ -733,7 +733,7 @@ return $array;
EOD;
if (file_put_contents($fileName, $content) === false) {
if (file_put_contents($fileName, $content, LOCK_EX) === false) {
$this->stdout("Translation was NOT saved.\n\n", Console::FG_RED);
return ExitCode::UNSPECIFIED_ERROR;
}

3
framework/db/oci/Schema.php

@ -482,8 +482,7 @@ SQL;
}
foreach ($constraints as $constraint) {
$name = array_keys($constraint);
$name = current($name);
$name = current(array_keys($constraint));
$table->foreignKeys[$name] = array_merge([$constraint['tableName']], $constraint['columns']);
}

3
framework/requirements/YiiRequirementChecker.php

@ -247,8 +247,7 @@ class YiiRequirementChecker
return (int) $verboseSize;
}
$sizeUnit = trim($verboseSize, '0123456789');
$size = str_replace($sizeUnit, '', $verboseSize);
$size = trim($size);
$size = trim(str_replace($sizeUnit, '', $verboseSize));
if (!is_numeric($size)) {
return 0;
}

3
framework/web/MultipartFormDataParser.php

@ -349,8 +349,7 @@ class MultipartFormDataParser extends BaseObject implements RequestParserInterfa
return (int) $verboseSize;
}
$sizeUnit = trim($verboseSize, '0123456789');
$size = str_replace($sizeUnit, '', $verboseSize);
$size = trim($size);
$size = trim(str_replace($sizeUnit, '', $verboseSize));
if (!is_numeric($size)) {
return 0;
}

Loading…
Cancel
Save