Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit fab0b48

Browse files
committed
CURLOPT_CONNECTTIMEOUT_MS is undefined in some versions of PHP
For some reasons, CURLOPT_CONNECTTIMEOUT_MS is undefined and it is a bug in some versions of php. Bug reports, https://www.mail-archive.com/wikibugs-l@lists.wikimedia.org/msg312672.html Issue on facebook/php-webdriver, php-webdriver/php-webdriver#154 Issue on Codeception/Codeception, Codeception/Codeception#1116
1 parent 64802a7 commit fab0b48

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/net/URLChecker.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ private function getHTTPResponseCode($timeout_in_ms, $url) {
5959
curl_setopt($ch, CURLOPT_URL, $url);
6060
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
6161
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, self::CONNECT_TIMEOUT_MS);
62+
// There is a PHP bug in some versions which didn't define the constant.
63+
curl_setopt(
64+
$ch,
65+
156, // CURLOPT_CONNECTTIMEOUT_MS
66+
self::CONNECT_TIMEOUT_MS
67+
);
6268
$code = null;
6369
try {
6470
curl_exec($ch);

lib/remote/HttpCommandExecutor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class HttpCommandExecutor implements WebDriverCommandExecutor {
113113
public function __construct($url) {
114114
$this->url = $url;
115115
$this->curl = curl_init();
116-
curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT_MS, 300000);
117116
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
118117
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
119118
curl_setopt(
@@ -124,14 +123,16 @@ public function __construct($url) {
124123
'Accept: application/json',
125124
)
126125
);
126+
$this->setTimeout(300000);
127127
}
128128

129129
/**
130130
* @param int $timeout
131131
* @return HttpCommandExecutor
132132
*/
133133
public function setTimeout($timeout) {
134-
curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT_MS, $timeout);
134+
// There is a PHP bug in some versions which didn't define the constant.
135+
curl_setopt($this->curl, /* CURLOPT_CONNECTTIMEOUT_MS */ 156, $timeout);
135136
return $this;
136137
}
137138

0 commit comments

Comments
 (0)