getTime() must be of the type string, null returned

Hi,

I’m facing with the following error in our NC log:

Exception: Return value of OCA\ServerInfo\OperatingSystems\DefaultOs::getTime() must be of the type string, null returned

/var/www/d85_0/html/nextcloud/lib/private/AppFramework/App.php - line 156:

OC\AppFramework\Http\Dispatcher->dispatch()

/var/www/d85_0/html/nextcloud/lib/private/Route/Router.php - line 302:

OC\AppFramework\App::main()

/var/www/d85_0/html/nextcloud/ocs/v1.php - line 62:

OC\Route\Router->match()

/var/www/d85_0/html/nextcloud/ocs/v2.php - line 23:

require_once("/var/www/d8 ... p")

Verursacht durch TypeError: Return value of OCA\ServerInfo\OperatingSystems\DefaultOs::getTime() must be of the type string, null returned

/var/www/d85_0/html/nextcloud/apps/serverinfo/lib/Os.php - line 89:

OCA\ServerInfo\OperatingSystems\DefaultOs->getTime()

/var/www/d85_0/html/nextcloud/apps/serverinfo/lib/Controller/ApiController.php - line 179:

OCA\ServerInfo\Os->getTime()

/var/www/d85_0/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 217:

OCA\ServerInfo\Controller\ApiController->BasicData()

/var/www/d85_0/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 126:

OC\AppFramework\Http\Dispatcher->executeController()

/var/www/d85_0/html/nextcloud/lib/private/AppFramework/App.php - line 156:

OC\AppFramework\Http\Dispatcher->dispatch()

/var/www/d85_0/html/nextcloud/lib/private/Route/Router.php - line 302:

OC\AppFramework\App::main()

/var/www/d85_0/html/nextcloud/ocs/v1.php - line 62:

OC\Route\Router->match()

/var/www/d85_0/html/nextcloud/ocs/v2.php - line 23:

require_once("/var/www/d8 ... p")

The error is thrown countless times. We startet our NC with version 21 and upgraded to the newest, error was thrown from the beginning and still remains.

Our configuration:
Nextcloud Version: 22.2.3
Server OS: Gentoo Linux 5.10.76
PHP: 7.4.26
DB: mysql 8.0.25

Maybe a type error with gentoo linux?

Hi mueckste,

the getTime() function in the serverinfo has been assigned the type string but yours is returning NULL.

This is the function in question:

public function getTime(): string {
		$date = shell_exec('date');
		return $date;
	}

Since the function is using shell_exec it could be possible, that your webhosting doesn’t allow the execution of shell_exec, hence it returns NULL.

You can test this by creating a simple PHP file in your webspace root with the following content and see what shows up in your browser, when you open the URL to the PHP file in your browser:

<? php
echo shell_exec ("hostname");

The output should be the hostname of your machine. If it doesn’t show the hostname of your machine and maybe an error instead, you may have to enable the execution of shell_exec in your php config or check with your webhoster (in case you are not hosting yourself)