Skip to content

Commit

Permalink
(base) Give a hint in web interface if SimpleXML (php-xml) is missing
Browse files Browse the repository at this point in the history
Fixes nextcloud#2180
And prevents nextcloud#31473, nextcloud#23970, nextcloud#18610, nextcloud#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 nextcloud#17163

Signed-off-by: Josh Richards <[email protected]>
  • Loading branch information
joshtrichards authored and AndyScherzinger committed Feb 27, 2024
1 parent 250084f commit 14c2b40
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,28 @@ public static function init(): void {
$bootstrapCoordinator->runInitialRegistration();

$eventLogger->start('init_session', 'Initialize session');

// Check for PHP SimpleXML extension earlier since we need it before our other checks and want to provide a useful hint for web users
// see https://github.com/nextcloud/server/pull/2619
if (!function_exists('simplexml_load_file')) {
if (!defined('OC_CONSOLE') && !self::$CLI) {
$errors[] = [
// don't translate since languages may not be available yet
'error' => 'The PHP SimpleXML/PHP-XML extension is not installed.',
'hint' => 'Install the extension or make sure it is enabled.'
];
http_response_code(503);
OC_Util::addStyle('guest');
try {
OC_Template::printGuestPage('', 'error', ['errors' => $errors]);
exit;
} catch (\Exception $e) {
// In case any error happens when showing the error page, we simply fall back to posting the text.
// This might be the case when e.g. the data directory is broken and we can not load/write SCSS to/from it.
}
}
}

OC_App::loadApps(['session']);
if (!self::$CLI) {
self::initSession();
Expand Down

0 comments on commit 14c2b40

Please sign in to comment.