Skip to content

Commit a090776

Browse files
(base) Give a hint in web interface if SimpleXML (php-xml) is missing
Fixes #2180 And prevents #31473, #23970, #18610, #15708 Avoids a 500 error and also gives a useful error message on the web interface if this module isn't installed, gets overlooked during a PHP upgrade, etc. While we check for it later, it's too late for session. Inspired by #17163 Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
1 parent b288d27 commit a090776

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

lib/base.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,28 @@ public static function init(): void {
698698
$bootstrapCoordinator->runInitialRegistration();
699699

700700
$eventLogger->start('init_session', 'Initialize session');
701+
702+
// Check for PHP SimpleXML extension earlier since we need it before our other checks and want to provide a useful hint for web users
703+
// see https://github.com/nextcloud/server/pull/2619
704+
if (!function_exists('simplexml_load_file')) {
705+
if (!defined('OC_CONSOLE') && !self::$CLI) {
706+
$errors[] = [
707+
// don't translate since languages may not be available yet
708+
'error' => 'The PHP SimpleXML/PHP-XML extension is not installed.',
709+
'hint' => 'Install the extension or make sure it is enabled.'
710+
];
711+
http_response_code(503);
712+
OC_Util::addStyle('guest');
713+
try {
714+
OC_Template::printGuestPage('', 'error', ['errors' => $errors] );
715+
exit;
716+
} catch (\Exception $e) {
717+
// In case any error happens when showing the error page, we simply fall back to posting the text.
718+
// This might be the case when e.g. the data directory is broken and we can not load/write SCSS to/from it.
719+
}
720+
}
721+
}
722+
701723
OC_App::loadApps(['session']);
702724
if (!self::$CLI) {
703725
self::initSession();

0 commit comments

Comments
 (0)