Beispiel #1
0
define('DIRECT_ACCESS_CHECK', true);
define('BASE_PATH', '../../');
require_once '../updatehelper.php';
require_once BASE_PATH . 'includes/reporthelper.class.php';
$mUpdateHelper = new UpdateHelper();
$mUpdateHelper->begin();
$mUpdateHelper->applySQLUpdateFile();
$mUpdateHelper->exitOnError();
$mUpdateHelper->printStartNextStepMsg("Start updating issues table");
$succeeded = true;
$packages = DbHelper::selectRows(TBL_REPORTS, null, REPORT_PACKAGE_NAME, REPORT_ISSUE . ', ' . REPORT_PACKAGE_NAME, REPORT_ISSUE, null, false);
foreach ($packages as $package) {
    $issueId = $package[0];
    $packageName = $package[1];
    // skip empty package name
    if (strlen($packageName) == 0) {
        $mUpdateHelper->printStepMsg("Found empty package name !", true, false);
        continue;
    }
    $appId = DbHelper::fetchOrInsertApplication($packageName, ReportHelper::formatPackageName($packageName, true));
    if ($appId == -1) {
        $succeeded = false;
    }
    $mUpdateHelper->printStepMsg("Inserted application " . $packageName . ", id is " . $appId, $appId == -1, false);
    $mUpdateHelper->printStepMsg('Update issued #' . $issueId . ' with application id #' . $appId, false, false);
    DbHelper::exec('UPDATE ' . TBL_ISSUES . ' SET ' . ISSUE_APP_ID . '=' . $appId . ' WHERE ' . ISSUE_ID . '=' . $issueId, false);
}
$mUpdateHelper->printEndStepMsg($succeeded, null, false);
$mUpdateHelper->printEndStepMsg(true, null, true);
$mUpdateHelper->end();
Beispiel #2
0
}
$mUpdateHelper->exitOnError();
$mUpdateHelper->printStartNextStepMsg('Insert issues');
try {
    foreach ($issues as $k => $issue) {
        $values = array(ISSUE_KEY => $k, ISSUE_DATETIME => $issue['datetime'], ISSUE_CAUSE => $issue['cause'], ISSUE_STATE => $issue['state']);
        // check cause length (<255)
        if (strlen($values[ISSUE_CAUSE]) > 254) {
            $values[ISSUE_CAUSE] = substr($values[ISSUE_CAUSE], 0, 250) . '...';
        }
        // insert new issue
        $mUpdateHelper->printStartSubStepMsg('Insert issue ' . $k);
        $issueId = DBHelper::insertIssue($values);
        // update reports
        if ($issueId > 0) {
            $mUpdateHelper->printEndSubStepMsg(true);
            $mUpdateHelper->printStartSubStepMsg('Update reports in (' . implode(', ', $issue['reports']) . ') with issue id ' . $issueId);
            if (DBHelper::updateReportsIssue($issue['reports'], $issueId)) {
                $mUpdateHelper->printEndSubStepMsg(true);
            } else {
                $mUpdateHelper->printEndSubStepMsg(false);
            }
        } else {
            $mUpdateHelper->printEndSubStepMsg(false, DBHelper::getLastError());
        }
    }
} catch (Exception $e) {
    $mUpdateHelper->printStepMsg($e->getMessage(), true);
}
$mUpdateHelper->printEndStepMsg(true, null, true);
$mUpdateHelper->end();