-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed the filesystem loader with relative paths #2195
Conversation
{ | ||
$this->rootPath = realpath(null !== $rootPath ? $rootPath : getcwd()).DIRECTORY_SEPARATOR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the place being broken if $rootPath
is inside a phar, as $this->rootPath
will be false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say that we don't want to support this use case (if everything is in a phar, then using an absolute path is not really an issue anymore). So, if realpath
returns false here, I would prefer to throw an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if someone uses relative path for the loader paths and passes __DIR__
as root path (instead of making all paths absolute in the loader paths), your suggestion would break the project once it gets bundled as phar.
This seems worse than forbidding passing relative paths to the loader altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
e5041b6
to
2fd5b0f
Compare
Ready. |
2fd5b0f
to
5f25a11
Compare
/** | ||
* Constructor. | ||
* | ||
* @param string|array $paths A path or an array of paths where to look for templates | ||
* @param string|array $paths A path or an array of paths where to look for templates | ||
* @param string $rootPath The root path common to all relative paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string|null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
5f25a11
to
a343c92
Compare
This PR was merged into the 1.x branch. Discussion ---------- fixed the filesystem loader with relative paths closes #2145 TODO - [x] document the new `$rootPath` option - [x] add test with a `$rootPath` different from `getcwd()` - [x] test the cache key does not vary when `$rootPath` changes Commits ------- a343c92 fixed the filesystem loader with relative paths
closes #2145
TODO
$rootPath
option$rootPath
different fromgetcwd()
$rootPath
changes