Skip to content

Commit 6fa9594

Browse files
committed
more tweaks for #79
1 parent 6fe9517 commit 6fa9594

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,21 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
135135

136136
$result = json_decode($rawResult, true);
137137

138-
if ($result === null && json_last_error() != JSON_ERROR_NONE) {
138+
if (!empty($rawResult) && $result === null && json_last_error() != JSON_ERROR_NONE) {
139139
throw WebDriverException::factory(
140140
WebDriverException::CURL_EXEC,
141141
'Payload received from webdriver is not valid json: ' . substr($rawResult, 0, 1000)
142142
);
143143
}
144144

145-
if (!is_array($result) || !array_key_exists('status', $result)) {
145+
if (is_array($result) && !array_key_exists('status', $result)) {
146146
throw WebDriverException::factory(
147147
WebDriverException::CURL_EXEC,
148148
'Payload received from webdriver is valid but unexpected json: ' . substr($rawResult, 0, 1000)
149149
);
150150
}
151151

152-
$value = array_key_exists('value', $result) ? $result['value'] : null;
152+
$value = (is_array($result) && array_key_exists('value', $result)) ? $result['value'] : null;
153153
$message = (is_array($value) && array_key_exists('message', $value)) ? $value['message'] : null;
154154

155155
// if not success, throw exception

0 commit comments

Comments
 (0)