Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for PHP 8 #376

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cluster_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ function get_load_heatmap($hosts_up, $host_regex, $metrics, $load_scale, $tpl_da
if (array_key_exists($user_metricname, $metrics))
$units = $metrics[$user_metricname]['UNITS'];
} else {
if (array_key_exists($user_metricname, $metrics[key($metrics)]))
if ((!is_null($metrics[key($metrics)])) && array_key_exists($user_metricname, $metrics[key($metrics)]))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/share/ganglia/cluster_view.php:597

if (isset($metrics[key($metrics)][$user_metricname]['UNITS']))
$units = $metrics[key($metrics)][$user_metricname]['UNITS'];
else
Expand All @@ -614,7 +614,7 @@ function get_load_heatmap($hosts_up, $host_regex, $metrics, $load_scale, $tpl_da
$user['ce'],
$conf['zoom_support'],
$conf['default_optional_graph_size'],
$cluster[LOCALTIME],
$cluster['LOCALTIME'],
$tpl_data);

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -761,7 +761,7 @@ function get_load_heatmap($hosts_up, $host_regex, $metrics, $load_scale, $tpl_da
show_stacked_graphs($user['clustername'],
$user['metricname'],
$user['range'],
$cluster[LOCALTIME],
$cluster['LOCALTIME'],
$user['host_regex'],
$user['cs'],
$user['ce'],
Expand Down
6 changes: 3 additions & 3 deletions dwoo/Dwoo/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ protected function parseFunction($in, $from, $to, $parsingParams = false, $curBl
if ($func === 'tif') {
$params[] = $tokens;
}
$output = call_user_func_array($funcCompiler, $params);
$output = call_user_func_array($funcCompiler, array_values($params));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught Error: Unknown named parameter $* in /usr/share/ganglia/dwoo/Dwoo/Compiler.php:1823

Not sure if this would introduce a logic bug, but the web page looks normal.

} else {
array_unshift($params, '$this');
$params = self::implode_r($params);
Expand Down Expand Up @@ -2527,7 +2527,7 @@ protected function parseOthers($in, $from, $to, $parsingParams = false, $curBloc
}

$breaker = false;
while (list($k,$char) = each($breakChars)) {
foreach ( $breakChars as $k => $char ) {
$test = strpos($substr, $char);
if ($test !== false && $test < $end) {
$end = $test;
Expand Down Expand Up @@ -3041,7 +3041,7 @@ protected function mapParams(array $params, $callback, $callType=2, $map = null)
}

// loops over the param map and assigns values from the template or default value for unset optional params
while (list($k,$v) = each($map)) {
foreach ( $map as $k => $v ) {
if ($v[0] === '*') {
// "rest" array parameter, fill every remaining params in it and then break
if (count($ps) === 0) {
Expand Down
2 changes: 1 addition & 1 deletion dwoo/plugins/builtin/blocks/if.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function replaceKeywords(array $params, array $tokens, Dwoo_Compil
$p = array();

reset($params);
while (list($k,$v) = each($params)) {
foreach ( $params as $k => $v ) {
$v = (string) $v;
if(substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') {
$vmod = strtolower(substr($v, 1, -1));
Expand Down
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ function get_view_graph_elements($view) {
case "standard":
// Does view have any items/graphs defined
if ( count($view['items']) == 0 ) {
continue;
break;
// print "No graphs defined for this view. Please add some";
} else {
// Loop through graph items
Expand Down
2 changes: 1 addition & 1 deletion ganglia.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function Gmetad () {
}

if ($debug) print "<br/>DEBUG: Creating parser\n";
if ( in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
if ( isset($context) && is_array($context) && isset($SKIP_GMETAD_CONTEXTS) && is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /usr/share/ganglia/ganglia.php:353

return TRUE;
}
$parser = xml_parser_create();
Expand Down
6 changes: 5 additions & 1 deletion meta_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@
# above the image. Not easy with template blocks.
$cols=5;
$i = 0;
$count=count($names);
if (is_null($names)) {
$count=0;
} else {
$count=count($names);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /usr/share/ganglia/meta_view.php:211

while ($i < $count)
{
$snapnames = "";
Expand Down
4 changes: 2 additions & 2 deletions stacked.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
$command .= "TZ='" . sanitize($_SESSION['tz']) . "' ";

$command .= $conf['rrdtool'] . " graph - $rrd_options -E";
$command .= " --start '" . sanitize(${start}) . "'";
$command .= " --end '" . sanitize(${end}) . "'";
$command .= " --start '" . sanitize($start) . "'";
$command .= " --end '" . sanitize($end) . "'";
$command .= " --width 700";
$command .= " --height 300";

Expand Down