From c18473f9b74747b692bf356888811c69841602ad Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Sun, 9 Sep 2012 22:01:39 +0000 Subject: fix warnings (undeclared/unset vars) --- lib.php | 29 ++++++++++++++++++----------- test_index.php | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib.php b/lib.php index dc5b378..5f4f559 100644 --- a/lib.php +++ b/lib.php @@ -67,17 +67,20 @@ function get_refined_packages_list($list_of_files, $package = null, $user = null continue; } $key = $val[6] . $val[7]; - if (!is_array($pkgs[$key])) { + if (!array_key_exists($key, $pkgs)) { $pkgs[$key] = array( - 'status' => array(), - 'path' => $val[2], - 'version' => $val[3], - 'media' => $val[4], - 'section' => $val[5], - 'user' => $val[7], - 'host' => $val[8], - 'job' => $val[9] + 'status' => array(), + 'path' => $val[2], + 'version' => $val[3], + 'media' => $val[4], + 'section' => $val[5], + 'user' => $val[7], + 'host' => $val[8], + 'job' => $val[9], + 'revision' => '', + 'summary' => '', + 'package' => '' ); } $status = $val[1]; @@ -217,7 +220,7 @@ function key2timestamp($key) { * * @return string */ -function timediff($start, $end) +function timediff($start, $end = null) { if (is_null($end)) { $end = time(); @@ -467,7 +470,11 @@ S; } else { $d = explode(' ', $duration); if ($d[0] > 20) { - $newdata['21 minutes'] += $count; + if (!array_key_exists('21 minutes', $newdata)) { + $newdata['21 minutes'] = $count; + } else { + $newdata['21 minutes'] += $count; + } } else { $newdata[$duration] = $count; } diff --git a/test_index.php b/test_index.php index c54f468..cfe9fdf 100644 --- a/test_index.php +++ b/test_index.php @@ -229,7 +229,7 @@ if ($total > 0) { } } $typestr = $p['type']; - if ($p['status']['build']) { + if (isset($p['status']['build'])) { $typealt = 'Building on'; foreach ($p['status']['build'] as $h) { $typealt .= " $h"; -- cgit v1.2.1