Skip to content

Commit 960186e

Browse files
fix: use strict MariaDB detection in install advisor (#273)
Refs #273 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 6f1a5a9 commit 960186e

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

setup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,10 +966,11 @@ function syslog_install_advisor($syslog_exists) {
966966
$type = __('Install', 'syslog');
967967
}
968968

969-
$database = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "version"');
969+
syslog_connect();
970+
$database = syslog_db_fetch_row('SHOW GLOBAL VARIABLES LIKE "version"');
970971

971-
/* remove Aria as a storage enging if this is mysql */
972-
if (stripos($database['Value'], 'mariadb') == false) {
972+
/* remove Aria as a storage engine if this is mysql */
973+
if (stripos($database['Value'], 'mariadb') === false) {
973974
unset($fields_syslog_update['engine']['array']['aria']);
974975
} else {
975976
$fields_syslog_update['engine']['value'] = 'aria';
@@ -1632,4 +1633,3 @@ function syslog_utilities_list() {
16321633
</tr>
16331634
<?php
16341635
}
1635-
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
$setup = file_get_contents(dirname(__DIR__, 2) . '/setup.php');
4+
5+
if ($setup === false) {
6+
fwrite(STDERR, "Failed to load setup.php\n");
7+
exit(1);
8+
}
9+
10+
$legacyPattern = '/stripos\s*\(\s*\$database\s*\[\s*[\'"]{1}Value[\'"]{1}\s*\]\s*,\s*[\'"]{1}mariadb[\'"]{1}\s*\)\s*==\s*false/';
11+
$fixedPattern = '/stripos\s*\(\s*\$database\s*\[\s*[\'"]{1}Value[\'"]{1}\s*\]\s*,\s*[\'"]{1}mariadb[\'"]{1}\s*\)\s*===\s*false/';
12+
13+
if (preg_match($legacyPattern, $setup)) {
14+
fwrite(STDERR, "Legacy loose MariaDB stripos comparison is still present.\n");
15+
exit(1);
16+
}
17+
18+
if (!preg_match($fixedPattern, $setup)) {
19+
fwrite(STDERR, "Strict MariaDB stripos comparison is missing.\n");
20+
exit(1);
21+
}
22+
23+
echo "issue270_mariadb_detection_strict_test passed\n";

0 commit comments

Comments
 (0)