DevHeads.net

com web/bugs: Refactor error handling in quick fixing link: www/fix.php

Link: <a href="http://git.php.net/?p=web/bugs.git;a=commitdiff;h=a5c3a8b7fc6e94b0c4152e2f06a4969bb2af303f" title="http://git.php.net/?p=web/bugs.git;a=commitdiff;h=a5c3a8b7fc6e94b0c4152e2f06a4969bb2af303f">http://git.php.net/?p=web/bugs.git;a=commitdiff;h=a5c3a8b7fc6e94b0c4152e...</a>

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 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();
}