Browse Source

Fix #15779: If directory path is passed to `FileHelper::unlink()` and directory has files it will not delete files in this directory on Windows now

tags/2.0.25
Alexander Kartavenko 5 years ago committed by Alexander Makarov
parent
commit
efe8d48f15
  1. 1
      framework/CHANGELOG.md
  2. 5
      framework/helpers/BaseFileHelper.php

1
framework/CHANGELOG.md

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.25 under development
------------------------
- Bug #15779: If directory path is passed to `FileHelper::unlink()` and directory has files it will not delete files in this directory on Windows now (alexkart)
- Bug #17473: Fixed `SimpleConditionBuilder::build()` when column is not a string (alexkart)
- Bug #17486: Fixed error when using `batch()` without `$db` parameter with MSSQL (alexkart)

5
framework/helpers/BaseFileHelper.php

@ -424,6 +424,9 @@ class BaseFileHelper
return unlink($path);
} catch (ErrorException $e) {
// last resort measure for Windows
if (is_dir($path) && count(static::findFiles($path)) !== 0) {
return false;
}
if (function_exists('exec') && file_exists($path)) {
exec('DEL /F/Q ' . escapeshellarg($path));
@ -784,8 +787,8 @@ class BaseFileHelper
* Processes the pattern, stripping special characters like / and ! from the beginning and settings flags instead.
* @param string $pattern
* @param bool $caseSensitive
* @throws InvalidArgumentException
* @return array with keys: (string) pattern, (int) flags, (int|bool) firstWildcard
* @throws InvalidArgumentException
*/
private static function parseExcludePattern($pattern, $caseSensitive)
{

Loading…
Cancel
Save