Commit: a5c3a8b7fc6e94b0c4152e2f06a4969bb2af303f Author: Peter Kokot <peterko...@gmail.com> Wed, 5 Dec 2018 12:28:55 +0100 Parents: 9909448411387a0446cdbb83adc0015bb6225011 Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=a5c3a8b7fc6e94b0c4152e2f06a4969bb2af303f Log: Refactor error handling in quick fixing link This patch refactors error handling from PEAR error to exceptions. Error handling has been refactored via 23298a123688443276f60143c1261f85a85873fe. Changed paths: M www/fix.php Diff: diff --git a/www/fix.php b/www/fix.php index 3006bf9..963cb43 100644 --- a/www/fix.php +++ b/www/fix.php @@ -131,43 +131,41 @@ if ($status == 'Closed' && $in['assign'] == '') { $in['assign'] = $auth_user->handle; } -// Update bug -$dbh->prepare(" - UPDATE bugdb - SET - status = ?, - assign = ?, - ts2 = NOW() - WHERE id = ? -")->execute([ - $status, - $in['assign'], - $bug_id, -]); - -// Add changelog entry -if (!PEAR::isError($res)) { +try { + // Update bug + $dbh->prepare(" + UPDATE bugdb + SET + status = ?, + assign = ?, + ts2 = NOW() + WHERE id = ? + ")->execute([ + $status, + $in['assign'], + $bug_id, + ]); + + // Add changelog entry $changed = bug_diff($bug, $in); if (!empty($changed)) { $log_comment = bug_diff_render_html($changed); if (!empty($log_comment)) { - $res = bugs_add_comment($bug_id, $auth_user->email, $auth_user->name, $log_comment, 'log'); + $result = bugs_add_comment($bug_id, $auth_user->email, $auth_user->name, $log_comment, 'log'); } } -} -// Add possible comment -if (!PEAR::isError($res) && !empty($ncomment)) { - $res = bugs_add_comment($bug_id, $auth_user->email, $auth_user->name, $ncomment, 'comment'); -} + // Add possible comment + if (!empty($ncomment)) { + $result = bugs_add_comment($bug_id, $auth_user->email, $auth_user->name, $ncomment, 'comment'); + } -// Send emails -if (!PEAR::isError($res)) { + // Send emails mail_bug_updates($bug, $in, $auth_user->email, $ncomment); redirect("bug.php?id={$bug_id}&thanks=1"); +} catch (\Exception $e) { + // If we end up here, something went wrong. + response_header('Resolve Bug: Problem'); + display_bug_error($e->getMessage()); + response_footer(); } - -// If we end up here, something went wrong. -response_header('Resolve Bug: Problem'); -display_bug_error($res); -response_footer(); -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php