Esempio n. 1
0
 function Insert()
 {
     $text = pdo_real_escape_string($this->Text);
     // Get this->Id from the database if text is already in the label table:
     $this->Id = pdo_get_field_value("SELECT id FROM label WHERE text='{$text}'", 'id', 0);
     // Or, if necessary, insert a new row, then get the id of the inserted row:
     if (0 == $this->Id) {
         $query = "INSERT INTO label (text) VALUES ('{$text}')";
         if (!pdo_query($query)) {
             add_last_sql_error('Label::Insert');
             return false;
         }
         $this->Id = pdo_insert_id('label');
     }
     // Insert relationship records, too, but only for those relationships
     // established by callers. (If coming from test.php, for example, TestId
     // will be set, but none of the others will. Similarly for other callers.)
     $this->InsertAssociation('label2build', 'buildid', $this->BuildId);
     $this->InsertAssociation('label2buildfailure', 'buildfailureid', $this->BuildFailureId);
     $this->InsertAssociation('label2coveragefile', 'buildid', $this->CoverageFileBuildId, 'coveragefileid', $this->CoverageFileId);
     $this->InsertAssociation('label2dynamicanalysis', 'dynamicanalysisid', $this->DynamicAnalysisId);
     $this->InsertAssociation('label2test', 'buildid', $this->TestBuildId, 'testid', $this->TestId);
     // TODO: Implement this:
     //
     //$this->InsertAssociation($this->UpdateFileKey,
     //  'label2updatefile', 'updatefilekey');
     return true;
 }
Esempio n. 2
0
 function Insert()
 {
     if (!$this->BuildId) {
         echo "BuildUserNote::Insert(): BuildId is not set<br>";
         return false;
     }
     if (!$this->UserId) {
         echo "BuildUserNote::Insert(): UserId is not set<br>";
         return false;
     }
     if (!$this->Note) {
         echo "BuildUserNote::Insert(): Note is not set<br>";
         return false;
     }
     if (!$this->TimeStamp) {
         echo "BuildUserNote::Insert(): TimeStamp is not set<br>";
         return false;
     }
     if (!$this->Status) {
         echo "BuildUserNote::Insert(): Status is not set<br>";
         return false;
     }
     $query = "INSERT INTO buildnote (buildid,userid,note,timestamp,status)\n              VALUES ('{$this->BuildId}','{$this->UserId}','{$this->Note}','{$this->TimeStamp}','{$this->Status}')";
     if (!pdo_query($query)) {
         add_last_sql_error("BuildUserNote Insert", 0, $this->BuildId);
         return false;
     }
     return true;
 }
Esempio n. 3
0
 /** Save in the database */
 public function Save()
 {
     if (!$this->BuildId) {
         echo 'BuildConfigureErrorDiff::Save(): BuildId not set';
         return false;
     }
     if ($this->Exists()) {
         // Update
         $query = 'UPDATE configureerrordiff SET';
         $query .= ' type=' . qnum($this->Type);
         $query .= ',difference=' . qnum($this->Difference);
         $query .= ' WHERE buildid=' . qnum($this->BuildId);
         if (!pdo_query($query)) {
             add_last_sql_error('BuildConfigureErrorDiff:Update', 0, $this->BuildId);
             return false;
         }
     } else {
         // insert
         $query = 'INSERT INTO configureerrordiff (buildid,type,difference)
              VALUES (' . qnum($this->BuildId) . ',' . qnum($this->Type) . ',' . qnum($this->Difference) . ')';
         if (!pdo_query($query)) {
             add_last_sql_error('BuildConfigureErrorDiff:Create', 0, $this->BuildId);
             return false;
         }
     }
     return true;
 }
Esempio n. 4
0
 function Insert()
 {
     if (!$this->BuildId) {
         echo "BuildTestDiff::Insert(): BuildId is not set<br>";
         return false;
     }
     if ($this->Type != 0 && empty($this->Type)) {
         echo "BuildTestDiff::Insert(): Type is not set<br>";
         return false;
     }
     if (!is_numeric($this->DifferenceNegative)) {
         echo "BuildTestDiff::Insert(): DifferenceNegative is not set<br>";
         return false;
     }
     if (!is_numeric($this->DifferencePositive)) {
         echo "BuildTestDiff::Insert(): DifferencePositive is not set<br>";
         return false;
     }
     $query = "INSERT INTO testdiff (buildid,type,difference_negative,difference_positive) \n              VALUES ('{$this->BuildId}','{$this->Type}','{$this->DifferenceNegative}','{$this->DifferencePositive}')";
     if (!pdo_query($query)) {
         add_last_sql_error("BuildTestDiff Insert", 0, $this->BuildId);
         return false;
     }
     return true;
 }
Esempio n. 5
0
 /** Save the group */
 public function Save()
 {
     if (!$this->DailyUpdateId) {
         echo 'DailyUpdateFile::Save(): DailyUpdateId not set!';
         return false;
     }
     if (!$this->Filename) {
         echo 'DailyUpdateFile::Save(): Filename not set!';
         return false;
     }
     if (!$this->CheckinDate) {
         echo 'DailyUpdateFile::Save(): CheckinDate not set!';
         return false;
     }
     if ($this->Exists()) {
         // Update the project
         $query = 'UPDATE dailyupdatefile SET';
         $query .= " checkindate='" . $this->CheckinDate . "'";
         $query .= ",author='" . $this->Author . "'";
         $query .= ",log='" . $this->Log . "'";
         $query .= ",revision='" . $this->Revision . "'";
         $query .= ",priorrevision='" . $this->PriorRevision . "'";
         $query .= " WHERE dailyupdateid='" . $this->DailyUpdateId . "' AND filename='" . $this->Filename . "'";
         if (!pdo_query($query)) {
             add_last_sql_error('DailyUpdateFile Update');
             return false;
         }
     } else {
         if (!pdo_query("INSERT INTO dailyupdatefile (dailyupdateid,filename,checkindate,author,log,revision,priorrevision)\n                     VALUES ('{$this->DailyUpdateId}','{$this->Filename}','{$this->CheckinDate}','{$this->Author}','{$this->Log}',\n                     '{$this->Revision}','{$this->PriorRevision}')")) {
             add_last_sql_error('DailyUpdateFile Insert');
             return false;
         }
     }
     return true;
 }
Esempio n. 6
0
 /** Update the content of the file */
 function Insert()
 {
     if (!$this->BuildId || !is_numeric($this->BuildId)) {
         add_log("BuildId not set", "CoverageFileLog::Insert()", LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId);
         return false;
     }
     if (!$this->FileId || !is_numeric($this->FileId)) {
         add_log("FileId not set", "CoverageFileLog::Insert()", LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId);
         return false;
     }
     $log = '';
     foreach ($this->Lines as $lineNumber => $code) {
         $log .= $lineNumber . ':' . $code . ';';
     }
     foreach ($this->Branches as $lineNumber => $code) {
         $log .= 'b' . $lineNumber . ':' . $code . ';';
     }
     if ($log != '') {
         $sql = "INSERT INTO coveragefilelog (buildid,fileid,log) VALUES ";
         $sql .= "(" . qnum($this->BuildId) . "," . qnum($this->FileId) . ",'" . $log . "')";
         pdo_query($sql);
         add_last_sql_error("CoverageFileLog::Insert()");
     }
     return true;
 }
Esempio n. 7
0
 function SetText($text)
 {
     if ($this->ProjectId == -1) {
         echo "Banner::SetText(): no ProjectId specified";
         return false;
     }
     $this->Text = pdo_real_escape_string($text);
     // Check if the project is already
     if ($this->Exists()) {
         // Update the project
         $query = "UPDATE banner SET";
         $query .= " text='" . $this->Text . "'";
         $query .= " WHERE projectid='" . $this->ProjectId . "'";
         if (!pdo_query($query)) {
             add_last_sql_error("Banner:SetText", $this->ProjectId);
             echo $query;
             return false;
         }
     } else {
         $query = "INSERT INTO banner (projectid,text)\n                VALUES (" . qnum($this->ProjectId) . ",'" . $this->Text . "')";
         if (!pdo_query($query)) {
             add_last_sql_error("Banner:SetText", $this->ProjectId);
             echo $query;
             return false;
         }
     }
     return true;
 }
Esempio n. 8
0
 /** Get the number of tests that are failing */
 function GetNumberOfFailures($checktesttiming, $testtimemaxstatus)
 {
     if (!$this->BuildId) {
         echo "BuildTest::GetNumberOfFailures(): BuildId not set";
         return false;
     }
     $sql = "SELECT testfailed,testnotrun,testtimestatusfailed FROM build WHERE id=" . qnum($this->BuildId);
     $query = pdo_query($sql);
     if (!$query) {
         add_last_sql_error("BuildTest:GetNumberOfFailures", 0, $this->BuildId);
         return false;
     }
     $nfail_array = pdo_fetch_array($query);
     $sumerrors = 0;
     if ($nfail_array['testfailed'] > 0) {
         $sumerrors += $nfail_array['testfailed'];
     }
     if ($nfail_array['testnotrun'] > 0) {
         $sumerrors += $nfail_array['testnotrun'];
     }
     // Find if the build has any test failings
     if ($checktesttiming) {
         if ($nfail_array['testtimestatusfailed'] > 0) {
             $sumerrors += $nfail_array['testtimestatusfailed'];
         }
     }
     return $sumerrors;
 }
Esempio n. 9
0
 /** Save in the database */
 function Save()
 {
     if (!$this->BuildId) {
         echo "BuildConfigureErrorDiff::Save(): BuildId not set";
         return false;
     }
     if ($this->Exists()) {
         // Update
         $query = "UPDATE configureerrordiff SET";
         $query .= " type=" . qnum($this->Type);
         $query .= ",difference=" . qnum($this->Difference);
         $query .= " WHERE buildid=" . qnum($this->BuildId);
         if (!pdo_query($query)) {
             add_last_sql_error("BuildConfigureErrorDiff:Update", 0, $this->BuildId);
             return false;
         }
     } else {
         $query = "INSERT INTO configureerrordiff (buildid,type,difference)\n                 VALUES (" . qnum($this->BuildId) . "," . qnum($this->Type) . "," . qnum($this->Difference) . ")";
         if (!pdo_query($query)) {
             add_last_sql_error("BuildConfigureErrorDiff:Create", 0, $this->BuildId);
             return false;
         }
     }
     return true;
 }
Esempio n. 10
0
 /** Get all the authors of a file */
 public function GetAuthors($filename, $onlylast = false)
 {
     if (!$this->ProjectId) {
         echo 'DailyUpdate::GetAuthors(): ProjectId is not set<br>';
         return false;
     }
     // Check if the note already exists
     $filename = pdo_real_escape_string($filename);
     // Remove
     if (substr($filename, 0, 2) == './') {
         $filename = substr($filename, 2);
     }
     $sql = '';
     if ($onlylast) {
         $sql = ' ORDER BY dailyupdate.id DESC LIMIT 1';
     }
     $query = pdo_query('SELECT DISTINCT up.userid,dailyupdate.id FROM user2project AS up,user2repository AS ur,dailyupdatefile,dailyupdate
                     WHERE dailyupdatefile.dailyupdateid=dailyupdate.id
                     AND dailyupdate.projectid=up.projectid
                     AND ur.credential=dailyupdatefile.author
                     AND up.projectid=' . qnum($this->ProjectId) . '
                     AND up.userid=ur.userid
                     AND (ur.projectid=0 OR ur.projectid=' . qnum($this->ProjectId) . ")\n                        AND dailyupdatefile.filename LIKE '%" . $filename . "'" . $sql);
     if (!$query) {
         add_last_sql_error('DailyUpdate GetAuthors', $this->ProjectId);
         return false;
     }
     $authorids = array();
     while ($query_array = pdo_fetch_array($query)) {
         $authorids[] = $query_array['userid'];
     }
     return $authorids;
 }
Esempio n. 11
0
/** Remove the first builds that are at the beginning of the queue */
function removeFirstBuilds($projectid, $days, $maxbuilds, $force = false)
{
    require 'config/config.php';
    require_once 'include/pdo.php';
    require_once 'include/common.php';
    @set_time_limit(0);
    if (!$force && !isset($CDASH_AUTOREMOVE_BUILDS)) {
        return;
    }
    if (!$force && $CDASH_AUTOREMOVE_BUILDS != '1') {
        return;
    }
    if ($days < 2) {
        return;
    }
    // First remove the builds with the wrong date
    $currentdate = time() - 3600 * 24 * $days;
    $startdate = date(FMT_DATETIME, $currentdate);
    add_log('about to query for builds to remove', 'removeFirstBuilds');
    $builds = pdo_query("SELECT id FROM build\n            WHERE parentid IN (0, -1) AND\n            starttime<'{$startdate}' AND\n            projectid=" . qnum($projectid) . "\n            ORDER BY starttime ASC LIMIT {$maxbuilds}");
    add_last_sql_error('dailyupdates::removeFirstBuilds');
    $buildids = array();
    while ($builds_array = pdo_fetch_array($builds)) {
        $buildids[] = $builds_array['id'];
    }
    $s = 'removing old buildids for projectid: ' . $projectid;
    add_log($s, 'removeFirstBuilds');
    echo '  -- ' . $s . "\n";
    // for "interactive" command line feedback
    remove_build($buildids);
    // Remove any job schedules that are older than our cutoff date
    // and not due to repeat again.
    require_once 'models/constants.php';
    require_once 'models/clientjobschedule.php';
    $sql = 'SELECT scheduleid FROM client_job AS cj
    LEFT JOIN client_jobschedule AS cjs ON cj.scheduleid = cjs.id
    WHERE cj.status > ' . CDASH_JOB_RUNNING . "\n    AND cjs.projectid={$projectid} AND cj.startdate < '{$startdate}'\n    AND (cjs.repeattime = 0.00 OR\n      (cjs.enddate < '{$startdate}' AND cjs.enddate != '1980-01-01 00:00:00'))";
    $job_schedules = pdo_query($sql);
    while ($job_schedule = pdo_fetch_array($job_schedules)) {
        $ClientJobSchedule = new ClientJobSchedule();
        $ClientJobSchedule->Id = $job_schedule['scheduleid'];
        $ClientJobSchedule->Remove();
    }
    // Remove any jobs that are older than our cutoff date.
    // This occurs when a job schedule is set to continue repeating, but
    // some of its past runs are older than our autoremove threshold.
    require_once 'models/clientjob.php';
    $sql = 'SELECT cj.id FROM client_job AS cj
    LEFT JOIN client_jobschedule AS cjs ON cj.scheduleid = cjs.id
    WHERE cj.status > ' . CDASH_JOB_RUNNING . "\n    AND cjs.projectid={$projectid} AND cj.startdate < '{$startdate}'";
    $jobs = pdo_query($sql);
    while ($job = pdo_fetch_array($jobs)) {
        $ClientJob = new ClientJob();
        $ClientJob->Id = $job['id'];
        $ClientJob->Remove();
    }
}
Esempio n. 12
0
 public function Insert()
 {
     $role = pdo_real_escape_string($this->Role);
     $query = "INSERT INTO test2image (imgid,testid,role)\n              VALUES ('{$this->Id}','{$this->TestId}','{$role}')";
     if (!pdo_query($query)) {
         add_last_sql_error('TestImage Insert');
         return false;
     }
     return true;
 }
Esempio n. 13
0
 /** Save the goup position */
 function Add()
 {
     if (!$this->Exists()) {
         if (!pdo_query("INSERT INTO buildgroupposition (buildgroupid,position,starttime,endtime)\n                     VALUES ('{$this->GroupId}','{$this->Position}','{$this->StartTime}','{$this->EndTime}')")) {
             add_last_sql_error("BuildGroupPosition Insert()");
             return false;
         }
         return true;
     }
     return false;
 }
Esempio n. 14
0
 function Insert()
 {
     $name = pdo_real_escape_string($this->Name);
     $type = pdo_real_escape_string($this->Type);
     $value = pdo_real_escape_string($this->Value);
     $query = "INSERT INTO testmeasurement (testid,name,type,value)\n              VALUES ('{$this->TestId}','{$name}','{$type}','{$value}')";
     if (!pdo_query($query)) {
         add_last_sql_error("TestMeasurement Insert");
         return false;
     }
     return true;
 }
Esempio n. 15
0
 /** Save the goup position */
 public function Add()
 {
     if (empty($this->GroupId) || empty($this->BuildType) || empty($this->BuildName) || empty($this->SiteId) || empty($this->Expected)) {
         return false;
     }
     if (!$this->Exists()) {
         if (!pdo_query("INSERT INTO build2grouprule (groupid,buildtype,buildname,siteid,expected,starttime,endtime)\n                     VALUES ('{$this->GroupId}','{$this->BuildType}','{$this->BuildName}','{$this->SiteId}','{$this->Expected}','{$this->StartTime}','{$this->EndTime}')")) {
             add_last_sql_error('BuildGroupRule Insert()');
             return false;
         }
         return true;
     }
     return false;
 }
Esempio n. 16
0
 function Insert()
 {
     if (strlen($this->DynamicAnalysisId) == 0) {
         echo "DynamicAnalysisDefect::Insert DynamicAnalysisId not set";
         return false;
     }
     $this->Type = pdo_real_escape_string($this->Type);
     $this->Value = pdo_real_escape_string($this->Value);
     $this->DynamicAnalysisId = pdo_real_escape_string($this->DynamicAnalysisId);
     $query = "INSERT INTO dynamicanalysisdefect (dynamicanalysisid,type,value)\n              VALUES (" . qnum($this->DynamicAnalysisId) . ",'{$this->Type}','{$this->Value}')";
     if (!pdo_query($query)) {
         add_last_sql_error("DynamicAnalysisDefect Insert");
         return false;
     }
     return true;
 }
Esempio n. 17
0
 /** Save the site information */
 function Save()
 {
     if ($this->OSName != "" || $this->OSPlatform != "" || $this->OSRelease != "" || $this->OSVersion != "") {
         if (empty($this->BuildId)) {
             return false;
         }
         // Check if we already have a buildinformation for that build. If yes we just skip it
         $query = pdo_query("SELECT buildid FROM buildinformation WHERE buildid=" . qnum($this->BuildId));
         add_last_sql_error("BuildInformation Insert", 0, $this->BuildId);
         if (pdo_num_rows($query) == 0) {
             pdo_query("INSERT INTO buildinformation (buildid,osname,osrelease,osversion,osplatform,compilername,compilerversion) \n                    VALUES (" . qnum($this->BuildId) . ",'{$this->OSName}','{$this->OSRelease}',\n                            '{$this->OSVersion}','{$this->OSPlatform}','{$this->CompilerName}','{$this->CompilerVersion}')");
             add_last_sql_error("BuildInformation Insert", 0, $this->BuildId);
         }
         return true;
     }
 }
Esempio n. 18
0
 public function Insert()
 {
     if (strlen($this->UpdateId) == 0) {
         echo 'BuildUpdateFile:Insert UpdateId not set';
         return false;
     }
     $this->Filename = pdo_real_escape_string($this->Filename);
     // Sometimes the checkin date is not found in that case we put the usual date
     if ($this->CheckinDate == 'Unknown') {
         $this->CheckinDate = '1980-01-01';
     }
     if (strtotime($this->CheckinDate) === false && is_numeric($this->CheckinDate)) {
         $this->CheckinDate = date(FMT_DATETIME, $this->CheckinDate);
     } elseif (strtotime($this->CheckinDate) !== false) {
         $this->CheckinDate = date(FMT_DATETIME, strtotime($this->CheckinDate));
     } else {
         $this->CheckinDate = '1980-01-01';
     }
     $this->Author = pdo_real_escape_string($this->Author);
     $this->UpdateId = pdo_real_escape_string($this->UpdateId);
     // Check if we have a robot file for this build
     $robot = pdo_query('SELECT authorregex FROM projectrobot,build,build2update
             WHERE projectrobot.projectid=build.projectid
             AND build2update.buildid=build.id
             AND build2update.updateid=' . qnum($this->UpdateId) . " AND robotname='" . $this->Author . "'");
     if (pdo_num_rows($robot) > 0) {
         $robot_array = pdo_fetch_array($robot);
         $regex = $robot_array['authorregex'];
         preg_match($regex, $this->Log, $matches);
         if (isset($matches[1])) {
             $this->Author = $matches[1];
         }
     }
     $this->Email = pdo_real_escape_string($this->Email);
     $this->Committer = pdo_real_escape_string($this->Committer);
     $this->CommitterEmail = pdo_real_escape_string($this->CommitterEmail);
     $this->Log = pdo_real_escape_string($this->Log);
     $this->Revision = pdo_real_escape_string($this->Revision);
     $this->PriorRevision = pdo_real_escape_string($this->PriorRevision);
     $query = 'INSERT INTO updatefile (updateid,filename,checkindate,author,email,log,revision,priorrevision,status,committer,committeremail)
           VALUES (' . qnum($this->UpdateId) . ",'{$this->Filename}','{$this->CheckinDate}','{$this->Author}','{$this->Email}',\n                      '{$this->Log}','{$this->Revision}','{$this->PriorRevision}','{$this->Status}','{$this->Committer}','{$this->CommitterEmail}')";
     if (!pdo_query($query)) {
         add_last_sql_error('BuildUpdateFile Insert', 0, $this->UpdateId);
         return false;
     }
 }
Esempio n. 19
0
 /** Return the name of a build */
 function GetFiles()
 {
     if (!$this->BuildId) {
         echo "Coverage GetFiles(): BuildId not set";
         return false;
     }
     $fileids = array();
     $coverage = pdo_query("SELECT fileid FROM coverage WHERE buildid=" . qnum($this->BuildId));
     if (!$coverage) {
         add_last_sql_error("Coverage GetFiles");
         return false;
     }
     while ($coverage_array = pdo_fetch_array($coverage)) {
         $fileids[] = $coverage_array['fileid'];
     }
     return $fileids;
 }
Esempio n. 20
0
 public function Insert()
 {
     $row = pdo_single_row_query('SELECT COUNT(1) FROM coveragesummarydiff
             WHERE buildid=' . qnum($this->BuildId));
     if ($row[0] > 0) {
         // UPDATE instead of INSERT if a row already exists.
         pdo_query('UPDATE coveragesummarydiff SET
                 loctested=' . qnum($this->LocTested) . ',
                 locuntested=' . qnum($this->LocUntested) . '
                 WHERE buildid=' . qnum($this->BuildId));
     } else {
         pdo_query('INSERT INTO coveragesummarydiff
                 (buildid,loctested,locuntested)
                 VALUES
                 (' . qnum($this->BuildId) . ',' . qnum($this->LocTested) . ',' . qnum($this->LocUntested) . ')');
     }
     add_last_sql_error('CoverageSummary:ComputeDifference');
 }
Esempio n. 21
0
 /** Save a site */
 function Save()
 {
     $name = $this->GetNameFromPlatform($this->Name);
     $version = $this->GetNameFromVersion($this->Version);
     if (strlen($name) == 0) {
         return false;
     }
     // Check if the name and bits system already exists
     $query = pdo_query("SELECT id FROM client_os WHERE name='" . $name . "' AND version='" . $version . "' AND bits='" . $this->Bits . "'");
     if (pdo_num_rows($query) == 0) {
         $sql = "INSERT INTO client_os (name,version,bits) \n              VALUES ('" . $name . "','" . $version . "','" . $this->Bits . "')";
         pdo_query($sql);
         $this->Id = pdo_insert_id('client_os');
         add_last_sql_error("ClientOS::Save()");
     } else {
         $query_array = pdo_fetch_array($query);
         $this->Id = $query_array['id'];
     }
 }
Esempio n. 22
0
 public function Insert()
 {
     if (!$this->BuildId) {
         echo 'BuildError::Insert(): BuildId not set<br>';
         return false;
     }
     $text = pdo_real_escape_string($this->Text);
     if (strlen($this->PreContext) == 0) {
         $precontext = 'NULL';
     } else {
         $precontext = "'" . pdo_real_escape_string($this->PreContext) . "'";
     }
     if (strlen($this->PostContext) == 0) {
         $postcontext = 'NULL';
     } else {
         $postcontext = "'" . pdo_real_escape_string($this->PostContext) . "'";
     }
     if (empty($this->SourceLine)) {
         $this->SourceLine = 0;
     }
     if (empty($this->RepeatCount)) {
         $this->RepeatCount = 0;
     }
     $crc32 = 0;
     // Compute the crc32
     if ($this->SourceLine == 0) {
         $crc32 = crc32($text);
         // no need for precontext or postcontext, this doesn't work for parallel build
     } else {
         $crc32 = crc32($text . $this->SourceFile . $this->SourceLine);
         // some warning can be on the same line
     }
     $query = 'INSERT INTO builderror (buildid,type,logline,text,sourcefile,sourceline,precontext,
                                   postcontext,repeatcount,newstatus,crc32)
           VALUES (' . qnum($this->BuildId) . ',' . qnum($this->Type) . ',' . qnum($this->LogLine) . ",'{$text}','{$this->SourceFile}'," . qnum($this->SourceLine) . ',
           ' . $precontext . ',' . $postcontext . ',' . qnum($this->RepeatCount) . ',0,' . qnum($crc32) . ')';
     if (!pdo_query($query)) {
         add_last_sql_error('BuildError Insert', 0, $this->BuildId);
         return false;
     }
     return true;
 }
Esempio n. 23
0
 /** Save in the database */
 function Save()
 {
     if (!$this->BuildId || !is_numeric($this->BuildId)) {
         echo "BuildConfigureError::Save(): BuildId not set";
         return false;
     }
     if (!$this->Type || !is_numeric($this->Type)) {
         echo "BuildConfigureError::Save(): Type not set";
         return false;
     }
     if (!$this->Exists()) {
         $text = pdo_real_escape_string($this->Text);
         $query = "INSERT INTO configureerror (buildid,type,text)\n                VALUES (" . qnum($this->BuildId) . "," . qnum($this->Type) . ",'{$text}')";
         if (!pdo_query($query)) {
             add_last_sql_error("BuildConfigureError:Save", 0, $this->BuildId);
             return false;
         }
     }
     return true;
 }
Esempio n. 24
0
 public function testRecoverPassword()
 {
     $this->login();
     $this->get($this->url . '/recoverPassword.php');
     if (strpos($this->getBrowser()->getContentAsText(), 'your email address') === false) {
         $this->fail("'your email address' not found when expected.");
         return 1;
     }
     if (!$this->setFieldByName('email', 'simpletest@localhost')) {
         $this->fail('Failed to set email');
         return 1;
     }
     if (!$this->clickSubmitByName('recover')) {
         $this->fail('clicking recover returned false');
     }
     //fix the password so others can still login...
     $md5pass = md5('simpletest');
     pdo_query('UPDATE ' . qid('user') . " SET password='******' WHERE email='simpletest@localhost'");
     add_last_sql_error('test_recoverpassword');
     $this->pass('Passed');
 }
Esempio n. 25
0
 function testRecoverPassword()
 {
     $this->login();
     $this->get($this->url . "/recoverPassword.php");
     if (strpos($this->getBrowser()->getContentAsText(), "your email address") === false) {
         $this->fail("'your email address' not found when expected.");
         return 1;
     }
     if (!$this->setFieldByName("email", "simpletest@localhost")) {
         $this->fail("Failed to set email");
         return 1;
     }
     if (!$this->clickSubmitByName("recover")) {
         $this->fail("clicking recover returned false");
     }
     //fix the password so others can still login...
     $md5pass = md5("simpletest");
     pdo_query("UPDATE " . qid("user") . " SET password='******' WHERE email='simpletest@localhost'");
     add_last_sql_error("test_recoverpassword");
     $this->pass("Passed");
 }
Esempio n. 26
0
 /** Update the content of the file */
 public function Insert($append = false)
 {
     if (!$this->BuildId || !is_numeric($this->BuildId)) {
         add_log('BuildId not set', 'CoverageFileLog::Insert()', LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId);
         return false;
     }
     if (!$this->FileId || !is_numeric($this->FileId)) {
         add_log('FileId not set', 'CoverageFileLog::Insert()', LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId);
         return false;
     }
     pdo_begin_transaction();
     $update = false;
     if ($append) {
         // Load any previously existing results for this file & build.
         $update = $this->Load(true);
     }
     $log = '';
     foreach ($this->Lines as $lineNumber => $code) {
         $log .= $lineNumber . ':' . $code . ';';
     }
     foreach ($this->Branches as $lineNumber => $code) {
         $log .= 'b' . $lineNumber . ':' . $code . ';';
     }
     if ($log != '') {
         if ($update) {
             $sql_command = 'UPDATE';
             $sql = "UPDATE coveragefilelog SET log='{$log}'\n                WHERE buildid=" . qnum($this->BuildId) . ' AND
             fileid=' . qnum($this->FileId);
         } else {
             $sql_command = 'INSERT';
             $sql = 'INSERT INTO coveragefilelog (buildid,fileid,log) VALUES ';
             $sql .= '(' . qnum($this->BuildId) . ',' . qnum($this->FileId) . ",'" . $log . "')";
         }
         pdo_query($sql);
         add_last_sql_error("CoverageFileLog::{$sql_command}()");
     }
     pdo_commit();
     $this->UpdateAggregate();
     return true;
 }
Esempio n. 27
0
 public function Insert()
 {
     if (!isset($this->BuildId) || $this->BuildId < 1) {
         add_log('BuildId is not set', 'BuildUserNote::Insert()', LOG_ERR);
         return false;
     }
     if (!isset($this->UserId) || $this->UserId < 1) {
         add_log('UserId is not set', 'BuildUserNote::Insert()', LOG_ERR, 0, $this->BuildId);
         return false;
     }
     if (!isset($this->Note)) {
         add_log('Note is not set', 'BuildUserNote::Insert()', LOG_ERR, 0, $this->BuildId);
         return false;
     }
     if (!isset($this->TimeStamp)) {
         add_log('TimeStamp is not set', 'BuildUserNote::Insert()', LOG_ERR, 0, $this->BuildId);
         return false;
     }
     if (!isset($this->Status)) {
         add_log('Status is not set', 'BuildUserNote::Insert()', LOG_ERR, 0, $this->BuildId);
         return false;
     }
     $pdo = get_link_identifier()->getPdo();
     $stmt = $pdo->prepare('INSERT INTO buildnote
             (buildid, userid, note, timestamp, status)
             VALUES
             (:buildid, :userid, :TextNote, :now, :Status)');
     $stmt->bindParam(':buildid', $this->BuildId);
     $stmt->bindParam(':userid', $this->UserId);
     $stmt->bindParam(':TextNote', $this->Note);
     $stmt->bindParam(':now', $this->TimeStamp);
     $stmt->bindParam(':Status', $this->Status);
     if (!$stmt->execute()) {
         add_last_sql_error('BuildUserNote Insert', 0, $this->BuildId);
         return false;
     }
     return true;
 }
Esempio n. 28
0
 public function Save()
 {
     if (!$this->BuildId || !is_numeric($this->BuildId)) {
         echo 'BuildErrorDiff::Save(): BuildId not set<br>';
         return false;
     }
     if (!$this->Type || !is_numeric($this->Type)) {
         echo 'BuildErrorDiff::Save(): Type not set<br>';
         return false;
     }
     if (!$this->DifferencePositive || !is_numeric($this->DifferencePositive)) {
         echo 'BuildErrorDiff::Save(): DifferencePositive not set<br>';
         return false;
     }
     if (!$this->DifferenceNegative || !is_numeric($this->DifferenceNegative)) {
         echo 'BuildErrorDiff::Save(): DifferenceNegative not set<br>';
         return false;
     }
     if ($this->Exists()) {
         // Update
         $query = 'UPDATE builderrordiff SET ';
         $query .= "difference_positive='" . $this->DifferencePositive . "'";
         $query .= ", difference_negative='" . $this->DifferenceNegative . "'";
         $query .= " WHERE buildid='" . $this->BuildId . "' AND type='" . $this->Type . "'";
         if (!pdo_query($query)) {
             add_last_sql_error('BuildErrorDiff Update', 0, $this->BuildId);
             return false;
         }
     } else {
         // insert
         $query = "INSERT INTO builderrordiff (buildid,type,difference_positive,difference_negative)\n                 VALUES ('" . $this->BuildId . "','" . $this->Type . "','" . $this->DifferencePositive . "','" . $this->DifferenceNegative . "')";
         if (!pdo_query($query)) {
             add_last_sql_error('BuildErrorDiff Create', 0, $this->BuildId);
             return false;
         }
     }
     return true;
 }
Esempio n. 29
0
 function Insert()
 {
     if (!$this->BuildId) {
         echo "BuildFile::Insert(): BuildId not set<br>";
         return false;
     }
     if (!$this->Type) {
         echo "BuildFile::Insert(): Type not set<br>";
         return false;
     }
     if (!$this->md5) {
         echo "BuildFile::Insert(): md5 not set<br>";
         return false;
     }
     if (!$this->Filename) {
         echo "BuildFile::Insert(): Filename not set<br>";
         return false;
     }
     $filename = pdo_real_escape_string($this->Filename);
     $type = pdo_real_escape_string($this->Type);
     $md5 = pdo_real_escape_string($this->md5);
     // Check if we already have a row
     $query = "SELECT buildid FROM buildfile WHERE buildid=" . qnum($this->BuildId) . " AND md5='" . $md5 . "'";
     $query_result = pdo_query($query);
     if (!$query_result) {
         add_last_sql_error("BuildFile Insert", 0, $this->BuildId);
         return false;
     }
     if (pdo_num_rows($query_result) > 0) {
         return false;
     }
     $query = "INSERT INTO buildfile (buildid,type,filename,md5)\n              VALUES (" . qnum($this->BuildId) . ",'" . $type . "','" . $filename . "','" . $md5 . "')";
     if (!pdo_query($query)) {
         add_last_sql_error("BuildFile Insert", 0, $this->BuildId);
         return false;
     }
     return true;
 }
Esempio n. 30
0
 public function Fill()
 {
     if (!$this->Id) {
         add_log('Id not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         return false;
     }
     $query = pdo_query("SELECT filename, filesize, sha1sum, isurl FROM uploadfile WHERE id='{$this->Id}'");
     if (!$query) {
         add_last_sql_error('Uploadfile::Fill', 0, $this->Id);
         return false;
     }
     if (pdo_num_rows($query) > 0) {
         $fileArray = pdo_fetch_array($query);
         $this->Sha1Sum = $fileArray['sha1sum'];
         $this->Filename = $fileArray['filename'];
         $this->Filesize = $fileArray['filesize'];
         $this->IsUrl = $fileArray['isurl'];
     } else {
         add_log('Invalid id', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         return false;
     }
     return true;
 }