Skip to content

Commit

Permalink
Fix pass by reference error in get_allowed_devices
Browse files Browse the repository at this point in the history
get_allowed_devices has a pass by reference on the "total_rows" field.  It is used in several places to pass the total_rows back to a counter.  Here though, we are passing a number directly to the function, which errors out with "Uncaught Error: get_allowed_devices(): Argument #4 ($total_rows) cannot be passed by reference".  So we will just place a dummy variable in front to catch the pass.

This wasn't caught before because the previous parentheses issue.
  • Loading branch information
cigamit authored Feb 22, 2025
1 parent 52c25cf commit 834d52f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ function is_tree_branch_empty($tree_id, $parent = 0) {
);

if (!cacti_sizeof($sites)) {
$total_rows = -1; /* Adding to fix pass by reference error in get_allowed_devices */
if (cacti_sizeof($hosts) && cacti_sizeof(get_allowed_devices('h.id IN(' . implode(',', $hosts) . ')', 'description', '', -1)) > 0) {
return false;
}
Expand All @@ -944,7 +945,7 @@ function is_tree_branch_empty($tree_id, $parent = 0) {
), 'id', 'id'
);
}

$total_rows = -1; /* Adding to fix pass by reference error in get_allowed_devices */
if (cacti_sizeof($site_hosts) && cacti_sizeof(get_allowed_devices('h.id IN(' . implode(',', $site_hosts) . ')', 'description', '', -1)) > 0) {
return false;
}
Expand Down

0 comments on commit 834d52f

Please sign in to comment.