소스 검색

Fixed confusing error message when running OBO loading jobs.

Lacey Sanderson 7 년 전
부모
커밋
c4d00fe54a
1개의 변경된 파일13개의 추가작업 그리고 2개의 파일을 삭제
  1. 13 2
      tripal/includes/TripalJob.inc

+ 13 - 2
tripal/includes/TripalJob.inc

@@ -29,8 +29,19 @@ class TripalJob {
    *   The ID of the job.
    */
   public function load($job_id) {
+
+    // Make sure we have a numeric job_id.
     if (!$job_id or !is_numeric($job_id)) {
-      throw new Exception("Must provide a numeric \$job_id to the tripal_cancel_job() function.");
+      // If we don't then do a quick double check in case this is a
+      // TripalJob object in which case, I still have the job_id.
+      if (is_object($job_id) AND is_a($job_id, 'TripalJob')) {
+        $job_id = $job_id->job->job_id;
+      }
+      // Finally just throw an exception.
+      // I can't load a job if I don't know which one.
+      else {
+        throw new Exception("You must provide the job_id to load the job.");
+      }
     }
 
     $sql = 'SELECT j.* FROM {tripal_jobs} j WHERE j.job_id = :job_id';
@@ -469,4 +480,4 @@ class TripalJob {
         $this->job->status = 'Error';
     }
   }
-}
+}