本文整理汇总了PHP中exit_with_error函数的典型用法代码示例。如果您正苦于以下问题:PHP exit_with_error函数的具体用法?PHP exit_with_error怎么用?PHP exit_with_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exit_with_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main($post_data)
{
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
$report = json_decode($post_data, true);
verify_slave($db, $report);
$commits = array_get($report, 'commits', array());
foreach ($commits as $commit_info) {
if (!array_key_exists('repository', $commit_info)) {
exit_with_error('MissingRepositoryName', array('commit' => $commit_info));
}
if (!array_key_exists('revision', $commit_info)) {
exit_with_error('MissingRevision', array('commit' => $commit_info));
}
require_format('Revision', $commit_info['revision'], '/^[A-Za-z0-9 \\.]+$/');
if (array_key_exists('author', $commit_info) && !is_array($commit_info['author'])) {
exit_with_error('InvalidAuthorFormat', array('commit' => $commit_info));
}
}
$db->begin_transaction();
foreach ($commits as $commit_info) {
$repository_id = $db->select_or_insert_row('repositories', 'repository', array('name' => $commit_info['repository']));
if (!$repository_id) {
$db->rollback_transaction();
exit_with_error('FailedToInsertRepository', array('commit' => $commit_info));
}
$author = array_get($commit_info, 'author');
$committer_id = NULL;
if ($author) {
$account = array_get($author, 'account');
$committer_query = array('repository' => $repository_id, 'account' => $account);
$committer_data = $committer_query;
$name = array_get($author, 'name');
if ($name) {
$committer_data['name'] = $name;
}
$committer_id = $db->update_or_insert_row('committers', 'committer', $committer_query, $committer_data);
if (!$committer_id) {
$db->rollback_transaction();
exit_with_error('FailedToInsertCommitter', array('committer' => $committer_data));
}
}
$parent_revision = array_get($commit_info, 'parent');
$parent_id = NULL;
if ($parent_revision) {
$parent_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $parent_revision));
if (!$parent_commit) {
$db->rollback_transaction();
exit_with_error('FailedToFindParentCommit', array('commit' => $commit_info));
}
$parent_id = $parent_commit['commit_id'];
}
$data = array('repository' => $repository_id, 'revision' => $commit_info['revision'], 'parent' => $parent_id, 'order' => array_get($commit_info, 'order'), 'time' => array_get($commit_info, 'time'), 'committer' => $committer_id, 'message' => array_get($commit_info, 'message'), 'reported' => true);
$db->update_or_insert_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $data['revision']), $data);
}
$db->commit_transaction();
exit_with_success();
}
示例2: main
function main($path)
{
if (count($path) > 1) {
exit_with_error('InvalidRequest');
}
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
$task_id = array_get($_GET, 'task');
$query = array();
if ($task_id) {
$triggerable = find_triggerable_for_task($db, $task_id);
if (!$triggerable) {
exit_with_error('TriggerableNotFoundForTask', array('task' => $task_id));
}
$query['id'] = $triggerable['id'];
}
$id_to_triggerable = array();
foreach ($db->select_rows('build_triggerables', 'triggerable', $query) as $row) {
$id = $row['triggerable_id'];
$repositories = array();
$id_to_triggerable[$id] = array('id' => $id, 'name' => $row['triggerable_name'], 'acceptedRepositories' => &$repositories);
}
foreach ($db->select_rows('triggerable_repositories', 'trigrepo', array()) as $row) {
$triggerable = array_get($id_to_triggerable, $row['trigrepo_triggerable']);
if ($triggerable) {
array_push($triggerable['acceptedRepositories'], $row['trigrepo_repository']);
}
}
exit_with_success(array('triggerables' => array_values($id_to_triggerable)));
}
示例3: main
function main($post_data)
{
set_exit_detail('failureStored', false);
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
// Convert all floating points to strings to avoid parsing them in PHP.
// FIXME: Do this conversion in the submission scripts themselves.
$parsed_json = json_decode(preg_replace('/(?<=[\\s,\\[])(\\d+(\\.\\d+)?)(\\s*[,\\]])/', '"$1"$3', $post_data), true);
if (!$parsed_json) {
exit_with_error('FailedToParseJSON');
}
set_exit_detail('processedRuns', 0);
foreach ($parsed_json as $i => $report) {
$processor = new ReportProcessor($db);
$processor->process($report);
set_exit_detail('processedRuns', $i + 1);
}
$generator = new ManifestGenerator($db);
if (!$generator->generate()) {
exit_with_error('FailedToGenerateManifest');
} else {
if (!$generator->store()) {
exit_with_error('FailedToStoreManifest');
}
}
exit_with_success();
}
示例4: commit_sets_from_root_sets
function commit_sets_from_root_sets($db, $root_sets)
{
$repository_name_to_id = array();
foreach ($db->fetch_table('repositories') as $row) {
$repository_name_to_id[$row['repository_name']] = $row['repository_id'];
}
$commit_sets = array();
foreach ($root_sets as $repository_name => $revisions) {
$repository_id = array_get($repository_name_to_id, $repository_name);
if (!$repository_id) {
exit_with_error('RepositoryNotFound', array('name' => $repository_name));
}
foreach ($revisions as $i => $revision) {
$commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $revision));
if (!$commit) {
exit_with_error('RevisionNotFound', array('repository' => $repository_name, 'revision' => $revision));
}
array_set_default($commit_sets, $i, array());
array_push($commit_sets[$i], $commit['commit_id']);
}
}
$commit_count_per_set = count($commit_sets[0]);
foreach ($commit_sets as $commits) {
if ($commit_count_per_set != count($commits)) {
exit_with_error('InvalidRootSets', array('rootSets' => $root_sets));
}
}
return $commit_sets;
}
示例5: main
function main()
{
$data = ensure_privileged_api_data_and_token();
$test_group_id = array_get($data, 'group');
if (!$test_group_id) {
exit_with_error('TestGroupNotSpecified');
}
$values = array();
if (array_key_exists('name', $data)) {
$values['name'] = $data['name'];
}
if (array_key_exists('hidden', $data)) {
$values['hidden'] = Database::to_database_boolean($data['hidden']);
}
if (!$values) {
exit_with_error('NothingToUpdate');
}
$db = connect();
$db->begin_transaction();
if (!$db->update_row('analysis_test_groups', 'testgroup', array('id' => $test_group_id), $values)) {
$db->rollback_transaction();
exit_with_error('FailedToUpdateTestGroup', array('id' => $test_group_id, 'values' => $values));
}
if (array_get($data, 'hidden')) {
$db->query_and_get_affected_rows('UPDATE build_requests SET request_status = $1
WHERE request_group = $2 AND request_status = $3', array('canceled', $test_group_id, 'pending'));
}
$db->commit_transaction();
exit_with_success();
}
示例6: main
function main()
{
$data = ensure_privileged_api_data_and_token();
$analysis_task_id = array_get($data, 'task');
$bug_tracker_id = array_get($data, 'bugTracker');
$bug_number = array_get($data, 'number');
$bug_id = array_get($data, 'bugToDelete');
$db = connect();
$db->begin_transaction();
if ($bug_id) {
require_format('BugToDelete', $bug_id, '/^\\d+$/');
$count = $db->query_and_get_affected_rows("DELETE FROM bugs WHERE bug_id = \$1", array($bug_id));
if ($count != 1) {
$db->rollback_transaction();
exit_with_error('UnexpectedNumberOfAffectedRows', array('affectedRows' => $count));
}
} else {
require_format('AnalysisTask', $analysis_task_id, '/^\\d+$/');
require_format('BugTracker', $bug_tracker_id, '/^\\d+$/');
require_format('BugNumber', $bug_number, '/^\\d+$/');
$bug_id = $db->insert_row('bugs', 'bug', array('task' => $analysis_task_id, 'tracker' => $bug_tracker_id, 'number' => $bug_number));
}
$db->commit_transaction();
exit_with_success(array('bugId' => $bug_id));
}
示例7: fetch_and_push_bugs_to_tasks
function fetch_and_push_bugs_to_tasks($db, &$tasks)
{
$task_ids = array();
$task_by_id = array();
foreach ($tasks as &$task) {
array_push($task_ids, $task['id']);
$task_by_id[$task['id']] =& $task;
}
$bugs = $db->query_and_fetch_all('SELECT bug_id AS "id", bug_task AS "task", bug_tracker AS "bugTracker", bug_number AS "number"
FROM bugs WHERE bug_task = ANY ($1)', array('{' . implode(', ', $task_ids) . '}'));
if (!is_array($bugs)) {
exit_with_error('FailedToFetchBugs');
}
foreach ($bugs as $bug) {
$associated_task =& $task_by_id[$bug['task']];
array_push($associated_task['bugs'], $bug['id']);
}
$task_build_counts = $db->query_and_fetch_all('SELECT
testgroup_task AS "task",
count(testgroup_id) as "total",
sum(case when request_status = \'failed\' or request_status = \'completed\' then 1 else 0 end) as "finished"
FROM analysis_test_groups, build_requests
WHERE request_group = testgroup_id AND testgroup_task = ANY($1) GROUP BY testgroup_task', array('{' . implode(', ', $task_ids) . '}'));
if (!is_array($task_build_counts)) {
exit_with_error('FailedToFetchTestGroups');
}
foreach ($task_build_counts as $build_count) {
$task =& $task_by_id[$build_count['task']];
$task['buildRequestCount'] = $build_count['total'];
$task['finishedBuildRequestCount'] = $build_count['finished'];
}
return $bugs;
}
示例8: main
function main()
{
$program_start_time = microtime(true);
$arguments = validate_arguments($_GET, array('platform' => 'int', 'metric' => 'int', 'testGroup' => 'int?', 'startTime' => 'int?', 'endTime' => 'int?'));
$platform_id = $arguments['platform'];
$metric_id = $arguments['metric'];
$start_time = $arguments['startTime'];
$end_time = $arguments['endTime'];
if (!!$start_time != !!$end_time) {
exit_with_error('InvalidTimeRange', array('startTime' => $start_time, 'endTime' => $end_time));
}
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
$fetcher = new MeasurementSetFetcher($db);
if (!$fetcher->fetch_config_list($platform_id, $metric_id)) {
exit_with_error('ConfigurationNotFound', array('platform' => $platform_id, 'metric' => $metric_id));
}
$cluster_count = 0;
while (!$fetcher->at_end()) {
$content = $fetcher->fetch_next_cluster();
$cluster_count++;
if ($fetcher->at_end()) {
$cache_filename = "measurement-set-{$platform_id}-{$metric_id}.json";
$content['clusterCount'] = $cluster_count;
$content['elapsedTime'] = (microtime(true) - $program_start_time) * 1000;
} else {
$cache_filename = "measurement-set-{$platform_id}-{$metric_id}-{$content['endTime']}.json";
}
$json = success_json($content);
generate_data_file($cache_filename, $json);
}
echo $json;
}
示例9: ensure_config_from_runs
function ensure_config_from_runs($db, $start_run, $end_run)
{
$range = array('startRun' => $start_run, 'endRun' => $end_run);
if ($start_run['run_config'] != $end_run['run_config']) {
exit_with_error('RunConfigMismatch', $range);
}
return ensure_row_by_id($db, 'test_configurations', 'config', $start_run['run_config'], 'ConfigNotFound', $range);
}
示例10: main
function main($paths)
{
if (count($paths) < 1 || count($paths) > 2) {
exit_with_error('InvalidRequest');
}
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
$fetcher = new CommitLogFetcher($db);
if (!is_numeric($paths[0])) {
$repository_id = $fetcher->repository_id_from_name($paths[0]);
if (!$repository_id) {
exit_with_error('RepositoryNotFound', array('repositoryName' => $paths[0]));
}
} else {
$repository_id = intval($paths[0]);
}
$filter = array_get($paths, 1);
$commits = array();
if (!$filter) {
$keyword = array_get($_GET, 'keyword');
$from = array_get($_GET, 'from');
$to = array_get($_GET, 'to');
$commits = $fetcher->fetch_between($repository_id, $from, $to, $keyword);
} else {
if ($filter == 'oldest') {
$commits = $fetcher->fetch_oldest($repository_id);
} else {
if ($filter == 'latest') {
$commits = $fetcher->fetch_latest($repository_id);
} else {
if ($filter == 'last-reported') {
$commits = $fetcher->fetch_last_reported($repository_id);
} else {
if (ctype_alnum($filter)) {
$commits = $fetcher->fetch_revision($repository_id, $filter);
} else {
$matches = array();
if (!preg_match('/([A-Za-z0-9]+)[\\:\\-]([A-Za-z0-9]+)/', $filter, $matches)) {
exit_with_error('UnknownFilter', array('repositoryName' => $repository_name, 'filter' => $filter));
}
$commits = $fetcher->fetch_between($repository_id, $matches[1], $matches[2]);
}
}
}
}
}
if (!is_array($commits)) {
exit_with_error('FailedToFetchCommits', array('repository' => $repository_id, 'filter' => $filter));
}
exit_with_success(array('commits' => $commits));
}
示例11: main
function main($path)
{
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
if (count($path) > 1) {
exit_with_error('InvalidRequest');
}
$build_requests_fetcher = new BuildRequestsFetcher($db);
if (count($path) > 0 && $path[0]) {
$group_id = intval($path[0]);
$group = $db->select_first_row('analysis_test_groups', 'testgroup', array('id' => $group_id));
if (!$group) {
exit_with_error('GroupNotFound', array('id' => $group_id));
}
$test_groups = array($group);
$build_requests_fetcher->fetch_for_group($group_id);
} else {
$task_id = array_get($_GET, 'task');
if (!$task_id) {
exit_with_error('TaskIdNotSpecified');
}
$test_groups = $db->select_rows('analysis_test_groups', 'testgroup', array('task' => $task_id));
if (!is_array($test_groups)) {
exit_with_error('FailedToFetchTestGroups');
}
$build_requests_fetcher->fetch_for_task($task_id);
}
if (!$build_requests_fetcher->has_results()) {
exit_with_error('FailedToFetchBuildRequests');
}
$test_groups = array_map("format_test_group", $test_groups);
$group_by_id = array();
foreach ($test_groups as &$group) {
$group_id = $group['id'];
$group_by_id[$group_id] =& $group;
$platforms = $db->query_and_fetch_all('SELECT DISTINCT(config_platform)
FROM test_configurations, test_runs, build_requests
WHERE run_config = config_id AND run_build = request_build AND request_group = $1', array($group_id));
if ($platforms) {
$group['platform'] = $platforms[0]['config_platform'];
}
}
$build_requests = $build_requests_fetcher->results();
foreach ($build_requests as $request) {
$request_group =& $group_by_id[$request['testGroup']];
array_push($request_group['buildRequests'], $request['id']);
array_push($request_group['rootSets'], $request['rootSet']);
}
exit_with_success(array('testGroups' => $test_groups, 'buildRequests' => $build_requests, 'rootSets' => $build_requests_fetcher->root_sets(), 'roots' => $build_requests_fetcher->roots()));
}
示例12: require_existence_of
function require_existence_of($array, $list_of_arguments, $prefix = '')
{
if ($prefix) {
$prefix .= '_';
}
foreach ($list_of_arguments as $key => $pattern) {
$name = camel_case_words_separated_by_underscore($prefix . $key);
if (!array_key_exists($key, $array)) {
exit_with_error($name . 'NotSpecified');
}
require_format($name, $array[$key], $pattern);
}
}
示例13: __construct
public function __construct($jsonFileLocation, $outputFile)
{
$this->jsonFileLocation = $jsonFileLocation;
$this->json = json_decode(file_get_contents(realpath($jsonFileLocation)), true);
$this->out = fopen($outputFile, 'w');
if (!is_array($this->json)) {
fclose($this->out);
exit_with_error('invalid json file');
}
if ($this->out === false) {
exit_with_error('could not open output file ./InitializerExtension.swift');
}
}
示例14: main
function main()
{
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
$generator = new ManifestGenerator($db);
if (!$generator->generate()) {
exit_with_error('FailedToGenerateManifest');
}
if (!$generator->store()) {
exit_with_error('FailedToStoreManifest');
}
exit_with_success($generator->manifest());
}
示例15: main
function main($path)
{
if (count($path) != 1) {
exit_with_error('InvalidRequest');
}
$parts = explode('-', $path[0]);
if (count($parts) != 2) {
exit_with_error('InvalidRequest');
}
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
$platform_id = intval($parts[0]);
$metric_id = intval($parts[1]);
$config_rows = $db->query_and_fetch_all('SELECT *
FROM test_configurations WHERE config_metric = $1 AND config_platform = $2', array($metric_id, $platform_id));
if (!$config_rows) {
exit_with_error('ConfigurationNotFound');
}
$test_group_id = array_get($_GET, 'testGroup');
$should_cache = array_get($_GET, 'cache');
if ($test_group_id) {
$test_group_id = intval($test_group_id);
} else {
if ($should_cache) {
// Only v1 UI needs caching.
$maxage = config('jsonCacheMaxAge');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $maxage) . ' GMT');
header("Cache-Control: maxage={$maxage}");
}
}
$generator = new RunsGenerator($config_rows);
foreach ($config_rows as $config) {
if ($test_group_id) {
$raw_runs = fetch_runs_for_config_and_test_group($db, $config, $test_group_id);
} else {
$raw_runs = fetch_runs_for_config($db, $config);
}
$generator->add_runs($config['config_type'], $raw_runs);
}
$content = success_json($generator->results());
if (!$test_group_id) {
generate_data_file("{$platform_id}-{$metric_id}.json", $content);
}
echo $content;
}