mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-09 01:27:20 +08:00
Fixed yii\console\controllers\AssetController does not create missing folders for the target bundles
This commit is contained in:
@ -6,6 +6,7 @@ Yii Framework 2 Change Log
|
||||
|
||||
- Bug #6642: Fixed the bug that using confirmation dialog via `data-confirm` in an `ActiveForm` may cause the dialog to appear twice (pana1990, qiangxue)
|
||||
- Bug #6871: Fixed the bug that using defaults and hostnames in URL rules may cause an out-of-range index issue (qiangxue)
|
||||
- Bug #7473: Fixed `yii\console\controllers\AssetController` does not create missing folders for the target bundles (schmunk42, klimov-paul)
|
||||
- Bug #7529: Fixed `yii\web\Response::sendContentAsFile()` that was broken in 2.0.3 (samdark)
|
||||
- Bug #7603: Fixed escape characters in `FormatConverter` to work with unicode characters (maddoger, cebe)
|
||||
- Bug #7757: Fix fetching tables schema for oci and mysql when PDO::ATTR_CASE is set (nineinchnick)
|
||||
|
||||
@ -11,6 +11,7 @@ use Yii;
|
||||
use yii\console\Exception;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\Console;
|
||||
use yii\helpers\FileHelper;
|
||||
use yii\helpers\VarDumper;
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
@ -325,9 +326,7 @@ class AssetController extends Controller
|
||||
*/
|
||||
protected function buildTarget($target, $type, $bundles)
|
||||
{
|
||||
$tempFile = $target->basePath . '/' . strtr($target->$type, ['{hash}' => 'temp']);
|
||||
$inputFiles = [];
|
||||
|
||||
foreach ($target->depends as $name) {
|
||||
if (isset($bundles[$name])) {
|
||||
if (!$this->isBundleExternal($bundles[$name])) {
|
||||
@ -339,16 +338,26 @@ class AssetController extends Controller
|
||||
throw new Exception("Unknown bundle: '{$name}'");
|
||||
}
|
||||
}
|
||||
if ($type === 'js') {
|
||||
$this->compressJsFiles($inputFiles, $tempFile);
|
||||
} else {
|
||||
$this->compressCssFiles($inputFiles, $tempFile);
|
||||
}
|
||||
|
||||
$targetFile = strtr($target->$type, ['{hash}' => md5_file($tempFile)]);
|
||||
$outputFile = $target->basePath . '/' . $targetFile;
|
||||
rename($tempFile, $outputFile);
|
||||
$target->$type = [$targetFile];
|
||||
if (empty($inputFiles)) {
|
||||
$target->$type = [];
|
||||
} else {
|
||||
if (!file_exists($target->basePath)) {
|
||||
FileHelper::createDirectory($target->basePath, $this->getAssetManager()->dirMode);
|
||||
}
|
||||
$tempFile = $target->basePath . '/' . strtr($target->$type, ['{hash}' => 'temp']);
|
||||
|
||||
if ($type === 'js') {
|
||||
$this->compressJsFiles($inputFiles, $tempFile);
|
||||
} else {
|
||||
$this->compressCssFiles($inputFiles, $tempFile);
|
||||
}
|
||||
|
||||
$targetFile = strtr($target->$type, ['{hash}' => md5_file($tempFile)]);
|
||||
$outputFile = $target->basePath . '/' . $targetFile;
|
||||
rename($tempFile, $outputFile);
|
||||
$target->$type = [$targetFile];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user