Make sure '0' edge case is properly handled by is_json()#4634
Closed
kirtangajjar wants to merge 1 commit intowp-cli:masterfrom
Closed
Make sure '0' edge case is properly handled by is_json()#4634kirtangajjar wants to merge 1 commit intowp-cli:masterfrom
kirtangajjar wants to merge 1 commit intowp-cli:masterfrom
Conversation
Fixed wp-cli#4629 - Broken `0` edge case in `WP_CLI\Utils\is_json()`
gitlost
suggested changes
Jan 24, 2018
Contributor
gitlost
left a comment
There was a problem hiding this comment.
Thanks v much @kirtangajjar ! Could you also add these test cases
array( '0', true, false ),
array( '0', false, true ),
array( '', true, false ),
array( '', false, false ),
to dataIsJson() in "tests/test-utils.php" please?
| */ | ||
| function is_json( $argument, $ignore_scalars = true ) { | ||
| if ( empty( $argument ) || ! is_string( $argument ) ) { | ||
| if ( ! is_string( $argument ) || 0 === strlen( $argument ) ) { |
Contributor
There was a problem hiding this comment.
Sorry just to be "modern" could you change this to:
if ( ! is_string( $argument ) || '' === $argument ) {
please? (My fault).
Contributor
Author
|
Sorry looks like I accidentially created new PR #4635. I published commit to my |
Contributor
|
Ok it's probably easiest if I close this and use the other one. |
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.
Fixed #4629 - Broken
0edge case inWP_CLI\Utils\is_json()