From 2a4676c999e8dbf9c191e41e0e745215458d1aa6 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 18 Jun 2026 09:10:28 -0500 Subject: [PATCH] fix: expand PHP extension checks (#22) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BackupEngine: check ext-zip, ext-pdo, ext-pdo_mysql, ext-mbstring before running (was only zip + mbstring). Installer preflight: warn about missing extensions (zip, pdo, pdo_mysql, mbstring, curl) during install/update. Warns but does not block installation so the component can still be configured. MokoRestore already checks ext-zip, ext-pdo_mysql, ext-mbstring, ext-json in its preflight step. composer.json already declares all six extensions as requirements (zip, pdo, pdo_mysql, curl, ftp, mbstring) — composer install fails if any are missing, which CI enforces. Closes #22 --- .../src/Engine/BackupEngine.php | 17 +++++++++++------ source/script.php | 13 +++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/source/packages/com_mokosuitebackup/src/Engine/BackupEngine.php b/source/packages/com_mokosuitebackup/src/Engine/BackupEngine.php index bf6544d..fa4a143 100644 --- a/source/packages/com_mokosuitebackup/src/Engine/BackupEngine.php +++ b/source/packages/com_mokosuitebackup/src/Engine/BackupEngine.php @@ -381,14 +381,19 @@ class BackupEngine */ private function checkRequiredExtensions(): true|string { + $required = [ + 'zip' => 'ext-zip (required for archive creation)', + 'pdo' => 'ext-pdo (required for database operations)', + 'pdo_mysql' => 'ext-pdo_mysql (required for MySQL database dumps)', + 'mbstring' => 'ext-mbstring (required for binary-safe operations)', + ]; + $missing = []; - if (!extension_loaded('zip')) { - $missing[] = 'ext-zip (required for archive creation)'; - } - - if (!extension_loaded('mbstring') && !function_exists('mb_strlen')) { - $missing[] = 'ext-mbstring (required for binary-safe operations)'; + foreach ($required as $ext => $label) { + if (!extension_loaded($ext)) { + $missing[] = $label; + } } if (!empty($missing)) { diff --git a/source/script.php b/source/script.php index f194511..4964a31 100644 --- a/source/script.php +++ b/source/script.php @@ -58,6 +58,19 @@ class Pkg_MokoSuiteBackupInstallerScript return false; } + // Check required PHP extensions (warn but don't block install) + $requiredExts = ['zip', 'pdo', 'pdo_mysql', 'mbstring', 'curl']; + $missingExts = array_filter($requiredExts, fn($ext) => !extension_loaded($ext)); + + if (!empty($missingExts)) { + Factory::getApplication()->enqueueMessage( + 'MokoSuiteBackup — Missing PHP Extensions: ' + . implode(', ', array_map(fn($e) => 'ext-' . $e, $missingExts)) + . '. Some features (backup, restore, remote upload, notifications) may not work until these are enabled.', + 'warning' + ); + } + // Save download key before Joomla re-registers the update site if ($type === 'update') { $this->preflight_saveKey();