0.8.7c PHP Parse Error in rrd.php

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

momo
Posts: 2
Joined: Wed Jan 28, 2009 2:22 am

0.8.7c PHP Parse Error in rrd.php

Post by momo »

Nice to meet you.
Besides, because a similar topic was not found, it writes newly. When it is my confirmation shortage, I'm sorry.

When the version improved from 0.8.7a to 0.8.7c, it was not drawn to the graph image.
It was similar though the clean install was tested.
My environment is written as follows.

・CentOS 4.7
・PHP 4.4.9
・MySQL Ver 14.12 Distrib 5.0.45

The error log of Apache when the graph image drawing is written as follows.

Code: Select all

PHP Parse error:  syntax error, unexpected '=', expecting ')' in /***/cacti-0.8.7c/lib/rrd.php on line 68, referer: http://***.net/cacti/graph_view.php?action=tree&tree_id=33
./lib/rrd.php on line 68 is being written as follows.

Code: Select all

function rrdtool_execute($command_line, $log_to_stdout, $output_flag, &$rrd_struc = array(), $logopt = "WEBLOG") {
Should I change possibly as follows?

Code: Select all

function rrdtool_execute($command_line, $log_to_stdout, $output_flag, $rrd_struc = array(), $logopt = "WEBLOG") {
When having changed like this, it seemed to have solved the problem.
:D :D
Runz
Posts: 6
Joined: Wed Jan 28, 2009 3:01 am

Post by Runz »

Same here...

CentOS 4.x
PHP 4.3.9 (Release 3.22.12)

My Workaround:

Code: Select all

--- rrd.php.orig	2009-01-27 15:10:39.000000000 +0100
+++ rrd.php	2009-01-27 17:45:03.000000000 +0100
@@ -65,7 +65,7 @@
 	}
 }
 
-function rrdtool_execute($command_line, $log_to_stdout, $output_flag, &$rrd_struc = array(), $logopt = "WEBLOG") {
+function rrdtool_execute($command_line, $log_to_stdout, $output_flag, $rrd_struc = array(), $logopt = "WEBLOG") {
 	global $config;
 
 	if (!is_numeric($output_flag)) {
@@ -92,7 +92,7 @@
 	/* use popen to eliminate the zombie issue */
 	if ($config["cacti_server_os"] == "unix") {
 		/* an empty $rrd_struc array means no fp is available */
-		if (sizeof($rrd_struc) == 0) {
+		if (sizeof($rrd_struc['fd']) == 0) {
 			session_write_close();
 			$fp = popen(read_config_option("path_rrdtool") . escape_command(" $command_line"), "r");
 		}else{
@@ -301,7 +301,7 @@
 	if ($show_source == true) {
 		return read_config_option("path_rrdtool") . " create" . RRD_NL . "$data_source_path$create_ds$create_rra";
 	}else{
-		rrdtool_execute("create $data_source_path $create_ds$create_rra", true, RRDTOOL_OUTPUT_STDOUT, $rrd_struc, "POLLER");
+		rrdtool_execute("create $data_source_path $create_ds$create_rra", true, RRDTOOL_OUTPUT_STDOUT, array(&$rrd_struc), "POLLER");
 	}
 }
 
@@ -353,7 +353,7 @@
 					$i++;
 				}
 
-				rrdtool_execute("update $rrd_path --template $rrd_update_template $rrd_update_values", true, RRDTOOL_OUTPUT_STDOUT, $rrd_struc, "POLLER");
+				rrdtool_execute("update $rrd_path --template $rrd_update_template $rrd_update_values", true, RRDTOOL_OUTPUT_STDOUT, array(&$rrd_struc), "POLLER");
 				$rrds_processed++;
 			}
 		}
@@ -535,7 +535,7 @@
 	return $fetch_array;
 }
 
-function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rrd_struc = array()) {
+function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rrd_struc) {
 	global $config, $consolidation_functions;
 
 	include_once($config["library_path"] . "/cdef.php");
@@ -1399,7 +1399,7 @@
 		print "<PRE>" . read_config_option("path_rrdtool") . " graph $graph_opts$graph_defs$txt_graph_items</PRE>";
 	}else{
 		if (isset($graph_data_array["export"])) {
-			rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrd_struc);
+			rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, array(&$rrd_struc));
 			return 0;
 		}else{
 			if (isset($graph_data_array["output_flag"])) {
@@ -1408,7 +1408,7 @@
 				$output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
 			}
 
-			return rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc);
+			return rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, array(&$rrd_struc));
 		}
 	}
 }
@@ -1972,7 +1972,7 @@
 
 	$output_flag = RRDTOOL_OUTPUT_STDOUT;
 
-	$xport_array = rrdxport2array(rrdtool_execute("xport $xport_opts$xport_defs$txt_xport_items", false, $output_flag, $rrd_struc));
+	$xport_array = rrdxport2array(rrdtool_execute("xport $xport_opts$xport_defs$txt_xport_items", false, $output_flag, array(&$rrd_struc)));
 
 	/* add host and graph information */
 	$xport_array["meta"]["title_cache"]    = $graph["title_cache"];
Changed all backreferences.
And changed $rrd_struc array check for fp. No idea... but if i let the original line sieof($rrd_struc) returns 1. And therefore the "rrd Crashed" shows up (false positive). This is why i changed the check to $rrd_struc['fd'].

Btw: This patch works for me. But it does need a review. Because I didn't analyized the whole cacti code, but just tracked back the problem and fixed this particular problem. :wink:
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Did you install from tar.gz or repository?
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
pred
Posts: 1
Joined: Thu Jan 29, 2009 3:47 am

Post by pred »

I have the same issue on windows.
Same error.
Same workaround (removing the &).

I guess it's related to the older PHP 4 version.
I am also on a older PHP 4 version -> '4.3.10)

Everything works fine with the workaround here.
Graphs are OK.
Runz
Posts: 6
Joined: Wed Jan 28, 2009 3:01 am

Post by Runz »

rony wrote:Did you install from tar.gz or repository?
Source. tar.gz (Building my own rpms) :lol:
momo
Posts: 2
Joined: Wed Jan 28, 2009 2:22 am

Post by momo »

rony wrote:Did you install from tar.gz or repository?
Both .tar.gz and .zip my installations were tested.
A problem similar as for both was caused.

When I trying with PHP 5.2.8 . PHP segmentation fault happened when ./cacti/index.php was executed, and it was not possible to display it at all.

The Apache error log is shown as follows.

Code: Select all

child pid 19588 exit signal Segmentation fault (11)
Pengu1n
Posts: 24
Joined: Fri Nov 30, 2007 2:07 am
Location: Lithuania, Vilnius
Contact:

Post by Pengu1n »

Runz wrote:Same here...

....


Changed all backreferences.
And changed $rrd_struc array check for fp. No idea... but if i let the original line sieof($rrd_struc) returns 1. And therefore the "rrd Crashed" shows up (false positive). This is why i changed the check to $rrd_struc['fd'].
i got this notice in cacti.log:

Notice: Undefined index: fd in /var/www/lib/rrd.php on line 95
Runz
Posts: 6
Joined: Wed Jan 28, 2009 3:01 am

Post by Runz »

Pengu1n wrote:
Runz wrote:Same here...
....
Changed all backreferences.
And changed $rrd_struc array check for fp. No idea... but if i let the original line sieof($rrd_struc) returns 1. And therefore the "rrd Crashed" shows up (false positive). This is why i changed the check to $rrd_struc['fd'].
i got this notice in cacti.log:
Notice: Undefined index: fd in /var/www/lib/rrd.php on line 95
It's a notice :D
Yeah, and I know that this fix is probably not the right clean solution. Maybe the devels should try to fix the problem "the right way". I did it quick&dirty. Therefore the Notice. If there isn't a $rrd_struc['fd'], you also can't get the size of :wink:

So, probably a check if the Variable is set would be the nicer way. But as I said, I did a quick&dirty. Use it on your own risk, or wait until the Cacti Developers have a clean patch for our problem. :wink:
Pengu1n
Posts: 24
Joined: Fri Nov 30, 2007 2:07 am
Location: Lithuania, Vilnius
Contact:

Post by Pengu1n »

Runz wrote:
Pengu1n wrote:
Runz wrote:Same here...
....
Changed all backreferences.
And changed $rrd_struc array check for fp. No idea... but if i let the original line sieof($rrd_struc) returns 1. And therefore the "rrd Crashed" shows up (false positive). This is why i changed the check to $rrd_struc['fd'].
i got this notice in cacti.log:
Notice: Undefined index: fd in /var/www/lib/rrd.php on line 95
It's a notice :D
Yeah, and I know that this fix is probably not the right clean solution. Maybe the devels should try to fix the problem "the right way". I did it quick&dirty. Therefore the Notice. If there isn't a $rrd_struc['fd'], you also can't get the size of :wink:

So, probably a check if the Variable is set would be the nicer way. But as I said, I did a quick&dirty. Use it on your own risk, or wait until the Cacti Developers have a clean patch for our problem. :wink:
one more thing:
in graph debug mode i found this ->
Warning: Missing argument 4 for rrdtool_function_graph() in /var/www/lib/rrd.php on line 538
pav
Posts: 6
Joined: Sat Jan 10, 2009 5:31 pm
Location: New Zealand

Modifying the rrd.php file works

Post by pav »

FYI:

Runz solution to modify the rrd.php file works perfectly. No issues since doing so (graphs display correctly).

But the new version has not resolved me issue "WARNING: Poller Output Table not Empty. Issues Found: 21, Data Sources"!

I'll keep searching for forum.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

solved with SVN#4897
Reinhard
Runz
Posts: 6
Joined: Wed Jan 28, 2009 3:01 am

Post by Runz »

gandalf wrote:solved with SVN#4897
Reinhard
Works, as far i can see. :D
Thx... and yeah, this seems to be the right way ( !isset($rrd_struc["fd"]) ) :wink:
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Unified patch for all the issues is coming this week... :(
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Runz wrote:
gandalf wrote:solved with SVN#4897
Reinhard
Works, as far i can see. :D
Thx... and yeah, this seems to be the right way ( !isset($rrd_struc["fd"]) ) :wink:
Confirmation appreciated
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests