Skip to content
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

Asset library fails to resolve file system path correctly #4863

Closed
ipimpat opened this issue Oct 29, 2018 · 5 comments
Closed

Asset library fails to resolve file system path correctly #4863

ipimpat opened this issue Oct 29, 2018 · 5 comments

Comments

@ipimpat
Copy link

ipimpat commented Oct 29, 2018

Description

I'm trying to create a copy of an existing PyroCMS website for testing/development purpose, in a Apache/mod_userdir environment, where every employee has a personal web directory.

But the Asset library fails to resolve the correct file system path, when trying to get the content of files.

It seems that the Asset library assumes that file system paths and web paths are always the same, because it prepends the web base path: /~<username>/<pyrocms> to the relative path app/<app name>/assets/public/theme.css before trying to get the content of the file.

An exception has been thrown during the rendering of a template ("file_get_contents(/home/<username>/src/<pyrocms>/public/~<username>/<pyrocms>/app/<app name>/assets/public/theme.css) : failed to open stream: No such file or directory")`.
file_get_contents … /vendor/anomaly/streams-platform/src/Asset/Asset.php 318

If I modify the Asset::path method, so the request base path is not prepended, the issue i'm having in this case with the Asset::inline method goes away, but that seems to have a negative effect on methods like Asset::script

To Reproduce

/home/<username>/public_html is the "document root" and is available under http://<server>/~<username>

PyroCMS is placed outside the public_html directory /home/<username>/src/<pyrocms> and /home/<username>/src/<pyrocms>/public is symlinked to /home/<username>/public_html/<pyrocms>

So it's available under http://<server>/~<username>/<pyrocms>

@ipimpat ipimpat changed the title Asset library fails to resolve file system path Asset library fails to resolve file system path correctly Oct 29, 2018
@ipimpat
Copy link
Author

ipimpat commented Oct 29, 2018

It is possible to work around this issue by making the path a valid path, but it's not perfect or git friendly:

Create a symlink to the symlink inside the document root folder (public_html), something like this:

mkdir /home/<username>/src/<pyrocms>/public/~<username>
ln -s /home/<username>/public_html/<pyrocms> /home/<username>/src/<pyrocms>/public/\~<username>/<pyrocms>

@RyanThompson
Copy link
Member

Outside of manually configuring this I don't know that it can be fixed properly? The symlinking looks a little funky.

We, for example, use ~/home/USER/ for pyro install and rm public_html and then symlink it back to public (you can also simply rename public to public_html). And that works great. But you're on different levels here it looks like.

git init - git remote add origin YOUR REPO - git pull

Is a good way to pull down into a directory that already has CGI and other stuff in it that comes with a lot of hosting environments.

@ipimpat
Copy link
Author

ipimpat commented Nov 10, 2018

The symlinking is simple

/home/USER/some/path/pyro1/public => /home/USER/public_html/pyro1
/home/USER/some/path/pyro2/public => /home/USER/public_html/pyro2
/home/USER/some/path/pyro3/public => /home/USER/public_html/pyro3

Nevertheless, the problem I think is really that the Asset library assumes that a web path is always the same as the file path (which is not true), when it needs to read the content of file.

You can clearly see from the error, that it mixes the file system path + the web path

/home/USER/some/path/pyro1/public/some/web/path/pyro1/app/default/assets/public/theme.css

Did you see my PR ?

@RyanThompson
Copy link
Member

Fixed in Streams Platform 1.7

@ipimpat
Copy link
Author

ipimpat commented Apr 7, 2019

I can confirm it works

Tested on a fresh installation of PyroCMS 3.7 branch

@ipimpat ipimpat closed this as completed Apr 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants