1<?php 2 3use App\Repository\PackageRepository; 4 5require '../include/prepend.php'; 6 7function status_print ($status, $num, $width, $align = STR_PAD_LEFT) 8{ 9 echo ucfirst($status), ':', str_pad($num, $width - strlen($status), ' ', $align), "\n\n"; 10} 11 12function get_status_count ($status, $category = '') 13{ 14 global $phpver, $dbh; 15 16 $query = "SELECT count(id) from bugdb WHERE"; 17 18 if ($phpver > 0) { 19 $query .= " php_version LIKE '{$phpver}%' AND"; 20 } 21 22 /* Categories which are excluded from bug count */ 23 $excluded = "'Feature/Change Request', 'Systems problem', 'Website Problem', 'PEAR related', 'PECL related', 'Documentation problem', 'Translation problem', 'PHP-GTK related', 'Online Doc Editor problem'"; 24 25 if ($category != '') { 26 $query.= " {$status} AND bug_type = 'Bug' AND package_name = " . $dbh->quote($category); 27 } else { 28 $query.= " status='{$status}' "; 29 } 30 $query.= "AND bug_type NOT IN({$excluded})"; 31 32 $res = $dbh->prepare($query)->execute([]); 33 $row = $res->fetch(\PDO::FETCH_NUM); 34 35 return $row[0]; 36} 37 38// Input 39$phpver = (isset($_GET['phpver']) ? (int) $_GET['phpver'] : false); 40 41if (!$phpver || ($phpver !== 5 && $phpver !== 7)) { 42 echo "<h3>Bug stats for both <a href='lstats.php?phpver=5'>PHP 5</a> and <a href='lstats.php?phpver=7'>PHP 7</a>:</h3>\n<pre>\n"; 43} else { 44 echo "<h3>Bug stats for PHP $phpver:</h3>\n<pre>\n"; 45} 46 47if (isset($_GET['per_category'])) 48{ 49 $packageRepository = $container->get(PackageRepository::class); 50 $pseudo_pkgs = $packageRepository->findAll($_GET['project'] ?? ''); 51 52 $totals = []; 53 foreach ($pseudo_pkgs as $category => $data) { 54 $count = get_status_count ("status NOT IN('to be documented', 'closed', 'not a bug', 'duplicate', 'wont fix', 'no feedback')", $category); 55 if ($count > 0) { 56 $totals[$category] = $count; 57 } 58 } 59 arsort($totals); 60 foreach ($totals as $category => $total) { 61 status_print($category, $total, 40); 62 } 63 64} else { 65 66 foreach ($tla as $status => $short) { 67 if (!in_array($status, ['Duplicate'])) { 68 $count = get_status_count ($status); 69 status_print($status, $count, 30); 70 } 71 } 72 73} 74 75echo "\n</pre>\n"; 76