diff --git a/extensions/faker/FixtureController.php b/extensions/faker/FixtureController.php index 2864813666..cff1b71953 100644 --- a/extensions/faker/FixtureController.php +++ b/extensions/faker/FixtureController.php @@ -233,8 +233,9 @@ class FixtureController extends \yii\console\controllers\FixtureController } $content = $this->exportFixtures($fixtures); - file_put_contents($fixturePath . '/' . $fixtureFileName, $content); - $this->stdout("Fixture file was generated under: " . realpath($fixturePath . "/" . $fixtureFileName) . "\n", Console::FG_GREEN); + $filePath = realpath($fixturePath . '/' . $fixtureFileName); + file_put_contents($filePath, $content); + $this->stdout("Fixture file was generated under: $filePath\n", Console::FG_GREEN); } } @@ -356,9 +357,9 @@ class FixtureController extends \yii\console\controllers\FixtureController public function confirmGeneration($files) { $this->stdout("Fixtures will be generated under the path: \n", Console::FG_YELLOW); - $this->stdout(realpath(Yii::getAlias($this->fixturePath, false)) . "\n\n", Console::FG_GREEN); + $this->stdout(realpath(Yii::getAlias($this->fixturePath)) . "\n\n", Console::FG_GREEN); $this->stdout("Templates will be taken from path: \n", Console::FG_YELLOW); - $this->stdout(realpath(Yii::getAlias($this->templatePath, false)) . "\n\n", Console::FG_GREEN); + $this->stdout(realpath(Yii::getAlias($this->templatePath)) . "\n\n", Console::FG_GREEN); foreach ($files as $index => $fileName) { $this->stdout(" " . ($index + 1) . ". " . basename($fileName) . "\n", Console::FG_GREEN); diff --git a/framework/base/Request.php b/framework/base/Request.php index cd3ffdc9f4..b76886ed4a 100644 --- a/framework/base/Request.php +++ b/framework/base/Request.php @@ -6,6 +6,7 @@ */ namespace yii\base; +use Yii; /** * Request represents a request that is handled by an [[Application]]. @@ -72,7 +73,7 @@ abstract class Request extends Component */ public function setScriptFile($value) { - $scriptFile = realpath(\Yii::getAlias($value)); + $scriptFile = realpath(Yii::getAlias($value)); if ($scriptFile !== false && is_file($scriptFile)) { $this->_scriptFile = $scriptFile; } else { diff --git a/framework/web/AssetManager.php b/framework/web/AssetManager.php index 89e746e1f0..b8f7dfa007 100644 --- a/framework/web/AssetManager.php +++ b/framework/web/AssetManager.php @@ -227,8 +227,7 @@ class AssetManager extends Component return $this->_published[$path]; } - $src = realpath($path); - if ($src === false) { + if (!is_string($path) || ($src = realpath($path)) === false) { throw new InvalidParamException("The file or directory to be published does not exist: $path"); } @@ -295,7 +294,7 @@ class AssetManager extends Component if (isset($this->_published[$path])) { return $this->_published[$path][0]; } - if (($path = realpath($path)) !== false) { + if (is_string($path) && ($path = realpath($path)) !== false) { $base = $this->basePath . DIRECTORY_SEPARATOR; if (is_file($path)) { return $base . $this->hash(dirname($path) . filemtime($path)) . DIRECTORY_SEPARATOR . basename($path); @@ -319,7 +318,7 @@ class AssetManager extends Component if (isset($this->_published[$path])) { return $this->_published[$path][1]; } - if (($path = realpath($path)) !== false) { + if (is_string($path) && ($path = realpath($path)) !== false) { if (is_file($path)) { return $this->baseUrl . '/' . $this->hash(dirname($path) . filemtime($path)) . '/' . basename($path); } else {