Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug when legacy module crashed due translations constants not loaded at correct time #1065

Merged
merged 1 commit into from Oct 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion core/Controllers/LegacyController.php
Expand Up @@ -53,6 +53,22 @@ public function proxy(ServerRequestInterface $request): ResponseInterface

global $icmsTpl, $xoopsTpl, $xoopsOption, $icmsAdminTpl, $icms_admin_handler;
ob_start();

MekDrop marked this conversation as resolved.
Show resolved Hide resolved
// Never PHP needs to have all constants in file defined and this is problem with some older modules that loads a bit later translations
// so here is hack to fix this issue - load all language files at once
if (version_compare(phpversion(), '8.0', '>=')) {
/**
* @var Filesystem $modulesFs
*/
$modulesFs = \icms::getInstance()->get('filesystem.modules');
MekDrop marked this conversation as resolved.
Show resolved Hide resolved
foreach ((array)$modulesFs->listContents(\icms::$module->dirname . '/language/english/', true) as $file) {
MekDrop marked this conversation as resolved.
Show resolved Hide resolved
if (!is_array($file) || $file['type'] !== 'file' || $file['basename'][0] === '.' || $file['extension'] !== 'php') {
continue;
}
icms_loadLanguageFile(\icms::$module->dirname, $file['filename']);
MekDrop marked this conversation as resolved.
Show resolved Hide resolved
}
}

MekDrop marked this conversation as resolved.
Show resolved Hide resolved
require $path;
return new Response(
200,
Expand All @@ -73,4 +89,4 @@ public function proxy(ServerRequestInterface $request): ResponseInterface
);
}

}
}