summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install.php6
-rw-r--r--modules-available/news/install.inc.php4
-rw-r--r--modules-available/syslog/install.inc.php4
3 files changed, 7 insertions, 7 deletions
diff --git a/install.php b/install.php
index 47084528..5f5fe369 100644
--- a/install.php
+++ b/install.php
@@ -60,7 +60,7 @@ function tableHasColumn($table, $column)
return false;
}
-function tableHasIndex($table, $index)
+function tableGetIndex($table, $index)
{
$table = preg_replace('/\W/', '', $table);
if (!is_array($index)) {
@@ -79,9 +79,9 @@ function tableHasIndex($table, $index)
}
}
}
- foreach ($matches as $m) {
+ foreach ($matches as $key => $m) {
if ($m === count($index))
- return true;
+ return $key;
}
return false;
}
diff --git a/modules-available/news/install.inc.php b/modules-available/news/install.inc.php
index 43336290..88a20749 100644
--- a/modules-available/news/install.inc.php
+++ b/modules-available/news/install.inc.php
@@ -32,11 +32,11 @@ $res[] = tableCreate('vmchooser_pages', "
KEY `all3` (`type`, `expires`, `dateline`)
");
-if (tableHasIndex('vmchooser_pages', ['dateline'])) {
+if (tableGetIndex('vmchooser_pages', ['dateline']) !== false) {
Database::exec('ALTER TABLE vmchooser_pages DROP KEY `dateline`');
Database::exec('ALTER TABLE vmchooser_pages ADD KEY `type` (`type`, `dateline`)');
}
-if (!tableHasIndex('vmchooser_pages', ['type', 'expires', 'dateline'])) {
+if (tableGetIndex('vmchooser_pages', ['type', 'expires', 'dateline']) === false) {
Database::exec('ALTER TABLE vmchooser_pages ADD KEY `all3` (`type`, `expires`, `dateline`)');
}
if (!tableHasColumn('vmchooser_pages', 'expires')) {
diff --git a/modules-available/syslog/install.inc.php b/modules-available/syslog/install.inc.php
index d42a4e0e..2f306f9e 100644
--- a/modules-available/syslog/install.inc.php
+++ b/modules-available/syslog/install.inc.php
@@ -30,11 +30,11 @@ if (!tableHasColumn('clientlog', 'machineuuid')) {
}
// 2017-11-03: Create proper index for query in statistics module
-if (tableHasIndex('clientlog', ['machineuuid'])) {
+if (tableGetIndex('clientlog', ['machineuuid']) !== false) {
$r = Database::exec("ALTER TABLE `clientlog` DROP INDEX `machineuuid`");
$res[] = $r === false ? UPDATE_FAILED : UPDATE_DONE;
}
-if (!tableHasIndex('clientlog', ['machineuuid', 'logid'])) {
+if (tableGetIndex('clientlog', ['machineuuid', 'logid']) === false) {
$r = Database::exec("ALTER TABLE `clientlog`
ADD INDEX `machineuuid` ( `machineuuid` , `logid` )");
$res[] = $r === false ? UPDATE_FAILED : UPDATE_DONE;