Commit 6a93b9d4 authored by Dries's avatar Dries
Browse files

- Patch #336043 by c960657: skip calls to curlExec() in curlConnect(). Nice find, c960657\!

parent a7b2b9df
...@@ -784,13 +784,13 @@ function tearDown() { ...@@ -784,13 +784,13 @@ function tearDown() {
} }
/** /**
* Initializes the cURL connection and gets a session cookie. * Initializes the cURL connection.
* *
* This function will add authentication headers as specified in * This function will add authentication headers as specified in the
* simpletest_httpauth_username and simpletest_httpauth_pass variables. * simpletest_httpauth_username and simpletest_httpauth_pass variables. Also,
* Also, see the description of $curl_options among the properties. * see the description of $curl_options among the properties.
*/ */
protected function curlConnect() { protected function curlInitialize() {
global $base_url, $db_prefix; global $base_url, $db_prefix;
if (!isset($this->ch)) { if (!isset($this->ch)) {
$this->ch = curl_init(); $this->ch = curl_init();
...@@ -812,7 +812,7 @@ protected function curlConnect() { ...@@ -812,7 +812,7 @@ protected function curlConnect() {
} }
$curl_options[CURLOPT_USERPWD] = $auth; $curl_options[CURLOPT_USERPWD] = $auth;
} }
return $this->curlExec($curl_options); curl_setopt_array($this->ch, $this->curl_options + $curl_options);
} }
} }
...@@ -825,7 +825,7 @@ protected function curlConnect() { ...@@ -825,7 +825,7 @@ protected function curlConnect() {
* Content returned from the exec. * Content returned from the exec.
*/ */
protected function curlExec($curl_options) { protected function curlExec($curl_options) {
$this->curlConnect(); $this->curlInitialize();
$url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL]; $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
curl_setopt_array($this->ch, $this->curl_options + $curl_options); curl_setopt_array($this->ch, $this->curl_options + $curl_options);
$this->drupalSetContent(curl_exec($this->ch), curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL)); $this->drupalSetContent(curl_exec($this->ch), curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL));
......
...@@ -100,7 +100,9 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { ...@@ -100,7 +100,9 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
function testPageCache() { function testPageCache() {
global $base_url; global $base_url;
variable_set('cache', 1); variable_set('cache', 1);
// Retrieve the front page, which has already been cached by $this->curlConnect(); // Fill the cache.
$this->drupalGet($base_url);
$this->drupalHead($base_url); $this->drupalHead($base_url);
$this->assertText('ETag: ', t('Verify presence of ETag header indicating that page caching is enabled.')); $this->assertText('ETag: ', t('Verify presence of ETag header indicating that page caching is enabled.'));
} }
...@@ -164,12 +166,10 @@ class HookBootExitTestCase extends DrupalWebTestCase { ...@@ -164,12 +166,10 @@ class HookBootExitTestCase extends DrupalWebTestCase {
* Test calling of hook_boot() and hook_exit(). * Test calling of hook_boot() and hook_exit().
*/ */
function testHookBootExit() { function testHookBootExit() {
// Test with cache disabled. Boot and exit should always fire. Initialize // Test with cache disabled. Boot and exit should always fire.
// the number of hook calls to two since the first call to drupalGet
// actually performs two HTTP requests.
variable_set('cache', CACHE_DISABLED); variable_set('cache', CACHE_DISABLED);
$this->drupalGet(''); $this->drupalGet('');
$calls = 2; $calls = 1;
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_boot'")->fetchField(), $calls, t('hook_boot called with disabled cache.')); $this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_boot'")->fetchField(), $calls, t('hook_boot called with disabled cache.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_exit'")->fetchField(), $calls, t('hook_exit called with disabled cache.')); $this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_exit'")->fetchField(), $calls, t('hook_exit called with disabled cache.'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment