From 3c12ba3e16440cd0cbb18447830a02797fa3bd7c Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Fri, 6 Mar 2026 18:23:53 -0800 Subject: [PATCH 1/6] fix: use strict mariadb detection in advisor Fixes #270 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Thomas Vincent --- CHANGELOG.md | 1 + setup.php | 3 +-- ...issue270_mariadb_detection_strict_test.php | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/regression/issue270_mariadb_detection_strict_test.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1e7f2..db776c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ --- develop --- +* issue#270: Use strict MariaDB version detection in the install advisor * issue: Making changes to support Cacti 1.3 * issue: Don't use MyISAM for non-analytical tables * issue: The install advisor for Syslog was broken in current Cacti releases diff --git a/setup.php b/setup.php index a90cb01..4764de4 100644 --- a/setup.php +++ b/setup.php @@ -963,7 +963,7 @@ function syslog_install_advisor($syslog_exists) { $database = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "version"'); /* remove Aria as a storage enging if this is mysql */ - if (stripos($database['Value'], 'mariadb') == false) { + if (stripos($database['Value'], 'mariadb') === false) { unset($fields_syslog_update['engine']['array']['aria']); } else { $fields_syslog_update['engine']['value'] = 'aria'; @@ -1626,4 +1626,3 @@ function syslog_utilities_list() { Date: Fri, 6 Mar 2026 21:58:30 -0800 Subject: [PATCH 2/6] fix: correct typo 'storage enging' -> 'storage engine' in comment Signed-off-by: Thomas Vincent --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index 4764de4..ef62310 100644 --- a/setup.php +++ b/setup.php @@ -962,7 +962,7 @@ function syslog_install_advisor($syslog_exists) { $database = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "version"'); - /* remove Aria as a storage enging if this is mysql */ + /* remove Aria as a storage engine if this is mysql */ if (stripos($database['Value'], 'mariadb') === false) { unset($fields_syslog_update['engine']['array']['aria']); } else { From 2e4aced6c8bf83931a4fdf6682666b5c9f327184 Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Fri, 6 Mar 2026 22:15:42 -0800 Subject: [PATCH 3/6] fix: use syslog_db_fetch_row() for MariaDB version check in install advisor db_fetch_row() uses the main Cacti DB connection; when Syslog is configured on a separate DB server, the version check could mis-detect MariaDB vs MySQL and incorrectly toggle the Aria engine option. Signed-off-by: Thomas Vincent --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index ef62310..65d1d1e 100644 --- a/setup.php +++ b/setup.php @@ -960,7 +960,7 @@ function syslog_install_advisor($syslog_exists) { $type = __('Install', 'syslog'); } - $database = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "version"'); + $database = syslog_db_fetch_row('SHOW GLOBAL VARIABLES LIKE "version"'); /* remove Aria as a storage engine if this is mysql */ if (stripos($database['Value'], 'mariadb') === false) { From 2ea58745841482aca8aa8891f894e60bc6f1c873 Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Sat, 7 Mar 2026 05:19:54 -0800 Subject: [PATCH 4/6] tests: use preg_match patterns in issue270 MariaDB detection test strpos() exact-string matches are brittle to whitespace changes. preg_match() patterns assert operator semantics (== vs ===) without coupling to exact source formatting. Signed-off-by: Thomas Vincent Signed-off-by: Thomas Vincent --- .../regression/issue270_mariadb_detection_strict_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/regression/issue270_mariadb_detection_strict_test.php b/tests/regression/issue270_mariadb_detection_strict_test.php index 65b19db..85112b6 100644 --- a/tests/regression/issue270_mariadb_detection_strict_test.php +++ b/tests/regression/issue270_mariadb_detection_strict_test.php @@ -7,15 +7,15 @@ exit(1); } -$legacy = "stripos(\$database['Value'], 'mariadb') == false"; -$fixed = "stripos(\$database['Value'], 'mariadb') === false"; +$legacyPattern = '/stripos\s*\(\s*\$database\s*\[\s*[\'"]{1}Value[\'"]{1}\s*\]\s*,\s*[\'"]{1}mariadb[\'"]{1}\s*\)\s*==\s*false/'; +$fixedPattern = '/stripos\s*\(\s*\$database\s*\[\s*[\'"]{1}Value[\'"]{1}\s*\]\s*,\s*[\'"]{1}mariadb[\'"]{1}\s*\)\s*===\s*false/'; -if (strpos($setup, $legacy) !== false) { +if (preg_match($legacyPattern, $setup)) { fwrite(STDERR, "Legacy loose MariaDB stripos comparison is still present.\n"); exit(1); } -if (strpos($setup, $fixed) === false) { +if (!preg_match($fixedPattern, $setup)) { fwrite(STDERR, "Strict MariaDB stripos comparison is missing.\n"); exit(1); } From 6879c5968234b52b3344eb0ca0c1a8e3677a7e24 Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Sat, 7 Mar 2026 22:27:32 -0800 Subject: [PATCH 5/6] fix: call syslog_connect() before version query in syslog_install_advisor() When the syslog plugin uses a dedicated DB server (use_cacti_db=false), the MariaDB/MySQL version check must run against the syslog connection, not the main Cacti connection. syslog_connect() establishes that connection; without it, db_fetch_row() would query the wrong server and mis-detect the engine type. Signed-off-by: Thomas Vincent --- setup.php | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.php b/setup.php index 65d1d1e..815e5c1 100644 --- a/setup.php +++ b/setup.php @@ -960,6 +960,7 @@ function syslog_install_advisor($syslog_exists) { $type = __('Install', 'syslog'); } + syslog_connect(); $database = syslog_db_fetch_row('SHOW GLOBAL VARIABLES LIKE "version"'); /* remove Aria as a storage engine if this is mysql */ From 0a110bfd281ee188a16375bd930093fa2a99057c Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Sun, 8 Mar 2026 03:55:26 -0700 Subject: [PATCH 6/6] chore: add CHANGELOG entry for develop Signed-off-by: Thomas Vincent --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db776c1..6a9f40a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ --- develop --- -* issue#270: Use strict MariaDB version detection in the install advisor +* issue#270: Switch MariaDB version detection to strict stripos comparison to avoid falsey ambiguity * issue: Making changes to support Cacti 1.3 * issue: Don't use MyISAM for non-analytical tables * issue: The install advisor for Syslog was broken in current Cacti releases