FIX Allow 0 as a directory name#683
Merged
emteknetnz merged 1 commit intosilverstripe:3.0from Apr 29, 2025
Merged
Conversation
1580d46 to
d976b2a
Compare
| protected static function getFilePathParts(string $filePath): array | ||
| { | ||
| // Explicitly allow zero as a segment in the path (e.g. /some/path/0/file.txt) | ||
| $notEmpty = fn(mixed $part) => ($part === 0 || $part === '0' || (bool) $part); |
Contributor
There was a problem hiding this comment.
I guess the conversion is implicit here, is it not? Ok to leave as is if it's better from some perspective.
Suggested change
| $notEmpty = fn(mixed $part) => ($part === 0 || $part === '0' || (bool) $part); | |
| $notEmpty = fn(mixed $part) => ($part === 0 || $part === '0' || $part); |
Member
Author
There was a problem hiding this comment.
Yeah, I guess it is implicitly cast if not done explicitly. In my head it made sense to be explicit here but both do exactly the same thing. I think this is just up to subjective preference.
Contributor
There was a problem hiding this comment.
I learnt not to cast to bool if it's in any logical condition/expression as PhpStorm always hints at it as useless due to it being casted implicitly.
Contributor
|
|
michalkleiner
approved these changes
Apr 28, 2025
emteknetnz
requested changes
Apr 29, 2025
emteknetnz
approved these changes
Apr 29, 2025
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.
This isn't
Path::join()but the same problem applies as described in the issue - "0" is being filtered out even though it's valid.Issue
Path::join()doesn't allow "0" to be a directory name in the path. silverstripe-framework#11708