Only try to extract first part of the explode result#2524
Merged
juliusknorr merged 1 commit intomasterfrom Nov 12, 2020
Merged
Conversation
Signed-off-by: Julius Härtl <jus@bitgrid.net>
| public function get($key) { | ||
| $result = null; | ||
| [$scope, $id] = explode(':', $key, 2); | ||
| [$scope] = explode(':', $key, 2); |
Member
There was a problem hiding this comment.
Suggested change
| [$scope] = explode(':', $key, 2); | |
| [$scope] = explode(':', $key, 1); |
if you don't care about the rest :)
Member
Author
There was a problem hiding this comment.
No, that would basically not explode the value at all:
If limit is set and positive, the returned array will contain a maximum of limit elements with the last element containing the rest of string.
$foo = explode(':', 'a:b:c:d', 1);
array(1) {
[0]=>
string(7) "a:b:c:d"
}
ChristophWurst
approved these changes
Nov 12, 2020
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 #2522
As we only use the first result anyways we can safely ignore the second part if one exists.
cc @Chartman123