Commit: 4bdb303453c1c44fa770483d10e4f62ebb8ca881 Author: Peter Kokot <peterko...@gmail.com> Tue, 23 Oct 2018 03:05:34 +0200 Parents: 5344b77166b0826165792f12042a72383fcbba93 Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=4bdb303453c1c44fa770483d10e4f62ebb8ca881 Log: Refactor PDO wrapper to not depend on MDB2 anymore The Bug_PDO is a thin PDO wrapper not dependant on the MDB2 anymore. The rpc.php page included some old MDB2::errorMessage() usage which is now refactored differently using only PDO way and current errors handling. Changed paths: M include/classes/bug_pdo.php M www/rpc.php Diff: diff --git a/include/classes/bug_pdo.php b/include/classes/bug_pdo.php index 237163f..536762c 100644 --- a/include/classes/bug_pdo.php +++ b/include/classes/bug_pdo.php @@ -1,10 +1,6 @@ <?php /** - * Thin compatibility layer between MDB2 and PDO for bugs.php.net. - * - * Please mind that it's not meant to implement full feature set, - * but only this used by our existing codebase. New code interacting - * with the database should be written using standard PDO's approach. + * Thin PDO wrapper for bugs.php.net. * * @author Maciej Sobaczewski <so...@php.net> */ @@ -23,8 +19,8 @@ class Bug_PDO extends PDO } /** - * MDB2::espace() doesn't put apostrophes around the text and PDO does so we - * need to strip outermost characters. + * PDO puts apostrophes around the text so we need to strip the outermost + * characters. */ public function escape($text, $escape_wildcards = false) { @@ -40,10 +36,10 @@ class Bug_PDO extends PDO class Bug_PDOStatement extends PDOStatement { /** - * MDB2 allows for chaining execute() method like so: + * This allows chaining execute() method: * $db->query('SELECT a FROM b WHERE c = ?')->execute('foo')->fetch(); - * PDOStatement::execute(), on the other hand, returns boolean. Change it - * to return $this and thus allow futher method chaining. + * PDOStatement::execute(), on the other hand, returns boolean. Change it to + * return $this and thus allow further method chaining. */ public function execute($input_parameters = NULL) { diff --git a/www/rpc.php b/www/rpc.php index 0a97a49..5aa60e1 100644 --- a/www/rpc.php +++ b/www/rpc.php @@ -49,10 +49,10 @@ if (!empty($_POST['ncomment']) && !empty($_POST['user'])) { $ncomment = htmlspecialchars(trim($_POST['ncomment'])); $from = "{$user}@php.net"; - /* svn log comment */ - $res = bugs_add_comment($bug_id, $from, $user, $ncomment, 'svn'); + try { + /* svn log comment */ + bugs_add_comment($bug_id, $from, $user, $ncomment, 'svn'); - if ($res) { /* Close the bug report as requested if it is not already closed */ if (!empty($_POST['status']) && $bug['status'] !== 'Closed' @@ -69,7 +69,7 @@ if (!empty($_POST['ncomment']) && !empty($_POST['user'])) { $log_comment = bug_diff_render_html($changed); if (!empty($log_comment)) { /* Add a log of status change */ - $res = bugs_add_comment($bug_id, $from, '', $log_comment, 'log'); + bugs_add_comment($bug_id, $from, '', $log_comment, 'log'); } } @@ -79,8 +79,8 @@ if (!empty($_POST['ncomment']) && !empty($_POST['user'])) { echo json_encode(array('result' => array('status' => $bug))); exit; - } else { - echo json_encode(array('result' => array('error' => MDB2::errorMessage($res)))); + } catch (Exception $e) { + echo json_encode(array('result' => array('error' => $e->getMessage()))); exit; } } else if (!empty($_POST['getbug'])) { -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php