check_patch_exists

Definition

check_patch_exists($patch_url, $node_id)
simpletestauto.module, line 398

Description

Function checks if same patch was already tested. If it was it marks it obsolete. If it wasnt yet tested we remove it from testing queue and mark it obsolete. Instead of link to test site we provide link to new test.

Parameters

$patch_url url of new patch that we are checking for @param $node_id id of new node

Code

<?php
function check_patch_exists($patch_url, $node_id) {
  $sql = "SELECT nid FROM {simpletestauto_test} WHERE patch_url = '%s' AND nid <> %d";
  $nodes = db_query($sql, $patch_url, $node_id);
  while ($node = db_fetch_object($nodes)) {
    $node = node_load($node->nid);
    
    //If test is not yet obsolete we need to cleanup on test server side
    if ($node->test_status != SIMPLETESTAUTO_OBSOLETE) {
      clean_up($node->site_url);
      
      $node->site_url = '';
      $node->test_status = SIMPLETESTAUTO_OBSOLETE;
    }
    $node->body = t('This test is obsolete which means that same patch reentered testing. You can check latest test results here !url', array('!url' => url('node/' . $node_id, NULL, NULL, TRUE)));
    $node->revision = 1;
    node_save($node);
  }
}
?>