Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Bad logic while checking if timeouts are numeric #169

Closed
2 tasks done
javabudd opened this issue Jan 15, 2019 · 2 comments
Closed
2 tasks done

Bad logic while checking if timeouts are numeric #169

javabudd opened this issue Jan 15, 2019 · 2 comments

Comments

@javabudd
Copy link

javabudd commented Jan 15, 2019

  • I was not able to find an open or closed issue matching what I'm seeing.
  • This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

There was new logic added to the Client and Socket adapters to apply an integer/numeric check (5b36ca3, 4dc2c30) that is not working as expected.

if ($connectTimeout !== null && (! is_int($connectTimeout) || ! is_numeric($connectTimeout))) {
                throw new AdapterException\InvalidArgumentException(sprintf(
                    'integer or numeric string expected, got %s',
                    gettype($connectTimeout)
                ));
            }

If $connectTimeout is a numeric string, ! is_int($connectTimeout) will return true and the exception will be thrown without is_numeric being called.

Code to reproduce the issue

$client = new \Zend\Http\Client();
$client->setOptions(['timeout' => '20']);

$request = new \Zend\Http\Request();
$client->dispatch($request);

Expected results

Timeout should be validated properly since it's a numeric string.

Actual results

Exception is thrown integer or numeric string expected, got string.

@kmwalke
Copy link

kmwalke commented Jan 16, 2019

My team ran into this exact issue.

@michalbundyra
Copy link
Member

Please see #168

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants