Conversation
rinatkhaziev
requested changes
Feb 9, 2021
Contributor
rinatkhaziev
left a comment
There was a problem hiding this comment.
isset is not reliable in this context because it'll be false if the value is NULL:
$keys = [
'test' => null,
'test2' => 'null',
'test3' => 1,
];
foreach( $keys as $key => $val ) {
var_dump( isset( $keys[ $key ] ) );
}
echo "\n";
foreach( $keys as $key => $val ) {
var_dump(array_key_exists( $key , $keys ) );
}
=>
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
array_key_exists would be safer.
Author
|
Documenting some of the edge-case behaviors:
|
Author
The PR is a bit more complex now though, but some good news is that we can eventually deploy to Side note: Held off on using PHP's new array destructuring & |
Slight performance boost under optimal conditions.
|
Kudos, SonarCloud Quality Gate passed!
|
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.








If you send an array, the memcache client will respond with an associative array: https://www.php.net/manual/en/memcache.get.php. With this, we can ensure that the memcached server is giving us the correct response.
This is just a proof of concept for now. Some further ideas include:
As a side note, we should really be making use of this functionality for the multi_get() logic that WP now uses - as it can greatly limit the # of roundtrips to the memcached server. But can come back to that another day :).