Make $civicrm_paths less sensitive to trailing slashes. Add tests. #16404
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Recall that the default value of
imageUploadURL
is[civicrm.files]/persist/contribute/
. Now, suppose you have one of these two configurations incivicrm.settings.php
:You could inspect to see if the URL is generated correctly by running these commands:
Before
Under either configuration (trailing-slash or trimmed-slash), you'll find that paths are generated properly (
cv path ...
orCivi::paths()->getPath(...)
).For generating URLs (
cv url ...
orCivi::paths()->getUrl(...)
), only the trailing-slash cfg works. The trimmed-slash cfg leads to a bad URL with a missing slash.This is surprising because the path expression (
[civicrm.files]/persist/contribute
) includes a slash... but it disappears in the final computation.After
Both configurations work, for paths and for URLs.
Comments
This fixes an issue in which the git-based Civi-D8 sites have a malfunctioning menu -- because the asset URLs are malformed.
This PR is an extracted subset of #16328, which was an exploratory branch aimed at supporting deployment of Civi git repos in D8 via composer. The changes are extracted to make the size of the review more manageable. It's probably best to use this smaller PR to consider topics like regression-risk and general code convention rather than trying to assess the fuller aims of #16328.