示例#1
0
文件: update.php 项目: xi67/MAB-LAB
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();
示例#2
0
文件: update.php 项目: xi67/MAB-LAB
for ($i = 0; $i <= 180; ++$i) {
    $mUpdateHelper->execSQL('INSERT INTO ' . DBHelper::getTblName(TBL_INCREMENTS) . '(' . INC_VALUE . ') VALUES (' . $i . ');');
}
// recreate issue keys with new algorithm
$mUpdateHelper->printStartNextStepMsg('Get reports');
$reports = DBHelper::selectRows(TBL_REPORTS, null, null, 'report_id, app_version_code, app_version_name, package_name, stack_trace, report_state, user_crash_date', null, null, false);
$mUpdateHelper->printStartNextStepMsg('Walk through reports array to create issues');
$issues = array();
try {
    foreach ($reports as $report) {
        $arr = explode("\n", $report[_STACK_TRACE]);
        $cause = $arr[0];
        // create a key to identify the issue from all reports
        $k = DBHelper::getReportIssueKey($report);
        if (!array_key_exists($k, $issues)) {
            $mUpdateHelper->printStepMsg('Create new issue ' . $k);
            $issues[$k] = array('reports' => array(), 'cause' => $cause, 'state' => $report[_REPORT_STATE], 'datetime' => $report[_CRASH_DATE]);
        }
        $issues[$k]['reports'][] = $report[_REPORT_ID];
        // check if state is different (if one report of the issue is archived or new then the issue is considered as archived or new)
        if ($issues[$k]['state'] != $report[_REPORT_STATE]) {
            switch ($report[_REPORT_STATE]) {
                case REPORT_STATE_ARCHIVED:
                    $issues[$k]['state'] = REPORT_STATE_ARCHIVED;
                    break;
                case REPORT_STATE_NEW:
                    $issues[$k]['state'] = REPORT_STATE_NEW;
                    break;
            }
        }
    }