Fix incorrect MediaLibrary links when base path is not the domain root #4055
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.
This PR fixes #4039, a bug that was introduced in PR #3536.
Currently the app root/base path is added to the
storagePath
variable inMediaLibrary
, which is then used to generate the links with thegetPathUrl()
function. Since PR #3536 this is then also passed through theUrl::to()
function to adhere to the link policy, however the base path is added again in this method and therefore we get duplicated base paths in the final URL (only noticeable if your base path is not the domain root, and not using S3 etc). This PR solves the issue by not adding the base path tostoragePath
in theMediaLibrary
.storagePath
is a protected variable and not used anywhere else within theMediaLibrary
so this should not cause any other problems, it would however affect anyone extending theMediaLibrary
class and using this variable.Unfortunately I have no experience using tests, and not the time needed to learn this within a reasonable timeframe for the need of this PR. Ping @w20k