Repository navigation
Prevent overwriting localized media with colliding filenames - #922
Open
gohelkunjan wants to merge 1 commit into
Open
gohelkunjan wants to merge 1 commit into
gohelkunjan wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #911
Description
When localizing multiple distinct media URLs that share the same basename (e.g.,
/2024/01/hero.jpgand/2025/06/hero.jpg), the second download previously overwrote the first file inassets/images/(and in exported ZIP archives), causing both blocks to point to the same file.Changes
CBT_Theme_Media::get_unique_media_filename()and per-URL relative path tracking inCBT_Theme_Mediaso colliding filenames receive unique suffixes (hero-1.jpg,hero-2.jpg, etc.) while identical URLs continue to reuse the same local asset.CBT_Theme_Media::add_media_to_local()andCBT_Theme_Zip::add_media_to_zip()(withCBT_Zip_Archive::locateNameInTheme()) to check for existing files/entries before writing.CBT_Theme_Media::get_media_relative_path_from_url()to return the assigned unique path somake_template_images_local()andCBT_Token_Processorrewrite each block to its matching asset.tests/test-theme-media.phpandtests/test-theme-zip.php.Testing
php -lon all modified PHP files andgit diff --checklocally.