本文整理汇总了PHP中exit_with_success函数的典型用法代码示例。如果您正苦于以下问题:PHP exit_with_success函数的具体用法?PHP exit_with_success怎么用?PHP exit_with_success使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exit_with_success函数的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($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();
}
示例3: 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();
}
示例4: 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));
}
示例5: 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)));
}
示例6: main
function main($id, $path, $post_data)
{
if (!$id && (count($path) < 1 || count($path) > 2)) {
exit_with_error('InvalidRequest');
}
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
$report = $post_data ? json_decode($post_data, true) : array();
$updates = array_get($report, 'buildRequestUpdates');
if ($updates) {
verify_slave($db, $report);
update_builds($db, $updates);
}
$requests_fetcher = new BuildRequestsFetcher($db);
if ($id) {
$requests_fetcher->fetch_request($id);
} else {
$triggerable_query = array('name' => array_get($path, 0));
$triggerable = $db->select_first_row('build_triggerables', 'triggerable', $triggerable_query);
if (!$triggerable) {
exit_with_error('TriggerableNotFound', $triggerable_query);
}
$requests_fetcher->fetch_incomplete_requests_for_triggerable($triggerable['triggerable_id']);
}
exit_with_success(array('buildRequests' => $requests_fetcher->results_with_resolved_ids(), 'rootSets' => $requests_fetcher->root_sets(), 'roots' => $requests_fetcher->roots(), 'updates' => $updates));
}
示例7: 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');
}
if (!is_numeric($paths[0])) {
$repository_name = $paths[0];
$repository_row = $db->select_first_row('repositories', 'repository', array('name' => $repository_name));
if (!$repository_row) {
exit_with_error('RepositoryNotFound', array('repositoryName' => $repository_name));
}
$repository_id = $repository_row['repository_id'];
} else {
$repository_id = intval($paths[0]);
}
$filter = array_get($paths, 1);
$single_commit = NULL;
$commits = array();
if (!$filter) {
$keyword = array_get($_GET, 'keyword');
$from = array_get($_GET, 'from');
$to = array_get($_GET, 'to');
$commits = fetch_commits_between($db, $repository_id, $from, $to, $keyword);
} else {
if ($filter == 'oldest') {
$single_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id), 'time');
} else {
if ($filter == 'latest') {
$single_commit = $db->select_last_row('commits', 'commit', array('repository' => $repository_id), 'time');
} else {
if ($filter == 'last-reported') {
$single_commit = $db->select_last_row('commits', 'commit', array('repository' => $repository_id, 'reported' => true), 'time');
} else {
if (ctype_alnum($filter)) {
$single_commit = commit_from_revision($db, $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 = fetch_commits_between($db, $repository_id, $matches[1], $matches[2]);
}
}
}
}
}
if ($single_commit) {
$committer = $db->select_first_row('committers', 'committer', array('id' => $single_commit['commit_committer']));
exit_with_success(array('commits' => array(format_commit($single_commit, $committer))));
}
exit_with_success(array('commits' => $commits));
}
示例8: 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));
}
示例9: 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()));
}
示例10: main
function main()
{
$db = connect();
$data = ensure_privileged_api_data_and_token_or_slave($db);
$author = remote_user_name($data);
$name = array_get($data, 'name');
$start_run_id = array_get($data, 'startRun');
$end_run_id = array_get($data, 'endRun');
$segmentation_name = array_get($data, 'segmentationStrategy');
$test_range_name = array_get($data, 'testRangeStrategy');
if (!$name) {
exit_with_error('MissingName', array('name' => $name));
}
$range = array('startRunId' => $start_run_id, 'endRunId' => $end_run_id);
if (!$start_run_id || !$end_run_id) {
exit_with_error('MissingRange', $range);
}
$start_run = ensure_row_by_id($db, 'test_runs', 'run', $start_run_id, 'InvalidStartRun', $range);
$end_run = ensure_row_by_id($db, 'test_runs', 'run', $end_run_id, 'InvalidEndRun', $range);
$config = ensure_config_from_runs($db, $start_run, $end_run);
$start_run_time = time_for_run($db, $start_run_id);
$end_run_time = time_for_run($db, $end_run_id);
if (!$start_run_time || !$end_run_time) {
exit_with_error('InvalidTimeRange', array('startTime' => $start_run_time, 'endTime' => $end_run_time));
}
$db->begin_transaction();
$segmentation_id = NULL;
if ($segmentation_name) {
$segmentation_id = $db->select_or_insert_row('analysis_strategies', 'strategy', array('name' => $segmentation_name));
if (!$segmentation_id) {
$db->rollback_transaction();
exit_with_error('CannotFindOrInsertSegmentationStrategy', array('segmentationStrategy' => $segmentation_name));
}
}
$test_range_id = NULL;
if ($test_range_name) {
$test_range_id = $db->select_or_insert_row('analysis_strategies', 'strategy', array('name' => $test_range_name));
if (!$test_range_id) {
$db->rollback_transaction();
exit_with_error('CannotFindOrInsertTestRangeStrategy', array('testRangeStrategy' => $test_range_name));
}
}
$duplicate = $db->select_first_row('analysis_tasks', 'task', array('start_run' => $start_run_id, 'end_run' => $end_run_id));
if ($duplicate) {
$db->rollback_transaction();
exit_with_error('DuplicateAnalysisTask', array('duplicate' => $duplicate));
}
$task_id = $db->insert_row('analysis_tasks', 'task', array('name' => $name, 'author' => $author, 'platform' => $config['config_platform'], 'metric' => $config['config_metric'], 'start_run' => $start_run_id, 'start_run_time' => $start_run_time, 'end_run' => $end_run_id, 'end_run_time' => $end_run_time, 'segmentation' => $segmentation_id, 'test_range' => $test_range_id));
$db->commit_transaction();
exit_with_success(array('taskId' => $task_id));
}
示例11: 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());
}
示例12: main
function main()
{
$db = connect();
$data = ensure_privileged_api_data_and_token_or_slave($db);
$author = remote_user_name($data);
$task_id = array_get($data, 'task');
$name = array_get($data, 'name');
$root_sets = array_get($data, 'rootSets');
$repetition_count = intval(array_get($data, 'repetitionCount', 1));
if (!$name) {
exit_with_error('MissingName');
}
if (!$root_sets) {
exit_with_error('MissingRootSets');
}
if ($repetition_count < 1) {
exit_with_error('InvalidRepetitionCount', array('repetitionCount' => $repetition_count));
}
$task = $db->select_first_row('analysis_tasks', 'task', array('id' => $task_id));
if (!$task) {
exit_with_error('InvalidTask', array('task' => $task_id));
}
$triggerable = find_triggerable_for_task($db, $task_id);
if (!$triggerable) {
exit_with_error('TriggerableNotFoundForTask', array('task' => $task_id));
}
$commit_sets = commit_sets_from_root_sets($db, $root_sets);
$db->begin_transaction();
$root_set_id_list = array();
foreach ($commit_sets as $commit_list) {
$root_set_id = $db->insert_row('root_sets', 'rootset', array());
foreach ($commit_list as $commit) {
$db->insert_row('roots', 'root', array('set' => $root_set_id, 'commit' => $commit), 'commit');
}
array_push($root_set_id_list, $root_set_id);
}
$group_id = $db->insert_row('analysis_test_groups', 'testgroup', array('task' => $task['task_id'], 'name' => $name, 'author' => $author));
$order = 0;
for ($i = 0; $i < $repetition_count; $i++) {
foreach ($root_set_id_list as $root_set_id) {
$db->insert_row('build_requests', 'request', array('triggerable' => $triggerable['id'], 'platform' => $triggerable['platform'], 'test' => $triggerable['test'], 'group' => $group_id, 'order' => $order, 'root_set' => $root_set_id));
$order++;
}
}
$db->commit_transaction();
exit_with_success(array('testGroupId' => $group_id));
}
示例13: main
function main()
{
require_existence_of($_GET, array('builder' => '/^[A-Za-z0-9 \\(\\)\\-_]+$/'));
$builder_name = $_GET['builder'];
$db = connect();
$builder_row = $db->select_first_row('builders', NULL, array('name' => $builder_name));
if (!$builder_row) {
exit_with_error('BuilderNotFound');
}
$builder_id = $builder_row['id'];
$generator = new ResultsJSONGenerator($db, $builder_id);
if ($generator->generate()) {
exit_with_success();
} else {
exit_with_error('ResultsNotFound');
}
}
示例14: main
function main($path)
{
$db = new Database();
if (!$db->connect()) {
exit_with_error('DatabaseConnectionFailure');
}
if (count($path) > 1) {
exit_with_error('InvalidRequest');
}
$build_request_id = array_get($_GET, 'buildRequest');
$task_id = count($path) > 0 && $path[0] ? $path[0] : array_get($_GET, 'id');
if ($build_request_id) {
$tasks = $db->query_and_fetch_all('SELECT analysis_tasks.* FROM build_requests, analysis_test_groups, analysis_tasks
WHERE request_id = $1 AND request_group = testgroup_id AND testgroup_task = task_id', array(intval($build_request_id)));
if (!$tasks) {
exit_with_error('TaskNotFound', array('buildRequest' => $build_request_id));
}
} else {
if ($task_id) {
$task_id = intval($task_id);
$task = $db->select_first_row('analysis_tasks', 'task', array('id' => $task_id));
if (!$task) {
exit_with_error('TaskNotFound', array('id' => $task_id));
}
$tasks = array($task);
} else {
$metric_id = array_get($_GET, 'metric');
$platform_id = array_get($_GET, 'platform');
if (!!$metric_id != !!$platform_id) {
exit_with_error('InvalidArguments', array('metricId' => $metric_id, 'platformId' => $platform_id));
}
if ($metric_id) {
$tasks = $db->select_rows('analysis_tasks', 'task', array('platform' => $platform_id, 'metric' => $metric_id));
} else {
// FIXME: Limit the number of tasks we fetch.
$tasks = array_reverse($db->fetch_table('analysis_tasks', 'task_created_at'));
}
if (!is_array($tasks)) {
exit_with_error('FailedToFetchTasks');
}
}
}
$tasks = array_map("format_task", $tasks);
$bugs = fetch_and_push_bugs_to_tasks($db, $tasks);
exit_with_success(array('analysisTasks' => $tasks, 'bugs' => $bugs));
}
示例15: main
function main($post_data)
{
set_exit_detail('failureStored', false);
$maintenance_mode = config('maintenanceMode');
if ($maintenance_mode && !config('maintenanceDirectory')) {
exit_with_error('MaintenanceDirectoryNotSet');
}
$db = new Database();
if (!$maintenance_mode && !$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) {
if (!$maintenance_mode) {
$processor = new ReportProcessor($db);
$processor->process($report);
}
set_exit_detail('processedRuns', $i + 1);
}
if ($maintenance_mode) {
$files = scandir(config_path('maintenanceDirectory', ''));
$i = 0;
$filename = '';
do {
$i++;
$filename = "{$i}.json";
} while (in_array($filename, $files));
file_put_contents(config_path('maintenanceDirectory', $filename), $post_data, LOCK_EX);
} else {
$generator = new ManifestGenerator($db);
if (!$generator->generate()) {
exit_with_error('FailedToGenerateManifest');
} else {
if (!$generator->store()) {
exit_with_error('FailedToStoreManifest');
}
}
}
exit_with_success();
}