Index: code_coverage.xdebug.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/code_coverage/code_coverage.xdebug.inc,v
retrieving revision 1.7
diff -u -r1.7 code_coverage.xdebug.inc
--- code_coverage.xdebug.inc	12 Mar 2010 21:41:00 -0000	1.7
+++ code_coverage.xdebug.inc	12 Mar 2010 23:46:37 -0000
@@ -16,19 +16,8 @@
     drupal_set_message('View the <a href="coverage/' . $coverage_set . '">code coverage report</a> for the page run.');
   }
   else {
-    global $db_prefix;
-    $db_prefix_testing = $db_prefix;
-    $db_prefix = preg_replace('/s\d+$/m', '', $db_prefix);
-
-    // Use the current test_id as the coverage set ID.
-    $coverage_set = db_select('simpletest_test_id', 's')
-      ->fields('s', 'test_id')
-      ->orderBy('test_id', 'DESC')
-      ->range(0, 1)
-      ->execute()
-      ->fetchField();
-
-    $db_prefix = $db_prefix_testing;
+    // Requires db-query so perform during record stage.
+    $coverage_set = FALSE;
   }
 
   // Start Xdebug code coverage and register shutdown function to collect the
@@ -51,6 +40,16 @@
   $db_prefix = preg_replace('/s\d+$/m', '', $db_prefix);
   $info = drupal_parse_info_file(DRUPAL_ROOT . '/' . drupal_get_path('module', 'code_coverage') . '/code_coverage.info');
 
+  if (!$coverage_set) {
+    // Use the current test_id as the coverage set ID.
+    $coverage_set = db_select('simpletest_test_id', 's')
+      ->fields('s', 'test_id')
+      ->orderBy('test_id', 'DESC')
+      ->range(0, 1)
+      ->execute()
+      ->fetchField();
+  }
+
   // Cycle through the code coverage for each file.
   $coverage = xdebug_get_code_coverage();
   foreach ($coverage as $file => $lines) {
Index: core.patch
===================================================================
RCS file: core.patch
diff -N core.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ core.patch	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,98 @@
+Index: index.php
+===================================================================
+RCS file: /cvs/drupal/drupal/index.php,v
+retrieving revision 1.99
+diff -u -r1.99 index.php
+--- index.php 15 Oct 2009 14:07:25 -0000  1.99
++++ index.php 12 Mar 2010 23:39:54 -0000
+@@ -12,6 +12,9 @@
+  * See COPYRIGHT.txt and LICENSE.txt.
+  */
+ 
++require_once 'sites/all/modules/code_coverage/code_coverage.xdebug.inc';
++$code_coverage_installed = TRUE;
++
+ /**
+  * Root directory of Drupal installation.
+  */
+Index: install.php
+===================================================================
+RCS file: /cvs/drupal/drupal/install.php,v
+retrieving revision 1.237
+diff -u -r1.237 install.php
+--- install.php 17 Feb 2010 04:19:51 -0000  1.237
++++ install.php 12 Mar 2010 23:39:54 -0000
+@@ -6,6 +6,8 @@
+  * Initiates a browser-based installation of Drupal.
+  */
+ 
++require_once 'sites/all/modules/code_coverage/code_coverage.xdebug.inc';
++
+ /**
+  * Root directory of Drupal installation.
+  */
+Index: update.php
+===================================================================
+RCS file: /cvs/drupal/drupal/update.php,v
+retrieving revision 1.317
+diff -u -r1.317 update.php
+--- update.php  6 Mar 2010 06:31:23 -0000 1.317
++++ update.php  12 Mar 2010 23:41:31 -0000
+@@ -6,6 +6,8 @@
+  */
+ define('DRUPAL_ROOT', getcwd());
+ 
++require_once 'sites/all/modules/code_coverage/code_coverage.xdebug.inc';
++
+ /**
+  * @file
+  * Administrative page for handling updates from one Drupal version to another.
+
+Index: authorize.php
+===================================================================
+RCS file: /cvs/drupal/drupal/authorize.php,v
+retrieving revision 1.7
+diff -u -r1.7 authorize.php
+--- authorize.php 6 Mar 2010 06:31:23 -0000 1.7
++++ authorize.php 12 Mar 2010 23:39:54 -0000
+@@ -21,6 +21,8 @@
+  * @link authorize Authorized operation helper functions @endlink
+  */
+ 
++require_once 'sites/all/modules/code_coverage/code_coverage.xdebug.inc';
++
+ /**
+  * Root directory of Drupal installation.
+  */
+Index: xmlrpc.php
+===================================================================
+RCS file: /cvs/drupal/drupal/xmlrpc.php,v
+retrieving revision 1.19
+diff -u -r1.19 xmlrpc.php
+--- xmlrpc.php  13 Dec 2009 13:06:45 -0000  1.19
++++ xmlrpc.php  12 Mar 2010 23:39:54 -0000
+@@ -6,6 +6,8 @@
+  * PHP page for handling incoming XML-RPC requests from clients.
+  */
+ 
++require_once 'sites/all/modules/code_coverage/code_coverage.xdebug.inc';
++
+ /**
+  * Root directory of Drupal installation.
+  */
+Index: cron.php
+===================================================================
+RCS file: /cvs/drupal/drupal/cron.php,v
+retrieving revision 1.43
+diff -u -r1.43 cron.php
+--- cron.php  2 Nov 2009 03:30:49 -0000 1.43
++++ cron.php  12 Mar 2010 23:39:54 -0000
+@@ -6,6 +6,8 @@
+  * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
+  */
+ 
++require_once 'sites/all/modules/code_coverage/code_coverage.xdebug.inc';
++
+ /**
+  * Root directory of Drupal installation.
+  */
