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

Various errors can occur due to undefined or incorrect variable names #2742

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

Comments

@ddb4github
Copy link
Contributor

diff -ruEbwB -x .git cacti/install/functions.php cacti/install/functions.php
--- cacti/install/functions.php	2019-06-14 17:18:23.000000000 +0800
+++ cacti/install/functions.php	2019-06-14 16:55:25.000000000 +0800
@@ -66,7 +66,7 @@
 }

 function install_test_local_database_connection() {
-	global $database_type, $database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port, $database_ssl, $database_ssl_key, $database_ssl_cert, $database_ssl_ca;
+	global $database_type, $database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port, $database_retries, $database_ssl, $database_ssl_key, $database_ssl_cert, $database_ssl_ca;

 	if (!isset($database_ssl)) $rdatabase_ssl = false;
 	if (!isset($database_ssl_key)) $rdatabase_ssl_key = false;
@@ -84,7 +84,7 @@
 }

 function install_test_remote_database_connection() {
-	global $rdatabase_type, $rdatabase_hostname, $rdatabase_username, $rdatabase_password, $rdatabase_default, $rdatabase_type, $rdatabase_port, $rdatabase_ssl, $rdatabase_ssl_key, $rdatabase_ssl_cert, $rdatabase_ssl_ca;
+	global $rdatabase_type, $rdatabase_hostname, $rdatabase_username, $rdatabase_password, $rdatabase_default, $rdatabase_type, $rdatabase_port, $rdatabase_retries, $rdatabase_ssl, $rdatabase_ssl_key, $rdatabase_ssl_cert, $rdatabase_ssl_ca;

 	if (!isset($rdatabase_ssl)) $rdatabase_ssl = false;
 	if (!isset($rdatabase_ssl_key)) $rdatabase_ssl_key = false;
diff -ruEbwB -x .git cacti/lib/api_aggregate.php cacti/lib/api_aggregate.php
--- cacti/lib/api_device.php	2019-06-14 17:18:23.000000000 +0800
+++ cacti/lib/api_device.php	2019-06-14 16:55:25.000000000 +0800
@@ -73,7 +73,7 @@
 	);

 	if (sizeof($graphs)) {
-		api_delete_graphs($graphs);
+		api_delete_graphs($graphs, 2);
 	}

 	clear_cached_allowed_types();
diff -ruEbwB -x .git cacti/lib/api_tree.php cacti/lib/api_tree.php
--- cacti/lib/api_tree.php	2019-06-14 17:18:23.000000000 +0800
+++ cacti/lib/api_tree.php	2019-06-14 16:55:25.000000000 +0800
@@ -265,7 +265,7 @@
  * @arg $parent - The parent leaf_id to search
  * @arg $sist_id - The host_id to search for
  * @returns - the id of the leaf if it exists */
-function api_tree_site_exists($tree_id, $parent, $host_id) {
+function api_tree_site_exists($tree_id, $parent, $site_id) {
 	$id = db_fetch_cell_prepared('SELECT id
 		FROM graph_tree_items
 		WHERE graph_tree_id = ?
diff -ruEbwB -x .git cacti/lib/clog_webapi.php cacti/lib/clog_webapi.php
--- cacti/lib/clog_webapi.php	2019-06-14 17:18:23.000000000 +0800
+++ cacti/lib/clog_webapi.php	2019-06-14 17:54:36.000000000 +0800
@@ -377,6 +377,8 @@
 }

 function clog_get_logfiles() {
+	global $config;
+
 	$stdFileArray = $stdLogFileArray = $stdErrFileArray = array();
 	$configLogPath = read_config_option('path_cactilog');
 	$configLogBase = basename($configLogPath);
diff -ruEbwB -x .git cacti/lib/functions.php cacti/lib/functions.php
--- cacti/lib/functions.php	2019-06-14 17:18:23.000000000 +0800
+++ cacti/lib/functions.php	2019-06-14 16:55:25.000000000 +0800
@@ -331,6 +331,8 @@
    @arg $value       - the values to be saved
    @returns          - void */
 function set_config_option($config_name, $value) {
+	global $config;
+
 	db_execute_prepared('REPLACE INTO settings
 		SET name = ?, value = ?',
 		array($config_name, $value));
diff -ruEbwB -x .git cacti/lib/html_filter.php cacti/lib/html_filter.php
--- cacti/lib/html_filter.php	2019-06-14 17:18:23.000000000 +0800
+++ cacti/lib/html_filter.php	2019-06-14 16:55:25.000000000 +0800
@@ -111,7 +111,7 @@
 	public function get_filter_row($index) {
 		if ($index === false ) {
 			return false;
-		} elseif (array_key_exists($this->filter_array['rows'][$index])) {
+		} elseif (array_key_exists($index, $this->filter_array['rows'])) {
 			return $this->filter_array['rows'][$index];
 		} else {
 			return false;
diff -ruEbwB -x .git cacti/user_admin.php cacti/user_admin.php
--- cacti/user_admin.php	2019-06-14 17:18:23.000000000 +0800
+++ cacti/user_admin.php	2019-06-14 16:55:25.000000000 +0800
@@ -2162,7 +2162,7 @@
 		break;
 	default:
 		if (api_plugin_hook_function('user_admin_run_action', get_request_var('tab'))) {
-			user_realms_edit();
+			user_realms_edit($header_label);
 		}
 		break;
 	}
@ddb4github ddb4github changed the title PHP Validation Part#1 with diff PHP Validation: Part#1 with diff Jun 14, 2019
@netniV
Copy link
Member

netniV commented Jun 16, 2019

Most of these look good. Can I ask what the 2 is on

api_delete_graphs($graphs, 2);

There is likely a named constant that should be used in place of the 2... But I have not looked from my phnoe

@ddb4github
Copy link
Contributor Author

Most of these look good. Can I ask what the 2 is on

api_delete_graphs($graphs, 2);

There is likely a named constant that should be used in place of the 2... But I have not looked from my phnoe

Yes, should be. But, until v1.2.4, non-named constant for delete type. Both graph and device check 'delete_type' by number.

@netniV
Copy link
Member

netniV commented Jun 20, 2019

So I took a look tonight and I think I agree with you that the value should be a 2 as that also removes any unneeded data sources but I will get @cigamit to confirm.

@cigamit cigamit changed the title PHP Validation: Part#1 with diff Resolve a number of QA issues in various files Jun 22, 2019
@cigamit
Copy link
Member

cigamit commented Jun 22, 2019

Great work @ddb4github!

@cigamit cigamit added bug Undesired behaviour resolved A fixed issue labels Jun 22, 2019
cigamit added a commit that referenced this issue Jun 22, 2019
Resolve a number of QA issues in various files
@cigamit cigamit added this to the v1.2.5 milestone Jun 23, 2019
@netniV netniV changed the title Resolve a number of QA issues in various files Various can errors occur due to undefined or incorrect variable names Jul 14, 2019
@netniV netniV changed the title Various can errors occur due to undefined or incorrect variable names Various errors can occur due to undefined or incorrect variable names Jul 14, 2019
@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

3 participants