diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 3cdc3e91ee0ef7c3e2eff18b4402dbce0b6a1acd..6b271ba2aa84338cbdbc9d78c01d8472d2ac303b 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -816,6 +816,13 @@ protected function curlInitialize() { if (!isset($this->curlHandle)) { $this->curlHandle = curl_init(); + + // Some versions/configurations of cURL break on a NULL cookie jar, so + // supply a real file. + if (empty($this->cookieFile)) { + $this->cookieFile = $this->public_files_directory . '/cookie.jar'; + } + $curl_options = array( CURLOPT_COOKIEJAR => $this->cookieFile, CURLOPT_URL => $base_url, @@ -830,7 +837,12 @@ protected function curlInitialize() { $curl_options[CURLOPT_HTTPAUTH] = $this->httpauth_method; $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials; } - curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options); + // curl_setopt_array() returns FALSE if any of the specified options + // cannot be set, and stops processing any further options. + $result = curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options); + if (!$result) { + throw new \UnexpectedValueException('One or more cURL options could not be set.'); + } // By default, the child session name should be the same as the parent. $this->session_name = session_name();