Commit f93054a4 by Carsten Brandt

fixed possible problem with realpath and false value

realpath(false) = current working directory. This can cause problems with getAlias() which returns false. see yiisoft/yii#3113
parent 208d5eac
......@@ -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);
......
......@@ -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 {
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment