Index: pifr.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_review/pifr.install,v
retrieving revision 1.31
diff -u -r1.31 pifr.install
--- pifr.install	7 Aug 2009 05:14:43 -0000	1.31
+++ pifr.install	28 Oct 2009 07:08:34 -0000
@@ -1,5 +1,6 @@
 <?php
 // $Id: pifr.install,v 1.31 2009/08/07 05:14:43 boombatower Exp $
+
 /**
  * @file
  * Automatically review patches attached to issues.
@@ -15,22 +16,6 @@
   variable_del('pifr_debug');
 }
 
-/*
- * Assumptions made for PIFR 1.x to 2.x upgrade.
- *   1) pifr_file has been renamed to pifr_file_old.
- *   2) pifr_result has been renamed to pifr_result_old.
- *   3) pifr_server has been enabled.
- *   4) pifr_log has been renamed to pifr_log_old.
- *
- * The table renames can be achomplished by executing the following SQL.
- *   RENAME TABLE pifr_file TO pifr_file_old;
- *   RENAME TABLE pifr_result TO pifr_result_old;
- *   RENAME TABLE pifr_log TO pifr_log_old;
- *
- * Afterwards enable pifr_server to ensure that the new schema is installed
- * properly and does not conflict with the old schema.
- */
-
 /**
  * Remove old variables.
  */
@@ -72,22 +57,31 @@
 function pifr_update_6201() {
   $ret = array();
 
-  // Remove old server table since all clients will be re-added anyway.
-  db_drop_table($ret, 'pifr_server');
-
   // Rename old tables so new schema can be installed and data converted.
   db_rename_table($ret, 'pifr_file', 'pifr_file_old');
   db_rename_table($ret, 'pifr_result', 'pifr_result_old');
   db_rename_table($ret, 'pifr_log', 'pifr_log_old');
+  db_rename_table($ret, 'pifr_server', 'pifr_server_old');
 
-  // Install pifr_server schema.
+  // Install equivilent 2.x modules.
   include_once './includes/install.inc';
-  drupal_install_schema('pifr_server');
+  foreach (array('pifr_server', 'pifr_assertion', 'pifr_simpletest') as $module) {
+    drupal_install_modules(array($module));
+  }
+  module_list(TRUE);
 
   return $ret;
 }
 
 /**
+ * Migrate pifr_server.
+ *
+ */
+function pifr_update_6202() {
+
+}
+
+/**
  * Migrate pifr_file and pifr_result to new data structure.
  *
  * Assumes:
@@ -95,7 +89,7 @@
  *   2) pifr_result has been renamed to pifr_result_old.
  *   3) pifr_server has been enabled.
  */
-function pifr_update_6202(&$sandbox = NULL) {
+function pifr_update_6203(&$sandbox = NULL) {
   $ret = array();
 
   if (!isset($sandbox['progress'])) {
@@ -111,18 +105,17 @@
   while ($file_old = db_fetch_array($result)) {
     // Insert file record and create test record.
     $file = pifr_server_file_save(array(
-      'branch_id' => 1,
-      'issue_nid' => $file_old['nid'],
-      'issue_cid' => $file_old['cid'],
+      'branch_id' => 1, // Assume Drupal 7.x core branch will be branch ID 1.
+      'client_identifier' => $file_old['server_file_id'],
       'file_url' => 'http://drupal.org/files/issues/' . $file_old['filename'],
       'file_name' => $file_old['filename'],
+      'link' => 'http://drupal.org/node/' . $file_old['nid'] . ($file_old['cid'] ? '#comment-' . $file_old['cid'] : ''),
     ), FALSE);
 
     // Update test record with current state.
     $test = pifr_server_test_get($file['test_id']);
     pifr_server_test_save(array(
-      'status' => pifr_update_6202_status($file_old['status']),
-      'client_id' => 0, // Client will be re-created.
+      'status' => pifr_update_6203_status($file_old['status']),
       'last_recieved' => $file_old['received'],
       'last_requested' => $file_old['sent'],
       'last_tested' => $file_old['last_tested'],
@@ -132,13 +125,10 @@
     // Insert test result and details.
     $test_result = array(
       'test_id' => $test['test_id'],
-      'type' => 1, // PIFR_SERVER_CLIENT_ENVIRONMENT_MYSQL_5_0_ISAM
-      'code' => $code = pifr_update_6202_code($file_old),
-      'details' => serialize(pifr_update_6202_details($code, $file_old['message'])),
-      'pass' => $file_old['pass'],
-      'fail' => $file_old['fail'],
-      'exception' => $file_old['exception'],
-      'result_details' => array(),
+      'environment_id' => 1, // Assume MySQL ISAM will be environment ID 1.
+      'code' => $code = pifr_update_6203_code($file_old),
+      'details' => serialize(pifr_update_6203_details($code, $file_old)),
+      'data' => array(),
     );
 
     if ($test_result['code'] >= PIFR_SERVER_TEST_RESULT_FAIL) {
@@ -147,14 +137,13 @@
                                        FROM {pifr_result_old}
                                        WHERE file_id = %d', $file_old['file_id']);
       while ($file_result_detail = db_fetch_array($file_result_details)) {
-        $result_detail = array(
+        $test_result['data'][$file_result_detail['test_class']] = array(
           'test_name' => $file_result_detail['test_class'],
           'pass' => $file_result_detail['pass'],
           'fail' => $file_result_detail['fail'],
           'exception' => $file_result_detail['exception'],
           'assertions' => array(), // Assertion data is not collected in 1.x.
         );
-        $test_result['result_details'][] = $result_detail;
       }
     }
 
@@ -175,13 +164,13 @@
  * @param integer $status 1.x test status code.
  * @return integer 2.x test status code.
  */
-function pifr_update_6202_status($status) {
+function pifr_update_6203_status($status) {
   $map = array(
     1 => 2, // PIFR_FILE_QUEUED => PIFR_SERVER_TEST_STATUS_QUEUED.
-    2 => 4, // PIFR_FILE_SENT => PIFR_SERVER_TEST_STATUS_SENT.
-    3 => 5, // PIFR_FILE_ERROR => PIFR_SERVER_TEST_STATUS_RESULT.
-    4 => 5, // PIFR_FILE_TEST_FAIL => PIFR_SERVER_TEST_STATUS_RESULT.
-    5 => 5, // PIFR_FILE_TEST_PASS => PIFR_SERVER_TEST_STATUS_RESULT.
+    2 => 2, // PIFR_FILE_SENT => PIFR_SERVER_TEST_STATUS_QUEUED.
+    3 => 4, // PIFR_FILE_ERROR => PIFR_SERVER_TEST_STATUS_RESULT.
+    4 => 4, // PIFR_FILE_TEST_FAIL => PIFR_SERVER_TEST_STATUS_RESULT.
+    5 => 4, // PIFR_FILE_TEST_PASS => PIFR_SERVER_TEST_STATUS_RESULT.
   );
   return $map[$status];
 }
@@ -192,7 +181,7 @@
  * @param array $file 1.x file information.
  * @return integer 2.x test result code.
  */
-function pifr_update_6202_code(array $file) {
+function pifr_update_6203_code(array $file) {
   switch ($file['message']) {
     case 'Failed to fetch file.':
       return PIFR_SERVER_TEST_RESULT_FETCH;
@@ -220,22 +209,29 @@
  * Convert 1.x message to 2.x details array.
  *
  * @param integer $code 2.x test result code.
- * @param string $message 1.x message.
+ * @param array $file 1.x file information.
  * @return array 2.x details.
  */
-function pifr_update_6202_details($code, $message) {
+function pifr_update_6203_details($code, array $file) {
   switch ($code) {
     case 2: // PIFR_SERVER_TEST_RESULT_FETCH.
-      return array('@reason' => 'failed to retrieve file from project client');
+      return array('@reason' => 'failed to retrieve [' . $file['filename'] . '] from project client');
     case 3: // PIFR_SERVER_TEST_RESULT_CVS.
-     return array('@reason' => 'failed to checkout Drupal core');
+     return array('@reason' => 'failed to checkout from [:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal/drupal]');
     case 9: // PIFR_SERVER_TEST_RESULT_TEST.
-      return array('@reason' => 'failed to run tests');
+      return array('@reason' => 'failed during invocation of run-tests.sh');
     case 6: // PIFR_SERVER_TEST_RESULT_SYNTAX.
-      if (preg_match('/Invalid PHP syntax in (.*?)\.$/', $message, $match)) {
+      if (preg_match('/Invalid PHP syntax in (.*?)\.$/', $file['message'], $match)) {
         return array('@filename' => $match[1]);
       }
       return array('@filename' => 'unknown');
+    case 9: // PIFR_SERVER_TEST_RESULT_FAIL.
+    case 10: // PIFR_SERVER_TEST_RESULT_PASS.
+      return array(
+        '@pass' => $file_old['pass'],
+        '@fail' => $file_old['fail'],
+        '@exception' => $file_old['exception'],
+      );
   }
   return array();
 }
@@ -245,7 +241,7 @@
  *
  * Assumes pifr_server enabled.
  */
-function pifr_update_6203() {
+function pifr_update_6204() {
   $ret = array();
 
   pifr_server_client_save(array(
@@ -280,7 +276,7 @@
  *
  * Assumes pifr_log has been renamed to pifr_log_old.
  */
-function pifr_update_6204(&$sandbox = NULL) {
+function pifr_update_6205(&$sandbox = NULL) {
   $ret = array();
 
   if (!isset($sandbox['progress'])) {
@@ -295,7 +291,7 @@
                             ORDER BY log_id ASC', $sandbox['current_log_id'], 0, 10000);
   while ($log = db_fetch_array($result)) {
     db_query("INSERT INTO {pifr_log} (test_id, timestamp, message)
-              VALUES (%d, %d, '%s')", $log['file_id'], $log['timestamp'], pifr_update_6204_message($log['message']));
+              VALUES (%d, %d, '%s')", $log['file_id'], $log['timestamp'], pifr_update_6205_message($log['message']));
 
     $sandbox['progress']++;
     $sandbox['current_log_id'] = $log['log_id'];
@@ -312,7 +308,7 @@
  * @param string $message 1.x log message.
  * @return string 2.x log message.
  */
-function pifr_update_6204_message($message) {
+function pifr_update_6205_message($message) {
   switch ($message) {
     case 'Results sent to project server.':
       return 'Result retrieved by project client.';
@@ -334,12 +330,41 @@
 /**
  * Remove old tables.
  */
-function pifr_update_6205() {
+function pifr_update_6206() {
   $ret = array();
 
   db_drop_table($ret, 'pifr_file_old');
   db_drop_table($ret, 'pifr_result_old');
   db_drop_table($ret, 'pifr_log_old');
+  db_drop_table($ret, 'pifr_server_old');
 
   return $ret;
 }
+//
+///**
+// * Add title field to pifr_test and insert the appriopriate value.
+// */
+//function pifr_update_6207() {
+//  $ret = array();
+//
+//  // Add title field to pifr_test.
+//  $spec = array(
+//    'description' => t('Title representing the test.'),
+//    'type' => 'varchar',
+//    'not null' => TRUE,
+//    'length' => 256,
+//    'default' => '',
+//  );
+//  db_add_field($ret, 'pifr_test', 'title', $spec);
+//
+//  // Update all existing test records.
+//  $tests = db_query('SELECT test_id
+//                     FROM {pifr_test}');
+//  while ($test_id = db_result($tests)) {
+//    $test = pifr_server_test_get($test_id);
+//    $test['title'] = pifr_server_test_title($test['type'], $test);
+//    pifr_server_test_save($test);
+//  }
+//
+//  return $ret;
+//}
Index: server/pifr_server.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_review/server/pifr_server.install,v
retrieving revision 1.40
diff -u -r1.40 pifr_server.install
--- server/pifr_server.install	28 Oct 2009 04:12:12 -0000	1.40
+++ server/pifr_server.install	28 Oct 2009 07:08:34 -0000
@@ -64,6 +64,13 @@
         'default' => '',
         'serialize' => TRUE,
       ),
+      'link' => array(
+        'description' => t('Link to relevant information determined by project client.'),
+        'type' => 'varchar',
+        'not null' => TRUE,
+        'length' => 255,
+        'default' => '',
+      ),
     ),
     'indexes' => array(
       'test_id' => array('test_id'),
@@ -305,6 +312,13 @@
         'length' => 255,
         'default' => '',
       ),
+      'link' => array(
+        'description' => t('Link to relevant information determined by project client.'),
+        'type' => 'varchar',
+        'not null' => TRUE,
+        'length' => 255,
+        'default' => '',
+      ),
     ),
     'indexes' => array(
       'test_id' => array('test_id'),
@@ -394,6 +408,13 @@
         'length' => 255,
         'default' => '',
       ),
+      'link' => array(
+        'description' => t('Link to relevant information determined by project client.'),
+        'type' => 'varchar',
+        'not null' => TRUE,
+        'length' => 255,
+        'default' => '',
+      ),
     ),
     'indexes' => array(
       'client_identifier' => array('client_identifier'),
@@ -511,10 +532,8 @@
  * Implementation of hook_install().
  */
 function pifr_server_install() {
-  // Schema may have been installed during pifr update.
-  if (!db_table_exists('pifr_client')) {
-    drupal_install_schema('pifr_server');
-  }
+  // Install schema.
+  drupal_install_schema('pifr_server');
 
   // Set chart global background to transparent.
   variable_set('chart_global_bg', 'FFFFFF00');
@@ -535,31 +554,3 @@
   variable_del('pifr_server_client_project_interval');
   variable_del('pifr_server_client_test_interval');
 }
-
-/**
- * Add title field to pifr_test and insert the appriopriate value.
- */
-function pifr_server_update_6200() {
-  $ret = array();
-
-  // Add title field to pifr_test.
-  $spec = array(
-    'description' => t('Title representing the test.'),
-    'type' => 'varchar',
-    'not null' => TRUE,
-    'length' => 256,
-    'default' => '',
-  );
-  db_add_field($ret, 'pifr_test', 'title', $spec);
-
-  // Update all existing test records.
-  $tests = db_query('SELECT test_id
-                     FROM {pifr_test}');
-  while ($test_id = db_result($tests)) {
-    $test = pifr_server_test_get($test_id);
-    $test['title'] = pifr_server_test_title($test['type'], $test);
-    pifr_server_test_save($test);
-  }
-
-  return $ret;
-}
Index: server/pifr_server.review.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_review/server/pifr_server.review.inc,v
retrieving revision 1.4
diff -u -r1.4 pifr_server.review.inc
--- server/pifr_server.review.inc	28 Oct 2009 03:06:30 -0000	1.4
+++ server/pifr_server.review.inc	28 Oct 2009 07:08:34 -0000
@@ -104,6 +104,10 @@
   static $loaded = array();
 
   if (!isset($loaded[$plugin])) {
+    if (!module_exists($plugin)) {
+      trigger_error('Plugin [' . $plugin . '] does not exist.', E_USER_ERROR);
+    }
+
     require_once drupal_get_path('module', 'pifr') . '/review/server.inc';
     require_once drupal_get_path('module', $plugin) . '/' . $plugin . '.server.inc';
 
