I have found that routes with dynamic paths through path processing are breaking under pathologic. For example, image styles.
The way these work is that a route is registered on a subfolder the public files directory path, then a path processor translates the trailing directory/filename into a query parameter which is in turn grabbed by the route controller. This is so that the subdirectory can have unlimited depth in the tree and still work.
For example:
My image style route is registered at /sites/default/files/styles/{image_style}/{scheme}
My image style url is /sites/default/files/styles/thumbnail/public/2016-05/myimage.jpg
When pathologic translates this url, the line:
$url = Url::fromUri('internal:/' . $url_params['path'], $url_params['options'])->toString();
returns:
/sites/default/files/styles/thumbnail/public
I'm assuming this is because that is the path that the actual route is registered on.
An easy solution would be to allow pathologic configuration to ignore paths. I actually found this bug when implementing a similar mechanism for caching external images.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 2718473-dynamic-image-style-lookup-25.patch | 1.66 KB | mvc |
Issue fork pathologic-2718473
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
acbramley commentedAdds an ignore_paths configuration item and checks this in the filter process callback.
Comment #3
acbramley commentedComment #5
acbramley commentedAttempting to fix test failures.
Comment #7
acbramley commentedHad missed the schema updates for the filter settings.
Comment #9
acbramley commentedUpdated to fix undefined index error if path was not set.
Comment #11
acbramley commentedWoops, that included another patch.
Comment #12
jonathanshawComment #14
acbramley commentedI've tried to figure out where those tests are failing but I can't find what I'm missing. Any help would be great!
Comment #15
minoroffense commentedHere's a reroll of the patch against the current dev. I can confirm that setting ignore paths for /sites/default/files/* fixes the image styles problem.
Comment #17
guedressel commentedThis specific issue with image style URLs is only apparent when the image derivative is not yet created. Once the derivative is created (thus the derived image is available on the filesystem) pathologic does not screw up the path anymore.
Comment #18
guedressel commentedCreated patch checking non-file path via route-lookup if it is a image_style route.
Comment #19
guedressel commentedFixed my patch:
internal://is bad.internal:/is better.Comment #20
guedressel commentedSlightly improved version from #19 is now also integrated in #2418369-25: Internal URL handling (language prefixes, base://, ...).
To keep things together I attach this improved version also here.
Comment #21
dwwThanks for the bug report and all the effort so far! My goal is to get #2418369: Internal URL handling (language prefixes, base://, ...) in soon, since there are a lot of bugs in the queue related to that. But it'd be great to fix this, too.
Meanwhile, I'd like to make sure our test coverage is solid, so I'm not going to commit issues that don't have tests. Tagging for that.
Thanks again,
-Derek
Comment #22
dwwp.s. The title references all 'Dynamic routes' but my very quick skim of the patch and it looks like it's is hard-coded to only handle image style routes. If this is really only fixing image styles, let's update the title accordingly. If this is actually handling any other kinds of dynamic routes, can someone explain how that works? ;)
Thanks again,
-Derek
Comment #23
mvcThis patch works for me except that a language prefix is still inserted into the file path, since is_files is never actually used. I know that's not closely related to the original post here but I've added a snippet from the latest patch in #2418369: Internal URL handling (language prefixes, base://, ...) which solves that problem for me.
Comment #24
mvcComment #25
mvcRerolling patch
Comment #26
veronicaseveryn commentedRerolling for Pathologic 2.0.x branch
Comment #28
veronicaseveryn commentedAdded MR !17 on 2.0.x branch with the changes from #25 (without language piece)