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

cast to (int) for Curl adapter timeout config #121

Merged
merged 3 commits into from
Jan 8, 2019

Conversation

samsonasik
Copy link
Contributor

same as what applied into Socket adapter

@Xerkus
Copy link
Member

Xerkus commented Oct 13, 2017

What is the reason for accepting non-integer timeout values?
I would say exception should be thrown instead.

@samsonasik
Copy link
Contributor Author

just for consistent with socket adapter. if it should be get exception, the in socket adapter should get exception as well?

@Xerkus
Copy link
Member

Xerkus commented Oct 13, 2017

That would be my preference, yes. I will need to look into it sometime later, may be i don't see something.

@@ -203,9 +203,9 @@ public function connect($host, $port = 80, $secure = false)
}

if (isset($this->config['connecttimeout'])) {
$connectTimeout = $this->config['connecttimeout'];
$connectTimeout = (int) $this->config['connecttimeout'];
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer the following approach:

  • Grab the config value.
  • If it is not an integer or not a numeric string, throw an InvalidArgumentException.
  • Cast to integer.

That approach ensures strings like timeout do not get cast to 0, which is obviously incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need to check $this->config['timeout'] and $this->config['connecttimeout'] in setOptions() function ? and change it at Socket adapter as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated with integer and numeric check, applied to socket adapter as well.

@weierophinney weierophinney added this to the 2.8.3 milestone Jan 7, 2019
@weierophinney weierophinney merged commit 4dc2c30 into zendframework:master Jan 8, 2019
weierophinney added a commit that referenced this pull request Jan 8, 2019
cast to (int) for Curl adapter timeout config
weierophinney added a commit that referenced this pull request Jan 8, 2019
weierophinney added a commit that referenced this pull request Jan 8, 2019
weierophinney added a commit that referenced this pull request Jan 8, 2019
@weierophinney
Copy link
Member

Thanks, @samsonasik!

@samsonasik samsonasik deleted the curl-timeout-int branch January 8, 2019 16:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants