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

When graphing HRULE items, 'Only Variables should be passed by reference' error may be seen #2724

Closed
eschoeller opened this issue Jun 9, 2019 · 4 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@eschoeller
Copy link

I've seen this in some graphs, not in others. But across a random sampling the error(s) were present in 50% of them.

Upon viewing the RRDtool command for a given graph several of these messages will appear:

Strict Standards: Only variables should be passed by reference in /cacti/cacti-1.2.4-prod/lib/rrd.php on line 2127

image

The graph is still displayed correctly with no other issues. Seems like this is just a warning.

@eschoeller
Copy link
Author

Looks like this issue occurs on graphs with HRULEs. So, it's probably related to my other issue that was already resolved. #2662 Sorry!

@netniV
Copy link
Member

netniV commented Jun 9, 2019

Actually, you will still have this. The call to strip_alpha() expects the parameter to be variable whose value can be returned. However, the call at the line you have referenced is:

$substitute = strip_alpha(rrd_substitute_host_query_data($graph_variables['value'][$graph_item_id], $graph, $graph_item));

This is trying to pass the return value of rrd_substitute_host_query_data() to the strip_alpha() which is invalid as it's not a variable that can be updated.

@netniV netniV added the bug Undesired behaviour label Jun 9, 2019
@netniV netniV added this to the v1.2.5 milestone Jun 9, 2019
@netniV netniV changed the title [1.2.4] Strict Standards variables passed by reference In PHP strict standards mode, rrdtool_function_graph() generates ByRef message for HRULE items Jun 9, 2019
@netniV netniV closed this as completed in 2c25435 Jun 9, 2019
@cigamit cigamit added the resolved A fixed issue label Jun 24, 2019
@netniV netniV changed the title In PHP strict standards mode, rrdtool_function_graph() generates ByRef message for HRULE items When graphing HRULE items, 'Only Variables should be passed by reference' error may be seen Jul 14, 2019
@colbaip
Copy link

colbaip commented Jul 17, 2019

en lib/function.php , en la funcion strip_alpha agrege agregue (int) para asegurar que velva un numero

### **function strip_alpha(&$string) {
	/* strip all non numeric data */
	$string = trim(preg_replace('/[^0-9,.+-]/', '', $string));

	/* check the easy cases first */
	/* it has no delimiters, and no space, therefore, must be numeric */
	if (is_numeric($string) || is_float($string)) {
--		return $string;
++		return (int)$string;  ( Esto no funciona  / gracias netniV)
	} else {
		return false;
	}**

@netniV
Copy link
Member

netniV commented Jul 17, 2019

That would not work as you are assuming integer values when they could be float/decimal.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

4 participants