Skip to content

Commit 0d6c11a

Browse files
committed
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 <roeland@famdouma.nl>
1 parent 3df8021 commit 0d6c11a

File tree

9 files changed

+31
-29
lines changed

9 files changed

+31
-29
lines changed

console.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,14 @@
2525
*
2626
*/
2727

28+
require_once __DIR__ . '/lib/versioncheck.php';
29+
2830
use OC\Console\Application;
2931
use Symfony\Component\Console\Input\ArgvInput;
3032
use Symfony\Component\Console\Output\ConsoleOutput;
3133

3234
define('OC_CONSOLE', 1);
3335

34-
// Show warning if a PHP version below 5.6.0 is used, this has to happen here
35-
// because base.php will already use 5.6 syntax.
36-
if (version_compare(PHP_VERSION, '5.6.0') === -1) {
37-
echo 'This version of Nextcloud requires at least PHP 5.6.0'.PHP_EOL;
38-
echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'.PHP_EOL;
39-
return;
40-
}
41-
42-
// Show warning if PHP 7.2 is used as Nextcloud is not compatible with PHP 7.2 for now
43-
// @see https://github.com/nextcloud/server/pull/5791
44-
if (version_compare(PHP_VERSION, '7.2.0') !== -1) {
45-
echo 'This version of Nextcloud is not compatible with PHP 7.2.<br/>';
46-
echo 'You are currently running ' . PHP_VERSION . '.';
47-
return;
48-
}
49-
5036
function exceptionHandler($exception) {
5137
echo "An unhandled exception has been thrown:" . PHP_EOL;
5238
echo $exception;

cron.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@
3030
*
3131
*/
3232

33-
// Show warning if a PHP version below 5.6.0 is used
34-
if (version_compare(PHP_VERSION, '5.6.0') === -1) {
35-
echo 'This version of Nextcloud requires at least PHP 5.6.0<br/>';
36-
echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.';
37-
return;
38-
}
33+
require_once __DIR__ . '/lib/versioncheck.php';
3934

4035
try {
4136

index.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@
2525
*
2626
*/
2727

28-
// Show warning if a PHP version below 5.6.0 is used, this has to happen here
29-
// because base.php will already use 5.6 syntax.
30-
if (version_compare(PHP_VERSION, '5.6.0') === -1) {
31-
echo 'This version of Nextcloud requires at least PHP 5.6.0<br/>';
32-
echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.';
33-
return;
34-
}
28+
require_once __DIR__ . '/lib/versioncheck.php';
3529

3630
// Show warning if PHP 7.2 is used as Nextcloud is not compatible with PHP 7.2 for now
3731
// @see https://github.com/nextcloud/server/pull/5791

lib/versioncheck.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
// Show warning if a PHP version below 5.6.0 is used, this has to happen here
4+
// because base.php will already use 5.6 syntax.
5+
if (version_compare(PHP_VERSION, '5.6.0'. '<')) {
6+
http_response_code(500);
7+
echo 'This version of Nextcloud requires at least PHP 5.6.0<br/>';
8+
echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.';
9+
exit(-1);
10+
}
11+
12+
// Show warning if > PHP 7.1 is used as Nextcloud 12 is not compatible with > PHP 7.1
13+
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
14+
http_response_code(500);
15+
echo 'This version of Nextcloud is not compatible with > PHP 7.2.<br/>';
16+
echo 'You are currently running ' . PHP_VERSION . '.';
17+
exit(-1);
18+
}

ocs/providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*
2424
*/
2525

26+
require_once __DIR__ . '/../lib/versioncheck.php';
2627
require_once __DIR__ . '/../lib/base.php';
2728

2829
header('Content-type: application/xml');

ocs/v1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
*/
3131

32+
require_once __DIR__ . '/../lib/versioncheck.php';
3233
require_once __DIR__ . '/../lib/base.php';
3334

3435
if (\OCP\Util::needUpgrade()

public.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
* along with this program. If not, see <http://www.gnu.org/licenses/>
2828
*
2929
*/
30+
31+
require_once __DIR__ . '/lib/versioncheck.php';
32+
3033
try {
3134

3235
require_once __DIR__ . '/lib/base.php';

remote.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
*
2929
*/
3030

31+
require_once __DIR__ . '/lib/versioncheck.php';
32+
3133
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
3234
use Sabre\DAV\Exception\ServiceUnavailable;
3335
use Sabre\DAV\Server;

status.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*
2828
*/
2929

30+
require_once __DIR__ . '/lib/versioncheck.php';
31+
3032
try {
3133

3234
require_once __DIR__ . '/lib/base.php';

0 commit comments

Comments
 (0)