-
Notifications
You must be signed in to change notification settings - Fork 2
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
Relative path issue in wireIncludeFile #511
Comments
I use I don't see a |
Thanks for chiming in @Toutouwai Maybe I should have been a little more explicit - I am actually hoping that Zeka from the PW forums will chime in (not sure his Github handle) because he found this with the Tracy console panel. If you put something like this: |
@adrianbj Thank you for opening this issue. When I put this line in ready.php In my case, I didn't get the exception from this line https://github.com/processwire/processwire/blob/a9ec5a640ac0442d3980d2cd33770626aafc91a2/wire/core/WireFileTools.php#L730 when open the site but got when using the Console panel. How to reproduce it:
I've tested this behavior on two different installations of the latest PW. |
Thanks for contributing @Lazerproof - I also don't see any error when viewing the site, but I also don't think this is specific to Tracy. In that example where a wireIncludeFile is added to ready.php, from what I can tell any module that results in ready.php being loaded will trigger that "file does not exist" error because the path to the included file will be relative to the root of the module, rathe than /site/ Hopefully between us we've now managed to explain this a little better :) |
I'm not sure I understand the issue report. File functions (whether PHP's or PW's) operate from the current working directory, not from the directory that the caller's file lives in (which it would have no way of knowing). During execution, ProcessWire sets the current working directory to the dir of whatever file is being rendered, i.e. /site/templates/. So any file function that you call (whether one from PHP or PW or anything else), a relative path is going to be relative to that directory. Unless you have set the current working directory chdir() on your own, don't call file functions with relative paths. If you want something relative to the file of where you make the call, then use |
@ryancramerdesign - maybe this is an unusual situation, but Tracy's Console panel uses: Probably the easiest way for you to see what is going on is to follow @Lazerproof 's instructions above. I didn't mention Tracy in my OP because I think it's very possible this could occur in other future modules as well. The dev adding a wireIncludeFile shouldn't have to consider the path to the root when using Thanks. |
@ryancramerdesign Do you have enough information to proceed? |
@ryancramerdesign - you state that this is not a bug, but could you please confirm that you tested as per @Lazerproof 's instructions above? I still think this could easily be solved by prepending |
Short description of the issue
Methods in the WireFileTools class, like
include
use relative paths so if you usewireIncludeFile()
or$files->include()
from a module the file is not included because the path is something like:./templates/fileToInclude.php
Expected behavior
It should work no matter where it's called from.
Actual behavior
You get an error triggered by https://github.com/processwire/processwire/blob/a9ec5a640ac0442d3980d2cd33770626aafc91a2/wire/core/WireFileTools.php#L730
Optional: Suggestion for a possible fix
Convert path to filename to be absolute.
Setup/Environment
The text was updated successfully, but these errors were encountered: