Fixes #16183: Fixed when yii\helpers\BaseFileHelper sometimes returned wrong value

This commit is contained in:
Ondřej Vašíček
2018-10-27 01:07:17 +02:00
committed by Alexander Makarov
parent f8f53a2d07
commit ba0a3c00ca
2 changed files with 8 additions and 3 deletions

View File

@ -415,9 +415,13 @@ class BaseFileHelper
return unlink($path);
} catch (ErrorException $e) {
// last resort measure for Windows
$lines = [];
exec('DEL /F/Q ' . escapeshellarg($path), $lines, $deleteError);
return $deleteError !== 0;
if (function_exists('exec') && file_exists($path)) {
exec('DEL /F/Q ' . escapeshellarg($path));
return !file_exists($path);
}
return false;
}
}