Skip to content

Only try to extract first part of the explode result#2524

Merged
juliusknorr merged 1 commit intomasterfrom
bugfix/2522
Nov 12, 2020
Merged

Only try to extract first part of the explode result#2524
juliusknorr merged 1 commit intomasterfrom
bugfix/2522

Conversation

@juliusknorr
Copy link
Copy Markdown
Member

Fixes #2522

As we only use the first result anyways we can safely ignore the second part if one exists.

cc @Chartman123

Signed-off-by: Julius Härtl <jus@bitgrid.net>
public function get($key) {
$result = null;
[$scope, $id] = explode(':', $key, 2);
[$scope] = explode(':', $key, 2);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[$scope] = explode(':', $key, 2);
[$scope] = explode(':', $key, 1);

if you don't care about the rest :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: Undefined offset: 1 at /var/www/html/custom_apps/deck/lib/Service/ConfigService.php#68 in 1.2.0 beta1

2 participants