Skip to content

Commit a1100c9

Browse files
authored
Merge pull request #950 from hppritcha/quick_php8_fixes_for_reporter
reporter: quick fixes for php8
2 parents c4c8fa7 + 84e2cf4 commit a1100c9

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

server/php/reporter/dashboard.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function get_form_universe2($sql_cmd, $resource) {
270270
foreach (array_keys($hash[$i]) as $k)
271271
$arr[$k][] = $hash[$i][$k];
272272

273-
foreach (array_keys($arr) as $k)
273+
foreach (array_keys((array)$arr) as $k)
274274
# Do not collect timestamp entries from the ttable
275275
if (! preg_match("/timestamp/", $k))
276276
$entries[$k][] = array_unique($arr[$k]);
@@ -862,7 +862,10 @@ function selection_popups($defaults, $entries) {
862862
"\n</div>";
863863

864864
# Widen popup according to the number of menus
865-
$num_menus = sizeof($entries[$field]);
865+
$num_menus = 0;
866+
if (! is_null($entries)) {
867+
$num_menus = sizeof((array)$entries[$field]);
868+
}
866869

867870
# Yippee, selection popup
868871
if ($linkto) {
@@ -961,7 +964,7 @@ function form_popup($elements, $params, $specs) {
961964
$max = 0;
962965
foreach (array_keys($elements) as $category) {
963966
foreach (array_keys($elements[$category]) as $field) {
964-
$size = sizeof($elements[$category][$field]);
967+
$size = sizeof((array)$elements[$category][$field]);
965968
if ($size > $max)
966969
$max = $size;
967970
}

server/php/reporter/db_iface.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ function INTERNAL_db_iface_compose_sql_summary_all_fast($query) {
435435
#
436436
$groupbys = array_unique(
437437
array_merge(
438-
(array)array_keys($query['select']),
439-
(array)array_keys($query['select_more']),
440-
(array)array_keys($query['performance'])
438+
(array)array_keys((array)$query['select']),
439+
(array)array_keys((array)$query['select_more']),
440+
(array)array_keys((array)$query['performance'])
441441
)
442442
);
443443

@@ -557,8 +557,8 @@ function INTERNAL_db_iface_compose_sql_summary_fast_sub_table_base($query, $sele
557557
#
558558
$sql_cmd .= "WHERE ".$nltt;
559559
# Filter the array in case there are NULLs
560-
$sql_cmd .= join(" AND $nltt", array_filter(array_values2($query['where'])));
561-
$sql_cmd .= join(" AND $nltt", array_filter(array_values2($query['where_not'])));
560+
$sql_cmd .= join(" AND $nltt", array_filter((array)array_values2($query['where'])));
561+
$sql_cmd .= join(" AND $nltt", array_filter((array)array_values2($query['where_not'])));
562562

563563
return $sql_cmd;
564564
}
@@ -1457,7 +1457,7 @@ function is_result_column($str) {
14571457
# Return the array values that are a depth of
14581458
# 2 away from the argument passed
14591459
function array_values2($arr) {
1460-
foreach (array_keys($arr) as $k)
1460+
foreach (array_keys((array)$arr) as $k)
14611461
$ret[] = $arr[$k];
14621462

14631463
return $ret;

server/php/reporter/main_reporter.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ function display_report() {
135135
$o = offset($_GET);
136136

137137
# Prepare headers array for *_table functions
138-
$headers['params'] = array_keys($query['select']);
139-
$headers['details'] = array_keys($query['select_more']);
140-
$headers['performance'] = array_keys($query['performance']);
141-
$headers['results'] = array_keys($query['aggregates']);
138+
$headers['params'] = array_keys((array)$query['select']);
139+
$headers['details'] = array_keys((array)$query['select_more']);
140+
$headers['performance'] = array_keys((array)$query['performance']);
141+
$headers['results'] = array_keys((array)$query['aggregates']);
142142
$headers['phases'] = $phases;
143143
$headers['offset'] = $o;
144144
}
@@ -2000,7 +2000,7 @@ function is_cherry_pick($params) {
20002000

20012001
# Mutator function to clear out all cherry checkbox values
20022002
function unset_cherries(&$arr) {
2003-
foreach (array_keys($arr) as $k)
2003+
foreach (array_keys((array)$arr) as $k)
20042004
if (preg_match("/cherry_\d+/i", $k))
20052005
unset($arr[$k]);
20062006
}

server/php/reporter/reporter.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,9 @@ function tokenize($string) {
914914
$next_token !== false;
915915
$next_token = strtok(' ')) {
916916

917-
if ($next_token{0} == '"')
917+
if ($next_token[0] == '"')
918918
$next_token =
919-
$next_token{strlen($next_token) - 1} == '"' ?
919+
$next_token[strlen($next_token) - 1] == '"' ?
920920
substr($next_token, 1, -1) :
921921
substr($next_token, 1) . ' ' . strtok('"');
922922
$tokens[] = $next_token;

0 commit comments

Comments
 (0)