Commit:    c2a40c6bf0a7ecf4eab0ff4f21d8abe6d32d1bfc
Author:    Peter Kokot <[email protected]>         Tue, 23 Oct 2018 00:40:44 
+0200
Parents:   e6700f9eeddc1b1a7c0573aa48e0082eb650881b
Branches:  master

Link:       
http://git.php.net/?p=web/bugs.git;a=commitdiff;h=c2a40c6bf0a7ecf4eab0ff4f21d8abe6d32d1bfc

Log:
Replace PEAR MDB2 constants with PDO constants

The changed constants are more understandable using PDO constants
nor are the dedicated definition needed anymore.

Changed paths:
  M  include/classes/bug_ghpulltracker.php
  M  include/classes/bug_patchtracker.php
  M  include/classes/bug_pdo.php
  M  include/functions.php
  M  www/admin/index.php
  M  www/api.php
  M  www/bug-pwd-finder.php
  M  www/lstats.php
  M  www/stats.php

diff --git a/include/classes/bug_ghpulltracker.php 
b/include/classes/bug_ghpulltracker.php
index 6bc0ad2..47d1524 100644
--- a/include/classes/bug_ghpulltracker.php
+++ b/include/classes/bug_ghpulltracker.php
@@ -72,6 +72,6 @@ class Bug_Pulltracker
                        ORDER BY github_repo, github_pull_id DESC
                ';
 
-               return 
$this->_dbh->prepare($query)->execute(array($bugid))->fetchAll(MDB2_FETCHMODE_ASSOC);
+               return 
$this->_dbh->prepare($query)->execute(array($bugid))->fetchAll(PDO::FETCH_ASSOC);
        }
 }
diff --git a/include/classes/bug_patchtracker.php 
b/include/classes/bug_patchtracker.php
index 39a79d5..2324eca 100644
--- a/include/classes/bug_patchtracker.php
+++ b/include/classes/bug_patchtracker.php
@@ -285,7 +285,7 @@ class Bug_Patchtracker
                        ORDER BY revision DESC
                ';
 
-               return 
$this->_dbh->prepare($query)->execute(array($bugid))->fetchAll(MDB2_FETCHMODE_ORDERED,
 true, false, true);
+               return 
$this->_dbh->prepare($query)->execute(array($bugid))->fetchAll(PDO::FETCH_NUM, 
true, false, true);
        }
 
        /**
@@ -302,7 +302,7 @@ class Bug_Patchtracker
                        WHERE bugdb_id = ? AND patch = ?
                        ORDER BY revision DESC
                ';
-               return $this->_dbh->prepare($query)->execute(array($bugid, 
$patch))->fetchAll(MDB2_FETCHMODE_ORDERED);
+               return $this->_dbh->prepare($query)->execute(array($bugid, 
$patch))->fetchAll(PDO::FETCH_NUM);
        }
 
        /**
@@ -326,7 +326,7 @@ class Bug_Patchtracker
                        SELECT developer, revision
                        FROM bugdb_patchtracker
                        WHERE bugdb_id = ? AND patch = ? ORDER BY revision DESC
-               ')->execute(array($bugid, 
$patch))->fetchAll(MDB2_FETCHMODE_ASSOC);
+               ')->execute(array($bugid, $patch))->fetchAll(PDO::FETCH_ASSOC);
        }
 
        function getObsoletingPatches($bugid, $patch, $revision)
@@ -335,7 +335,7 @@ class Bug_Patchtracker
                        SELECT bugdb_id, patch, revision
                        FROM bugdb_obsoletes_patches
                        WHERE   bugdb_id = ? AND obsolete_patch = ? AND 
obsolete_revision = ?
-               ')->execute(array($bugid, $patch, 
$revision))->fetchAll(MDB2_FETCHMODE_ASSOC);
+               ')->execute(array($bugid, $patch, 
$revision))->fetchAll(PDO::FETCH_ASSOC);
        }
 
        function getObsoletePatches($bugid, $patch, $revision)
@@ -344,7 +344,7 @@ class Bug_Patchtracker
                        SELECT bugdb_id, obsolete_patch, obsolete_revision
                        FROM bugdb_obsoletes_patches
                        WHERE bugdb_id = ? AND patch = ? AND revision = ?
-               ')->execute(array($bugid, $patch, 
$revision))->fetchAll(MDB2_FETCHMODE_ASSOC);
+               ')->execute(array($bugid, $patch, 
$revision))->fetchAll(PDO::FETCH_ASSOC);
        }
 
        /**
diff --git a/include/classes/bug_pdo.php b/include/classes/bug_pdo.php
index f5e8efa..237163f 100644
--- a/include/classes/bug_pdo.php
+++ b/include/classes/bug_pdo.php
@@ -9,11 +9,6 @@
  * @author Maciej Sobaczewski <[email protected]>
  */
 
-// Define missing constants
-define('MDB2_FETCHMODE_ASSOC', PDO::FETCH_ASSOC);
-define('MDB2_FETCHMODE_ORDERED', PDO::FETCH_NUM);
-define('MDB2_PREPARE_MANIP', null);
-
 class Bug_PDO extends PDO
 {
     /**
diff --git a/include/functions.php b/include/functions.php
index 31e5bf4..3216978 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -215,7 +215,7 @@ function get_pseudo_packages($project, $return_disabled = 
true)
                $where.= " AND disabled = 0";
        }
 
-       $data = $dbh->queryAll("SELECT * FROM bugdb_pseudo_packages WHERE 
$where ORDER BY parent, disabled, id", null, MDB2_FETCHMODE_ASSOC);
+       $data = $dbh->queryAll("SELECT * FROM bugdb_pseudo_packages WHERE 
$where ORDER BY parent, disabled, id", null, PDO::FETCH_ASSOC);
 
        // Convert flat array to nested strucutre
        foreach ($data as &$node)
@@ -1181,13 +1181,13 @@ function get_old_comments($bug_id, $all = 0)
 
        // skip the most recent unless the caller wanted all comments
        if (!$all) {
-               $row = $res->fetchRow(MDB2_FETCHMODE_ORDERED);
+               $row = $res->fetchRow(PDO::FETCH_NUM);
                if (!$row) {
                        return '';
                }
        }
 
-       while (($row = $res->fetchRow(MDB2_FETCHMODE_ORDERED)) && 
strlen($output) < $max_message_length && $count++ < $max_comments) {
+       while (($row = $res->fetchRow(PDO::FETCH_NUM)) && strlen($output) < 
$max_message_length && $count++ < $max_comments) {
                $email = spam_protect($row[1], 'text');
                $output .= "[{$row[0]}] {$email}\n\n{$row[2]}\n\n{$divider}\n";
        }
@@ -1197,7 +1197,7 @@ function get_old_comments($bug_id, $all = 0)
                if (!$res) {
                        return $output;
                }
-               $row = $res->fetchRow(MDB2_FETCHMODE_ORDERED);
+               $row = $res->fetchRow(PDO::FETCH_NUM);
                if (!$row) {
                        return $output;
                }
@@ -1477,7 +1477,7 @@ function unsubscribe_hash($bug_id, $email)
                WHERE bug_id = ? AND email = ?
        ";
 
-       $affected = $dbh->prepare($query, null, 
MDB2_PREPARE_MANIP)->execute([$hash, $bug_id, $email]);
+       $affected = $dbh->prepare($query, null, null)->execute([$hash, $bug_id, 
$email]);
 
        if ($affected > 0) {
                $hash = urlencode($hash);
@@ -1530,7 +1530,7 @@ function unsubscribe($bug_id, $hash)
                WHERE bug_id = ? AND unsubscribe_hash = ? LIMIT 1
        ";
 
-       $sub = $dbh->prepare($query)->execute([$bug_id, 
$hash])->fetch(MDB2_FETCHMODE_ASSOC);
+       $sub = $dbh->prepare($query)->execute([$bug_id, 
$hash])->fetch(PDO::FETCH_ASSOC);
 
        if (!$sub) {
                return false;
@@ -1573,7 +1573,7 @@ function get_resolve_reasons($project = false)
        if (!$res) {
                throw new Exception("SQL Error in get_resolve_reasons");
        }
-       while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+       while ($row = $res->fetchRow(PDO::FETCH_ASSOC)) {
                if (!empty($row['package_name'])) {
                        $variations[$row['name']][$row['package_name']] = 
$row['message'];
                } else {
@@ -1608,7 +1608,7 @@ function bugs_get_bug($bug_id)
                WHERE b.id = ?
                GROUP BY bug';
 
-       return 
$dbh->prepare($query)->execute([$bug_id])->fetchRow(MDB2_FETCHMODE_ASSOC);
+       return 
$dbh->prepare($query)->execute([$bug_id])->fetchRow(PDO::FETCH_ASSOC);
 }
 
 /**
@@ -1628,7 +1628,7 @@ function bugs_get_bug_comments($bug_id)
                WHERE c.bug = ?
                GROUP BY c.id ORDER BY c.ts
        ";
-       return 
$dbh->prepare($query)->execute([$bug_id])->fetchAll(MDB2_FETCHMODE_ASSOC);
+       return 
$dbh->prepare($query)->execute([$bug_id])->fetchAll(PDO::FETCH_ASSOC);
 }
 
 /**
diff --git a/www/admin/index.php b/www/admin/index.php
index 3b047b9..5d60eb0 100644
--- a/www/admin/index.php
+++ b/www/admin/index.php
@@ -59,7 +59,7 @@ if ($action === 'phpinfo') {
        ");
 
        echo "<dl>\n";
-       while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+       while ($row = $res->fetchRow(PDO::FETCH_ASSOC)) {
                echo "<dt>", $row['name'], ": </dt>\n<dd>", 
mailto_list(explode(',', $row['list_email'])), "</dd>\n";
        }
        echo "</dl>\n";
@@ -73,7 +73,7 @@ if ($action === 'phpinfo') {
        echo "<h3>List Responses</h3>\n";
 
        $rows = array();
-       while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+       while ($row = $res->fetchRow(PDO::FETCH_ASSOC)) {
                // This is ugly but works (tm)
                $row['message'] = nl2br($row['message']);
 
@@ -86,13 +86,13 @@ if ($action === 'phpinfo') {
 
        $sql = "SELECT version() mysql_version\n";
 
-       while ($row = $res->fetchRow(MDB2_FETCHMODE_ORDERED)) {
+       while ($row = $res->fetchRow(PDO::FETCH_NUM)) {
                $table = $row[0];
                $sql .= "\t, (SELECT COUNT(*) FROM `$table`) `cnt_$table`\n";
        }
 
        $res = $dbh->query($sql);
-       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
+       $row = $res->fetchRow(PDO::FETCH_ASSOC);
 
        echo "<p>Running MySQL <b>".$row['mysql_version']."</b></p>";
        unset($row['mysql_version']);
@@ -110,7 +110,7 @@ if ($action === 'phpinfo') {
        $rows = array();
        $res = $dbh->query("SHOW TABLE STATUS");
        echo "<h3>Table status:</h3>\n";
-       while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+       while ($row = $res->fetchRow(PDO::FETCH_ASSOC)) {
                $rows[] = $row;
        }
 
diff --git a/www/api.php b/www/api.php
index 53228ff..b1e2e17 100644
--- a/www/api.php
+++ b/www/api.php
@@ -27,7 +27,7 @@ if ($type === 'docs' && $action === 'closed' && $interval) {
        ";
 
        //@todo add error handling
-       $rows = 
$dbh->prepare($query)->execute(array())->fetchAll(MDB2_FETCHMODE_ASSOC);
+       $rows = 
$dbh->prepare($query)->execute(array())->fetchAll(PDO::FETCH_ASSOC);
        if (!$rows) {
                echo 'The fail train has arrived.';
                exit;
diff --git a/www/bug-pwd-finder.php b/www/bug-pwd-finder.php
index f7a6ac6..eb78c54 100644
--- a/www/bug-pwd-finder.php
+++ b/www/bug-pwd-finder.php
@@ -28,7 +28,7 @@ if (isset($_POST['captcha']) && $bug_id != '') {
                $query = "SELECT email, passwd FROM bugdb WHERE id = 
'{$bug_id}'";
 
                // Run the query
-               $row = 
$dbh->prepare($query)->execute()->fetchRow(MDB2_FETCHMODE_ASSOC);
+               $row = 
$dbh->prepare($query)->execute()->fetchRow(PDO::FETCH_ASSOC);
 
                if (is_null($row)) {
                        $errors[] = "Invalid bug id provided: #{$bug_id}";
diff --git a/www/lstats.php b/www/lstats.php
index d8a8ae2..cf705bc 100644
--- a/www/lstats.php
+++ b/www/lstats.php
@@ -28,7 +28,7 @@ function get_status_count ($status, $category = '')
        $query.= "AND bug_type NOT IN({$excluded})";
 
        $res = $dbh->prepare($query)->execute(array());
-       $row = $res->fetchRow(MDB2_FETCHMODE_ORDERED);
+       $row = $res->fetchRow(PDO::FETCH_NUM);
 
        return $row[0];
 }
diff --git a/www/stats.php b/www/stats.php
index ec9cb2a..cc46037 100644
--- a/www/stats.php
+++ b/www/stats.php
@@ -59,7 +59,7 @@ $query  = "
 
 $result = $dbh->prepare($query)->execute();
 
-while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+while ($row = $result->fetchRow(PDO::FETCH_ASSOC)) {
        $pkg_tmp[$row['status']][$row['package_name']] = $row['quant'];
        @$pkg_total[$row['package_name']] += $row['quant'];
        @$all[$row['status']] += $row['quant'];
@@ -161,7 +161,7 @@ $query  = "  SELECT DATE_FORMAT(ts1, '%Y-%m') as d,
 $result = $dbh->prepare($query)->execute();
 
 $last_date = null;
-while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+while ($row = $result->fetchRow(PDO::FETCH_ASSOC)) {
        if ($row['d'] != $last_date) {
                if ($last_date !== null) {
                        echo "</table>\n\n";
-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to