Skip to content

Perform strict comparison for set() options array#4833

Closed
matthiasmullie wants to merge 1 commit into
facebook:masterfrom
matthiasmullie:patch-1
Closed

Perform strict comparison for set() options array#4833
matthiasmullie wants to merge 1 commit into
facebook:masterfrom
matthiasmullie:patch-1

Conversation

@matthiasmullie

Copy link
Copy Markdown
Contributor

The non-strict check results in false positives with a zero expiration time.
The following returns true for $nx, even though it's a valid options array & doesn't include nx.

$optionArrayOrExpiration = array(
    'xx', // if exists
    'ex' => 0 // expire time in seconds
);
$nx = in_array('nx', $optionArrayOrExpiration);

Making it a strict check fixes that:

$nx = in_array('nx', $optionArrayOrExpiration, true); // returns false

The non-strict check results in false positives with a zero expiration time.
The following returns `true` for $nx, even though it's a valid options array & doesn't include nx.

    $optionArrayOrExpiration = array(
        'xx', // if exists
        'ex' => 0 // expire time in seconds
    );
    $nx = in_array('nx', $optionArrayOrExpiration);

Making it a strict check fixes that:

    $nx = in_array('nx', $optionArrayOrExpiration, true); // returns false
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been imported into Phabricator, and discussion and review of the diff will take place at https://reviews.facebook.net/D33393

@facebook-github-bot

Copy link
Copy Markdown
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@facebook-github-bot

Copy link
Copy Markdown
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@hhvm-bot hhvm-bot closed this in 826dcbb Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants