From 88e4da2a8314cfce12af500e912cd8f658b5d540 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 13 Oct 2017 21:30:29 +0200 Subject: [PATCH] Nextcloud 12 is not compatible with newer than php 7.1 Just to avoid users from trying this with a to new (untested) php version * Moved the check logic to 1 place * All directly callable scripts just require this on top * exit hard (-1) so we know scripts won't continue * Return status 500 so no sync clients will try fancy stuff Signed-off-by: Roeland Jago Douma --- console.php | 18 ++---------------- cron.php | 7 +------ index.php | 8 +------- lib/versioncheck.php | 18 ++++++++++++++++++ ocs/providers.php | 1 + ocs/v1.php | 1 + public.php | 3 +++ remote.php | 2 ++ status.php | 2 ++ 9 files changed, 31 insertions(+), 29 deletions(-) create mode 100644 lib/versioncheck.php diff --git a/console.php b/console.php index 517032c266523..709461fc48409 100644 --- a/console.php +++ b/console.php @@ -25,28 +25,14 @@ * */ +require_once __DIR__ . '/lib/versioncheck.php'; + use OC\Console\Application; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Output\ConsoleOutput; define('OC_CONSOLE', 1); -// Show warning if a PHP version below 5.6.0 is used, this has to happen here -// because base.php will already use 5.6 syntax. -if (version_compare(PHP_VERSION, '5.6.0') === -1) { - echo 'This version of Nextcloud requires at least PHP 5.6.0'.PHP_EOL; - echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'.PHP_EOL; - return; -} - -// Show warning if PHP 7.2 is used as Nextcloud is not compatible with PHP 7.2 for now -// @see https://github.com/nextcloud/server/pull/5791 -if (version_compare(PHP_VERSION, '7.2.0') !== -1) { - echo 'This version of Nextcloud is not compatible with PHP 7.2.
'; - echo 'You are currently running ' . PHP_VERSION . '.'; - return; -} - function exceptionHandler($exception) { echo "An unhandled exception has been thrown:" . PHP_EOL; echo $exception; diff --git a/cron.php b/cron.php index 9bdb12eeaae36..c30fbac2a8ea7 100644 --- a/cron.php +++ b/cron.php @@ -30,12 +30,7 @@ * */ -// Show warning if a PHP version below 5.6.0 is used -if (version_compare(PHP_VERSION, '5.6.0') === -1) { - echo 'This version of Nextcloud requires at least PHP 5.6.0
'; - echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'; - return; -} +require_once __DIR__ . '/lib/versioncheck.php'; try { diff --git a/index.php b/index.php index 686b48aaff10e..ad789d30830a9 100644 --- a/index.php +++ b/index.php @@ -25,13 +25,7 @@ * */ -// Show warning if a PHP version below 5.6.0 is used, this has to happen here -// because base.php will already use 5.6 syntax. -if (version_compare(PHP_VERSION, '5.6.0') === -1) { - echo 'This version of Nextcloud requires at least PHP 5.6.0
'; - echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'; - return; -} +require_once __DIR__ . '/lib/versioncheck.php'; // Show warning if PHP 7.2 is used as Nextcloud is not compatible with PHP 7.2 for now // @see https://github.com/nextcloud/server/pull/5791 diff --git a/lib/versioncheck.php b/lib/versioncheck.php new file mode 100644 index 0000000000000..b7f79818c1be3 --- /dev/null +++ b/lib/versioncheck.php @@ -0,0 +1,18 @@ +'; + echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'; + exit(-1); +} + +// Show warning if > PHP 7.1 is used as Nextcloud 12 is not compatible with > PHP 7.1 +if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + http_response_code(500); + echo 'This version of Nextcloud is not compatible with > PHP 7.2.
'; + echo 'You are currently running ' . PHP_VERSION . '.'; + exit(-1); +} diff --git a/ocs/providers.php b/ocs/providers.php index 9efca14768e89..64204f485cb22 100644 --- a/ocs/providers.php +++ b/ocs/providers.php @@ -23,6 +23,7 @@ * */ +require_once __DIR__ . '/../lib/versioncheck.php'; require_once __DIR__ . '/../lib/base.php'; header('Content-type: application/xml'); diff --git a/ocs/v1.php b/ocs/v1.php index 80df64f4ed618..1dd8fb96f59e7 100644 --- a/ocs/v1.php +++ b/ocs/v1.php @@ -29,6 +29,7 @@ * */ +require_once __DIR__ . '/../lib/versioncheck.php'; require_once __DIR__ . '/../lib/base.php'; if (\OCP\Util::needUpgrade() diff --git a/public.php b/public.php index a9365d6db6393..6c3f853be8d9f 100644 --- a/public.php +++ b/public.php @@ -27,6 +27,9 @@ * along with this program. If not, see * */ + +require_once __DIR__ . '/lib/versioncheck.php'; + try { require_once __DIR__ . '/lib/base.php'; diff --git a/remote.php b/remote.php index 8e74967365df5..25cb2647a05bd 100644 --- a/remote.php +++ b/remote.php @@ -28,6 +28,8 @@ * */ +require_once __DIR__ . '/lib/versioncheck.php'; + use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin; use Sabre\DAV\Exception\ServiceUnavailable; use Sabre\DAV\Server; diff --git a/status.php b/status.php index 3d2d8f59d75cd..70b33227c9934 100644 --- a/status.php +++ b/status.php @@ -27,6 +27,8 @@ * */ +require_once __DIR__ . '/lib/versioncheck.php'; + try { require_once __DIR__ . '/lib/base.php';