Commit: 23298a123688443276f60143c1261f85a85873fe
Author: Rasmus Lerdorf <[email protected]> Tue, 17 Jul 2018 19:53:03
-0400
Parents: 5d5debad406fb4ea468a4a91984ef1031876fb3a
Branches: master
Link:
http://git.php.net/?p=web/bugs.git;a=commitdiff;h=23298a123688443276f60143c1261f85a85873fe
Log:
New bugs.php.net code
Changed paths:
M README.md
M include/classes/bug_patchtracker.php
M include/functions.php
M include/php_versions.php
M include/prepend.php
M include/query.php
M local_config.php.sample
M scripts/cron/email-assigned
M scripts/cron/no-feedback
M templates/search-rdf.php
M templates/search-rss2.php
M www/js/userlisting.php
M www/report.php
M www/rss/search.php
M www/search.php
diff --git a/README.md b/README.md
index 125c1a1..61f351d 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,3 @@
-PHP Bug Tracking System
-=======================
-This was a collaboration between PEAR, PECL and PHP core to create a unified
bug tracker.
-
-Requirements
-============
-- PHP 5.4+
-- `ext/openssl` (for https:// fopen wrapper)
-- PEAR packages:
- - MDB2
- - MDB2#mysql
- - MDB2#mysqli
- - DB_DataObject
- - Text_CAPTCHA_Numeral
- Text_Diff
- HTTP_Upload
@@ -19,10 +5,4 @@ Installation
============
1. Copy `local_config.php.sample` to `local_config.php` and modify accordingly
2. Install all required packages:
-`pear install MDB2 MDB2#mysql MDB2#mysqli DB_DataObject Text_CAPTCHA_Numeral
Text_Diff HTTP_Upload`
-3. Import SQL schema from `sql/bugs.sql`
-
-TODO
-====
-- AJAXify where it's useful
-- Add project support (f.e. PHP-GTK, PEAR..)
+`pear install Text_CAPTCHA_Numeral Text_Diff HTTP_Upload`
diff --git a/include/classes/bug_patchtracker.php
b/include/classes/bug_patchtracker.php
index 93c6051..8091303 100644
--- a/include/classes/bug_patchtracker.php
+++ b/include/classes/bug_patchtracker.php
@@ -224,7 +224,7 @@ class Bug_Patchtracker
return $id;
} elseif ($file->isMissing()) {
return PEAR::raiseError('Uploaded file is empty or
nothing was uploaded.');
- } elseif ($file->isError()) {
+ } elseif ($file->error()) {
return PEAR::raiseError($file->errorMsg());
}
return PEAR::raiseError('Unable to attach patch (try renaming
the file with .txt extension)');
diff --git a/include/functions.php b/include/functions.php
index 845b831..a8c6ec1 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -796,13 +796,7 @@ function show_boolean_options($current)
*/
function display_bug_error($in, $class = 'errors', $head = 'ERROR:')
{
- if (PEAR::isError($in)) {
- if (DEVBOX == true) {
- $in = array($in->getMessage() . '... ' .
$in->getUserInfo());
- } else {
- $in = array($in->getMessage());
- }
- } elseif (!is_array($in)) {
+ if (!is_array($in)) {
$in = array($in);
} elseif (!count($in)) {
return false;
@@ -810,13 +804,6 @@ function display_bug_error($in, $class = 'errors', $head =
'ERROR:')
echo "<div class='{$class}'>{$head}<ul>";
foreach ($in as $msg) {
- if (PEAR::isError($msg)) {
- if (DEVBOX == true) {
- $msg = $msg->getMessage() . '... ' .
$msg->getUserInfo();
- } else {
- $msg = $msg->getMessage();
- }
- }
echo '<li>' , htmlspecialchars($msg) , "</li>\n";
}
echo "</ul></div>\n";
@@ -1356,10 +1343,6 @@ function get_package_mail($package_name, $bug_id =
false, $bug_type = 'Bug')
WHERE name = ?
')->execute([$package_name]);
- if (PEAR::isError($res)) {
- throw new Exception('SQL Error in get_package_name(): '
. $res->getMessage());
- }
-
list($list_email, $project) = $res->fetchRow();
if ($project == 'pecl') {
@@ -1568,7 +1551,7 @@ function get_resolve_reasons($project = false)
$resolves = $variations = array();
$res = $dbh->prepare("SELECT * FROM bugdb_resolves
$where")->execute(array());
- if (PEAR::isError($res)) {
+ if (!$res) {
throw new Exception("SQL Error in get_resolve_reasons");
}
while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
@@ -2050,15 +2033,3 @@ function mailto_list(array $mails)
echo rtrim($buffer, ', ');
}
-
-if (!function_exists('apc_fetch')) {
- function apc_fetch($key, &$success = false) {
- return apcu_fetch($key, $success);
- }
-}
-
-if (!function_exists('apc_store')) {
- function apc_store($key, $var, $ttl = 0) {
- return apcu_store($key, $var, $ttl);
- }
-}
diff --git a/include/php_versions.php b/include/php_versions.php
index f3e5021..20529c5 100644
--- a/include/php_versions.php
+++ b/include/php_versions.php
@@ -3,7 +3,7 @@
/*
The RC and dev versions are pulled from the http://qa.php.net/api.php
if you want to add a new version, add it there at include/release-qa.php
- the result is cached for an hour, you can force it to refresh, if you
delete the 'bugs.versions' item from apc
+ the result is cached for an hour in /tmp/<systemd>/tmp/versions.php
the versions are weighted by the following:
- major+minor version desc (7>5.4>5.3>master)
- between a minor version we order by the micro if available: first the
qa releases: alpha/beta/rc, then the stable, then the Git versions(snaps, Git)
@@ -18,11 +18,12 @@
'Irrelevant'
);
- if (!$versions = apc_fetch('bugs.versions')) {
+ if(!file_exists("/tmp/versions.php") || filemtime("/tmp/versions.php")
< $_SERVER['REQUEST_TIME'] - 3600) {
$versions = buildVersions();
- if ($versions) {
- apc_store('bugs.versions', $versions, 3600);
- }
+ $versions_data = var_export($versions, true);
+ file_put_contents("/tmp/versions.php", '<?php $versions =
'.$versions_data.';');
+ } else {
+ include "/tmp/versions.php";
}
$versions = array_merge($versions, $custom_versions);
diff --git a/include/prepend.php b/include/prepend.php
index b20b7ce..ba285e4 100644
--- a/include/prepend.php
+++ b/include/prepend.php
@@ -1,9 +1,5 @@
<?php
-// Enable output compression
-ini_set('zlib.output_compression', 1);
-
-// FIXME: Do not display errors, they are logged
ini_set('display_errors', 0);
$site = 'php';
@@ -45,23 +41,20 @@ $docBugEmail = $site_data['doc_email'];
$secBugEmail = $site_data['security_email'];
$basedir = $site_data['basedir'];
define('BUG_PATCHTRACKER_TMPDIR', $site_data['patch_tmp']);
-define('DATABASE_DSN',
"{$site_data['db_extension']}://{$site_data['db_user']}:{$site_data['db_pass']}@{$site_data['db_host']}/{$site_data['db']}");
+define('DATABASE_DSN',
"mysql:host={$site_data['db_host']};dbname={$site_data['db']};charset=utf8");
/**
* Obtain the functions and variables used throughout the bug system
*/
require_once "{$ROOT_DIR}/include/functions.php";
+require 'classes/bug_pdo.php';
// Database connection (required always?)
-include_once 'MDB2.php';
-
-PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_errors');
-
-if (empty($dbh))
-{
- $dbh = MDB2::factory(DATABASE_DSN);
- $dbh->loadModule('Extended');
-}
+$dbh = new Bug_PDO(DATABASE_DSN, $site_data['db_user'], $site_data['db_pass'],
[
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::ATTR_EMULATE_PREPARES => false,
+]);
// Last Updated..
$tmp = filectime($_SERVER['SCRIPT_FILENAME']);
diff --git a/include/query.php b/include/query.php
index 6fb6f6a..bd6b6f3 100644
--- a/include/query.php
+++ b/include/query.php
@@ -263,14 +263,13 @@ if (isset($_GET['cmd']) && $_GET['cmd'] == 'display')
if (stristr($query, ';')) {
$errors[] = 'BAD HACKER!! No database cracking for you today!';
} else {
- $res = $dbh->prepare($query)->execute();
- if (!PEAR::isError($res)) {
- $rows = $res->numRows();
+ try {
+ $result = $dbh->prepare($query)->execute()->fetchAll();
+ $rows = count($result);
$total_rows = $dbh->prepare('SELECT
FOUND_ROWS()')->execute()->fetchOne();
- } else {
- $error = MDB2::errorMessage($res);
- $errors[] = $error;
- }
+ } catch (Exception $e) {
+ $errors[] = 'Invalid query: ' . $e->getMessage();
+ }
if (defined('MAX_BUGS_RETURN') && $total_rows > $rows) {
$warnings[] = 'The search was too general, only ' .
MAX_BUGS_RETURN . ' bugs will be returned';
}
diff --git a/local_config.php.sample b/local_config.php.sample
index 6a02dce..5e5cca0 100644
--- a/local_config.php.sample
+++ b/local_config.php.sample
@@ -12,7 +12,6 @@ $site_data = array (
'doc_email' => '[email protected]',
'security_email' => '[email protected]',
'db' => 'phpbugsdb',
- 'db_extension' => 'mysqli',
'db_user' => 'nobody',
'db_pass' => '',
'db_host' => 'localhost',
diff --git a/scripts/cron/email-assigned b/scripts/cron/email-assigned
index b9910be..61200b4 100755
--- a/scripts/cron/email-assigned
+++ b/scripts/cron/email-assigned
@@ -16,18 +16,11 @@ $sql = "SELECT id, package_name, bug_type, sdesc, status,
assign, UNIX_TIMESTAMP
$res = $dbh->query($sql);
-if (PEAR::isError($res)) {
- throw new Exception("SQL Error in email-assigned");
-}
-
// Gather up the data
-while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+while ($row = $res->fetchRow(PDO::FETCH_ASSOC)) {
$data[$row['assign']][] = $row;
}
-$num_rows = $res->numRows();
-$num_users = count($data);
-
foreach ($data as $assigned => $binfos) {
$mbody = format_email_body($binfos);
diff --git a/scripts/cron/no-feedback b/scripts/cron/no-feedback
index 478b7ff..335c472 100755
--- a/scripts/cron/no-feedback
+++ b/scripts/cron/no-feedback
@@ -26,7 +26,7 @@ if ($dbh)
if (PEAR::isError($res)) {
throw new Exception("SQL Error in no-feedback");
}
- while ($bug = $res->fetchRow(MDB2_FETCHMODE_ASSOC))
+ while ($bug = $res->fetchRow(PDO::FETCH_ASSOC))
{
list($mailto, $mailfrom, $bcc, $params) =
get_package_mail($bug['package_name'], false, $bug['bug_type']);
diff --git a/templates/search-rdf.php b/templates/search-rdf.php
index fd67fdf..fa1edbc 100644
--- a/templates/search-rdf.php
+++ b/templates/search-rdf.php
@@ -25,7 +25,7 @@ echo ' <items>
$items = '';
if ($total_rows > 0) {
- foreach ($res->fetchAll(MDB2_FETCHMODE_ASSOC) as $row) {
+ foreach ($result as $row) {
$desc = "{$row['package_name']} ({$row['bug_type']})\nReported
by ";
if (preg_match('/@php.net$/i', $row['email'])) {
$desc .= substr($row['email'], 0, strpos($row['email'],
'@')) ."\n";
diff --git a/templates/search-rss2.php b/templates/search-rss2.php
index 3a7b0b0..a020684 100644
--- a/templates/search-rss2.php
+++ b/templates/search-rss2.php
@@ -9,7 +9,7 @@ echo '<?xml version="1.0"?>' . "\n";
<description>Search Results</description>
<?php
if ($total_rows > 0) {
- foreach ($res->fetchAll(MDB2_FETCHMODE_ASSOC) as $row) {
+ foreach ($result as $row) {
echo " <item>\n";
echo ' <title>' . clean($row['sdesc']) . "</title>\n";
echo "
<link>{$site_method}://{$site_url}{$basedir}/{$row['id']}</link>\n";
diff --git a/www/js/userlisting.php b/www/js/userlisting.php
index e53709d..87bbf3d 100644
--- a/www/js/userlisting.php
+++ b/www/js/userlisting.php
@@ -27,14 +27,14 @@ function getAllUsers()
return $json;
}
-if (!$json = apc_fetch('svnusers')) {
+if (!file_exists("/tmp/svnusers.json") || filemetime("/tmp/svnusers.json") <
$_SERVER["REQUEST_TIME"] - 3600) {
$json = getAllUsers();
- if ($json) {
- apc_store('svnusers', $json, 3600);
- apc_store('svnusers_update', $_SERVER['REQUEST_TIME'], 3600);
- }
+ $json_data = var_export($json, true);
+ file_put_contents("/tmp/svnusers.php", '<?php $json = '.$json_data.';');
+} else {
+ include "/tmp/svnusers.php";
+ $modified = filemtime("/tmp/svnusers.php");
}
-$modified = apc_fetch('svnusers_update');
$tsstring = gmdate('D, d M Y H:i:s ', $modified);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
$_SERVER['HTTP_IF_MODIFIED_SINCE'] == $tsstring) {
diff --git a/www/report.php b/www/report.php
index 1c325f0..95098d0 100644
--- a/www/report.php
+++ b/www/report.php
@@ -76,9 +76,9 @@ if (isset($_POST['in'])) {
$query = "SELECT * from bugdb $where_clause LIMIT 5";
- $res = $dbh->prepare($query)->execute();
+ $possible_duplicates =
$dbh->prepare($query)->execute()->fetchAll();
- if ($res->numRows() == 0) {
+ if (count($possible_duplicates) == 0) {
$ok_to_submit_report = true;
} else {
response_header("Report - Confirm");
@@ -107,7 +107,7 @@ if (isset($_POST['in'])) {
</tr>
<?php
- foreach ($res->fetchAll(MDB2_FETCHMODE_ASSOC)
as $row) {
+ foreach ($possible_duplicates as $row) {
$resolution = $dbh->prepare("
SELECT comment
FROM bugdb_comments
@@ -215,11 +215,7 @@ OUTPUT;
$_SERVER['REMOTE_ADDR']
)
);
- if (PEAR::isError($res)) {
- echo "<pre>";
- var_dump($_POST['in'], $fdesc, $package_name);
- die($res->getMessage());
- }
+
$cid = $dbh->lastInsertId();
$redirectToPatchAdd = false;
diff --git a/www/rss/search.php b/www/rss/search.php
index c5b6d6c..0739404 100644
--- a/www/rss/search.php
+++ b/www/rss/search.php
@@ -28,14 +28,6 @@ if ($format === 'rss2') {
require_once '../../include/prepend.php';
require "{$ROOT_DIR}/include/query.php";
-if (!isset($res)) {
- die('Invalid query');
-} else {
- $res = $dbh->prepare($query)->execute();
- $rows = $res->numRows();
- $total_rows = $dbh->prepare('SELECT
FOUND_ROWS()')->execute()->fetchOne();
-}
-
if ($format === 'rss2') {
require "{$ROOT_DIR}/templates/search-rss2.php";
} else {
diff --git a/www/search.php b/www/search.php
index ba4ff35..40395f0 100644
--- a/www/search.php
+++ b/www/search.php
@@ -34,7 +34,10 @@ require "{$ROOT_DIR}/include/query.php";
if (isset($_GET['cmd']) && $_GET['cmd'] == 'display')
{
- if (!isset($res)) {
+ // FIXME: this if doesn't make sense, check is already performed in
+ // query.php - whole condition can be removed, reducing level of
+ // nesting by one.
+ if (!isset($result)) {
$errors[] = 'Invalid query';
} else {
// For count only, simply print the count and exit
@@ -145,7 +148,7 @@ if (isset($_GET['cmd']) && $_GET['cmd'] == 'display')
</tr>
<?php
- while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+ foreach ($result as $row) {
$status_class = $row['private'] == 'Y' ? 'Sec'
: $tla[$row['status']];
echo ' <tr valign="top" class="' ,
$status_class, '">' , "\n";--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php