Skip to content

Commit 631b31b

Browse files
authored
fix(installer): prevent column-shift corruption and autoloader failure on fresh install (#16)
* fix(installer): prevent column-shift corruption and autoloader failure on fresh install Use explicit column names in every INSERT in makedata.php to prevent silent data corruption when columns are added to core tables. The modules table gained show_in_menu after the positional VALUES list was written, shifting dirname to '0' and isactive to 0 for the System module — which broke the entire install: the System module appeared as an optional checkbox (issue #12), selecting it caused duplicate template insertion errors (issue #13), and skipping it left XOOPS non-functional. Also replace Xmf\Request with raw $_COOKIE in the install wizard bootstrap (issue #11). The XMF autoloader is not reliably available at that point when xoops_lib has been relocated outside the webroot — mainfile.php does not exist yet on the first page load, so the autoloader search paths all fail. Fixes #11, fixes #12, fixes #13 * fix(installer): add explicit columns to remaining menu-seed permission inserts The two group_permission inserts in system_menu_install_seed_defaults() were still using positional VALUES without a column list. Also initialize $module_array before the system-dirname filter loop in searchform.php to prevent an undefined variable warning when all modules are filtered out.
1 parent 9c3a62d commit 631b31b

3 files changed

Lines changed: 210 additions & 197 deletions

File tree

htdocs/include/searchform.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,19 @@
4141
$criteria = new CriteriaCompo();
4242
$criteria->add(new Criteria('hassearch', 1));
4343
$criteria->add(new Criteria('isactive', 1));
44+
$criteria->add(new Criteria('dirname', 'system', '<>'));
4445
if (!empty($available_modules)) {
4546
$criteria->add(new Criteria('mid', '(' . implode(',', $available_modules) . ')', 'IN'));
4647
}
4748
/** @var XoopsModuleHandler $module_handler */
4849
$module_handler = xoops_getHandler('module');
4950
$mods_checkbox->addOptionArray($module_handler->getList($criteria));
5051
} else {
52+
$module_array = [];
5153
foreach ($modules as $mid => $module) {
54+
if ('system' === $module->getVar('dirname')) {
55+
continue;
56+
}
5257
$module_array[$mid] = $module->getVar('name');
5358
}
5459
$mods_checkbox->addOptionArray($module_array);

htdocs/install/class/installwizard.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ public function xoInit()
4141
$_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
4242
}
4343

44-
// Load the main language file
45-
$installLang = \Xmf\Request::getString('xo_install_lang', '', 'COOKIE');
44+
// Load the main language file.
45+
// Use raw $_COOKIE here — the XMF autoloader is not reliably available
46+
// this early in the install bootstrap (xoops_lib may be relocated and
47+
// mainfile.php doesn't exist yet on the first page load).
48+
$installLang = isset($_COOKIE['xo_install_lang']) ? trim((string) $_COOKIE['xo_install_lang']) : '';
4649
$this->initLanguage(!empty($installLang) ? $installLang : 'english');
4750
// Setup pages
4851
$pages = include __DIR__ . '/../include/page.php';

0 commit comments

Comments
 (0)