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

Assets can not be resolved on SSP (symlinked assets folder) #362

Closed
robbieaverill opened this issue Jan 12, 2017 · 4 comments
Closed

Assets can not be resolved on SSP (symlinked assets folder) #362

robbieaverill opened this issue Jan 12, 2017 · 4 comments

Comments

@robbieaverill
Copy link
Contributor

robbieaverill commented Jan 12, 2017

In a site hosted on SSP, none of the assets will load.

Uploading a new image shows the preview, then when you navigate away and back again it is gone.

The network browser tells me that the thumbnails it tries to load are just my root domain, no filename included. I don't see assets/ as a prefix to the filenames that are returned in the GraphQL, just for example Uploads/filename.jpg


I can replicate this locally by changing my assets directory to a symlink. Note: the underlying league/flysystem package does not support symlinks.

@robbieaverill robbieaverill changed the title Assets can not be resolved on SSP Assets can not be resolved on SSP (symlinked assets folder) Jan 12, 2017
@robbieaverill
Copy link
Contributor Author

cc @marcello-silverstripe

@tractorcow
Copy link
Contributor

Answer is in thephpleague/flysystem#599 (comment); We just need a realpath in AssetAdapter::findRoot to ensure we work with the symlinked path as the root, rather than the symlink alias.

@tractorcow
Copy link
Contributor

tractorcow commented Jan 25, 2017

ok, after much debugging, we found the bug is in PublicAssetAdapter::getPublicURL()

It uses realpath($this->getPathPrefix), which may not be within BASE_PATH once resolved from a symlink.

The fix is to store a logicalPathPrefix when we construct the adapter, and compare this to base_path (without realpath).

Also, instead of falling back to returning null, we can assume $dir === ASSET_DIR instead. :D

tractorcow pushed a commit to open-sausages/silverstripe-framework that referenced this issue Jan 25, 2017
@tractorcow
Copy link
Contributor

Updated fix at silverstripe/silverstripe-framework#6565

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants