[Blueprints] Replace randomString() with randomFilename() in installAsset() #2677
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.
Motivation for the change, related issues
@bcotrim reported a problem with random empty folders showing up in wp-content when creating sites from a specific Blueprint:
The problem was with the
installAsset()function callingrandomString()to generate filenames. Sometimes the resulting string would contain a slash, which would create a subdirectory structure. After the asset is processed, only the subdirectory would be cleaned up, leaving the parent directory unchanged.Implementation details
This PR replaces the
randomString()call with arandomFilename()call. It uses the same randomizer, but it restrict the set of special characters to just-and_.Testing Instructions (or ideally a Blueprint)
Run this Blueprint with a local Playground CLI or Playground web and confirm that, after it's finished, there are no random-looking directories inside
wp-content. Repeat this test a few times for a good measure.cc @bcotrim @brandonpayton @wojtekn @JanJakes @akirk