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 undefined variables generate errors within database.php #2622

Closed
ddb4github opened this issue Apr 7, 2019 · 1 comment
Closed

Various undefined variables generate errors within database.php #2622

ddb4github opened this issue Apr 7, 2019 · 1 comment
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@ddb4github
Copy link
Contributor

  1. missed global $config
  2. typo '$k' to '$key'
--- lib/database.php	2019-04-03 19:13:09.383859716 +0800
+++ lib/database.php	2019-04-08 01:00:51.986580645 +0800
@@ -642,7 +642,7 @@
    @param $log - whether to log error messages, defaults to true
    @returns - (bool) the output of the sql query as a single variable */
 function db_index_exists($table, $index, $log = true, $db_conn = false) {
-	global $database_log;
+	global $database_log, $config;
 	if (!isset($database_log)) {
 		$database_log = false;
 	}
@@ -670,7 +670,7 @@
    @param $log - whether to log error messages, defaults to true
    @returns - (bool) the output of the sql query as a single variable */
 function db_index_matches($table, $index, $columns, $log = true, $db_conn = false) {
-	global $database_log;
+	global $database_log, $config;
 	if (!isset($database_log)) {
 		$database_log = false;
 	}
@@ -924,7 +924,7 @@
 					$del = array_diff($index, $k['columns']);
 					if (!empty($add) || !empty($del)) {
 						if (!db_execute("ALTER TABLE `$table` DROP INDEX `$n`", $log, $db_conn) ||
-						    !db_execute("ALTER TABLE `$table` ADD INDEX `$n` (" . $k['name'] . '` (' . db_format_index_create($key['columns']) . ')', $log, $db_conn)) {
+						    !db_execute("ALTER TABLE `$table` ADD INDEX `$n` (" . $k['name'] . '` (' . db_format_index_create($k['columns']) . ')', $log, $db_conn)) {
 							return false;
 						}
 					}
@@ -944,7 +944,7 @@
 	if (isset($data['keys'])) {
 		foreach ($data['keys'] as $k) {
 			if (!isset($allindexes[$k['name']])) {
-				if (!db_execute("ALTER TABLE `$table` ADD INDEX `" . $k['name'] . '` (' . db_format_index_create($key['columns']) . ')', $log, $db_conn)) {
+				if (!db_execute("ALTER TABLE `$table` ADD INDEX `" . $k['name'] . '` (' . db_format_index_create($k['columns']) . ')', $log, $db_conn)) {
 					return false;
 				}
 			}
cigamit added a commit that referenced this issue Apr 10, 2019
Various PHP undefined variable in database.php
@cigamit
Copy link
Member

cigamit commented Apr 10, 2019

Good catch. Resolved.

@cigamit cigamit added bug Undesired behaviour resolved A fixed issue labels Apr 10, 2019
@cigamit cigamit added this to the v1.2.4 milestone Apr 17, 2019
@cigamit cigamit closed this as completed Apr 25, 2019
@netniV netniV changed the title Various PHP undefined variable in database.php Various undefined variables generate errors within database.php Apr 28, 2019
@github-actions github-actions bot locked as resolved 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

2 participants