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

Fix: month, year, physical_view, etc. in php8 #379

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PHPCBF = phpcbf
##########################################################

# Gweb version
GWEB_VERSION = 3.7.5
GWEB_VERSION = 3.7.7

DIST_NAME = ganglia-web
DIST_DIR = $(DIST_NAME)-$(GWEB_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion cluster_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ function get_cluster_overview($showhosts,
$overview["cluster_load"] = join(", ", $cluster_load);

$avg_cpu_num = find_avg($clustername, "", "cpu_num");
if ($avg_cpu_num == 0)
if ((float)$avg_cpu_num == 0)
$avg_cpu_num = 1;
$cluster_util =
sprintf("%.0f%%",
Expand Down
6 changes: 3 additions & 3 deletions dwoo/Dwoo/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ public function readVarInto($varstr, $data, $safeRead = false)
}
unset($varstr);

while (list($k, $sep) = each($m[1])) {
foreach ($m[1] as $k => $sep) {
if ($sep === '.' || $sep === '[' || $sep === '') {
// strip enclosing quotes if present
$m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]);
Expand Down Expand Up @@ -1425,7 +1425,7 @@ public function readVar($varstr)
$cur = $this->scope;
}

while (list($k, $sep) = each($m[1])) {
foreach ($m[1] as $k => $sep) {
if ($sep === '.' || $sep === '[' || $sep === '') {
if ((is_array($cur) || $cur instanceof ArrayAccess) && isset($cur[$m[2][$k]])) {
$cur = $cur[$m[2][$k]];
Expand Down Expand Up @@ -1470,7 +1470,7 @@ public function assignInScope($value, $scope)
$cur =& $this->scope;
$last = array(array_pop($m[1]), array_pop($m[2]));

while (list($k, $sep) = each($m[1])) {
foreach ($m[1] as $k => $sep) {
if ($sep === '.' || $sep === '[' || $sep === '') {
if (is_array($cur) === false) {
$cur = array();
Expand Down
5 changes: 3 additions & 2 deletions dwoo/Dwoo/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function setData(array $data)
public function mergeData(array $data)
{
$args = func_get_args();
while (list(,$v) = each($args)) {
foreach ($args as $v) {
if (is_array($v)) {
$this->data = array_merge($this->data, $v);
}
Expand All @@ -90,8 +90,9 @@ public function assign($name, $val = null)
{
if (is_array($name)) {
reset($name);
while (list($k,$v) = each($name))
foreach ($name as $k => $v) {
$this->data[$k] = $v;
}
} else {
$this->data[$name] = $val;
}
Expand Down
2 changes: 1 addition & 1 deletion dwoo/plugins/builtin/blocks/textformat.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function process()
// gets paragraphs
$pgs = explode("\n", str_replace(array("\r\n", "\r"), "\n", $this->buffer));

while (list($i,) = each($pgs)) {
foreach ($pgs as $i => $values) {
if (empty($pgs[$i])) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion dwoo/plugins/builtin/functions/capitalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Dwoo_Plugin_capitalize(Dwoo_Core $dwoo, $value, $numwords=false)
} else {
$bits = explode(' ', (string) $value);
$out = '';
while (list(,$v) = each($bits)) {
foreach ($bits as $v) {
if (preg_match('#^[^0-9]+$#', $v)) {
$out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
} else {
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 ( isset($context) && is_array($context) && isset($SKIP_GMETAD_CONTEXTS) && is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
if ( is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
return TRUE;
}
$parser = xml_parser_create();
Expand Down
2 changes: 1 addition & 1 deletion get_ganglia.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# If we are in compare_hosts, views and decompose_graph context we shouldn't attempt
# any connections to the gmetad
if (! in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
if (! ( is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) ) {
if (! Gmetad($conf['ganglia_ip'], $conf['ganglia_port']) )
{
print "<H4>There was an error collecting ganglia data ".
Expand Down
1 change: 1 addition & 0 deletions graph.d/metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function graph_metric ( &$rrdtool_graph ) {
}

$prefix = $summary ? $metricname : $hostname;
$value = (float)$value;
$value = ($value > 1000)
? number_format($value)
: number_format($value, 2);
Expand Down
2 changes: 1 addition & 1 deletion graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ function execute_graph_command($graph_engine, $command) {

// Fix from Phil Radden, but step is not always 15 anymore.
if ($range == "month")
$rrdtool_graph['end'] = floor($rrdtool_graph['end'] / 672) * 672;
$rrdtool_graph['end'] = floor((int)$rrdtool_graph['end'] / 672) * 672;

///////////////////////////////////////////////////////////////////////////////
// Are we generating aggregate graphs
Expand Down
2 changes: 1 addition & 1 deletion meta_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

$clusname = $source == $self ? '' : $source;
$avg_cpu_num = find_avg($clusname, "", "cpu_num");
if ($avg_cpu_num == 0) $avg_cpu_num = 1;
if ((float)$avg_cpu_num == 0) $avg_cpu_num = 1;
$cluster_util = sprintf("%.0f", ((double) find_avg($clusname, "", "load_one") / $avg_cpu_num ) * 100);

$sources[$source]["name"] = $name;
Expand Down
2 changes: 1 addition & 1 deletion mobile_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
} else if (isset($reports[$metric_name]) and $reports[$metric])
continue;
else {
$metric_graphargs = "c=".rawurlencode($clustername)."&amp;h=".rawurlencode($hostname)."&amp;v=".rawurlencode($metric_attributes[VAL])
$metric_graphargs = "c=".rawurlencode($clustername)."&amp;h=".rawurlencode($hostname)."&amp;v=".rawurlencode($metric_attributes['VAL'])
."&amp;m=$metric_name&amp;r=".rawurlencode($range)."&amp;z=$size&amp;jr=$jobrange"
."&amp;js=$jobstart&amp;st=$cluster[LOCALTIME]";
if ($cs)
Expand Down
2 changes: 1 addition & 1 deletion physical_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function physical_racks() {
else {
ksort($racks);
reset($racks);
while (list($rack,) = each($racks)) {
foreach ($racks as $rack => $values) {
# In our convention, y=0 is close to the floor. (Easier to wire up)
krsort($racks[$rack]);
}
Expand Down
6 changes: 5 additions & 1 deletion pie.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ function draw_slices( $x, $y, $angles, $colors ) {

$x; //PHPCS
$y; //PHPCS
$pie_count = count( $angles );
if is_null( $angles ) {
$pie_count = 0;
} else {
$pie_count = count( $angles );
}
$PIE_THICKNESS = ($this->diameter * 0.075);

for( $j = ($this->center_y+$PIE_THICKNESS); $j > $this->center_y; $j-- ) {
Expand Down
2 changes: 1 addition & 1 deletion templates/default/footer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Loading view, please wait...<img src="img/spinner.gif" />
<div align="center" class="footer" style="font-size:small;clear:both;" {if $hide_footer} style="visibility:hidden;display:none;" {/if}>
<hr />
Ganglia Web Frontend version {$webfrontend_version}
<a href="http://ganglia.sourceforge.net/downloads.php?component=ganglia-webfrontend&amp;version={$webfrontend_version}">Check for Updates.</a><br />
<a href="https://github.com/ganglia/ganglia-web" target="_blank">Check for Updates.</a><br />

Ganglia Web Backend <i>({$webbackend_component})</i> version {$webbackend_version}
<a href="http://ganglia.sourceforge.net/downloads.php?component={$webbackend_component}&amp;version={$webbackend_version}">Check for Updates.</a><br />
Expand Down