Migrate set_time_limit setup check to new API

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/42814/head
Côme Chilliet 5 months ago
parent 1334055ab8
commit a77bab2f95
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A

@ -97,6 +97,7 @@ return array(
'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => $baseDir . '/../lib/SetupChecks/MemcacheConfigured.php',
'OCA\\Settings\\SetupChecks\\OverwriteCliUrl' => $baseDir . '/../lib/SetupChecks/OverwriteCliUrl.php',
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php',
'OCA\\Settings\\SetupChecks\\PhpDisabledFunctions' => $baseDir . '/../lib/SetupChecks/PhpDisabledFunctions.php',
'OCA\\Settings\\SetupChecks\\PhpFreetypeSupport' => $baseDir . '/../lib/SetupChecks/PhpFreetypeSupport.php',
'OCA\\Settings\\SetupChecks\\PhpGetEnv' => $baseDir . '/../lib/SetupChecks/PhpGetEnv.php',
'OCA\\Settings\\SetupChecks\\PhpMemoryLimit' => $baseDir . '/../lib/SetupChecks/PhpMemoryLimit.php',

@ -112,6 +112,7 @@ class ComposerStaticInitSettings
'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => __DIR__ . '/..' . '/../lib/SetupChecks/MemcacheConfigured.php',
'OCA\\Settings\\SetupChecks\\OverwriteCliUrl' => __DIR__ . '/..' . '/../lib/SetupChecks/OverwriteCliUrl.php',
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
'OCA\\Settings\\SetupChecks\\PhpDisabledFunctions' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDisabledFunctions.php',
'OCA\\Settings\\SetupChecks\\PhpFreetypeSupport' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpFreetypeSupport.php',
'OCA\\Settings\\SetupChecks\\PhpGetEnv' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpGetEnv.php',
'OCA\\Settings\\SetupChecks\\PhpMemoryLimit' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpMemoryLimit.php',

@ -69,6 +69,7 @@ use OCA\Settings\SetupChecks\MaintenanceWindowStart;
use OCA\Settings\SetupChecks\MemcacheConfigured;
use OCA\Settings\SetupChecks\OverwriteCliUrl;
use OCA\Settings\SetupChecks\PhpDefaultCharset;
use OCA\Settings\SetupChecks\PhpDisabledFunctions;
use OCA\Settings\SetupChecks\PhpFreetypeSupport;
use OCA\Settings\SetupChecks\PhpGetEnv;
use OCA\Settings\SetupChecks\PhpMemoryLimit;
@ -191,6 +192,7 @@ class Application extends App implements IBootstrap {
$context->registerSetupCheck(MemcacheConfigured::class);
$context->registerSetupCheck(OverwriteCliUrl::class);
$context->registerSetupCheck(PhpDefaultCharset::class);
$context->registerSetupCheck(PhpDisabledFunctions::class);
$context->registerSetupCheck(PhpFreetypeSupport::class);
$context->registerSetupCheck(PhpGetEnv::class);
$context->registerSetupCheck(PhpMemoryLimit::class);

@ -123,20 +123,6 @@ class CheckSetupController extends Controller {
return $this->manager->isFairUseOfFreePushService();
}
/**
* Checks if set_time_limit is not disabled.
*
* @return bool
*/
private function isSettimelimitAvailable() {
if (function_exists('set_time_limit')
&& !str_contains(ini_get('disable_functions'), 'set_time_limit')) {
return true;
}
return false;
}
/**
* @NoCSRFRequired
* @return RedirectResponse
@ -275,7 +261,6 @@ Raw output
[
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(),
'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),

@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Côme Chilliet <come.chilliet@nextcloud.com>
*
* @author Côme Chilliet <come.chilliet@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Settings\SetupChecks;
use OCP\IL10N;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;
class PhpDisabledFunctions implements ISetupCheck {
public function __construct(
private IL10N $l10n,
) {
}
public function getName(): string {
return $this->l10n->t('PHP set_time_limit');
}
public function getCategory(): string {
return 'php';
}
public function run(): SetupResult {
if (function_exists('set_time_limit') && !str_contains(ini_get('disable_functions'), 'set_time_limit')) {
return SetupResult::success($this->l10n->t('The function is available.'));
} else {
return SetupResult::warning(
$this->l10n->t('The PHP function "set_time_limit" is not available. This could result in scripts being halted mid-execution, breaking your installation. Enabling this function is strongly recommended.'),
);
}
}
}

@ -67,7 +67,7 @@ class PhpModules implements ISetupCheck {
}
public function getCategory(): string {
return 'system';
return 'php';
}
public function run(): SetupResult {

@ -192,7 +192,6 @@ class CheckSetupControllerTest extends TestCase {
$expected = new DataResponse(
[
'reverseProxyDocs' => 'reverse-proxy-doc-link',
'isSettimelimitAvailable' => true,
'areWebauthnExtensionsEnabled' => false,
'isMysqlUsedWithoutUTF8MB4' => false,
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true,

@ -188,12 +188,6 @@
type: OC.SetupChecks.MESSAGE_TYPE_ERROR
});
}
if(!data.isSettimelimitAvailable) {
messages.push({
msg: t('core', 'The PHP function "set_time_limit" is not available. This could result in scripts being halted mid-execution, breaking your installation. Enabling this function is strongly recommended.'),
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
});
}
if (!data.areWebauthnExtensionsEnabled) {
messages.push({
msg: t(

@ -224,7 +224,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -263,7 +262,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -302,7 +300,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -331,44 +328,6 @@ describe('OC.SetupChecks tests', function() {
});
});
it('should return an error if set_time_limit is unavailable', function(done) {
var async = OC.SetupChecks.checkSetup();
suite.server.requests[0].respond(
200,
{
'Content-Type': 'application/json',
},
JSON.stringify({
isFairUseOfFreePushService: true,
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
isSettimelimitAvailable: false,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
reverseProxyGeneratedURL: 'https://server',
temporaryDirectoryWritable: true,
generic: {
network: {
"Internet connectivity": {
severity: "success",
description: null,
linkToDoc: null
}
},
},
})
);
async.done(function( data, s, x ){
expect(data).toEqual([{
msg: 'The PHP function "set_time_limit" is not available. This could result in scripts being halted mid-execution, breaking your installation. Enabling this function is strongly recommended.',
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
}]);
done();
});
});
it('should return a warning if the memory limit is below the recommended value', function(done) {
var async = OC.SetupChecks.checkSetup();
@ -380,7 +339,6 @@ describe('OC.SetupChecks tests', function() {
JSON.stringify({
isFairUseOfFreePushService: true,
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -449,7 +407,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -493,7 +450,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: true,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -534,7 +490,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -572,7 +527,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -607,7 +561,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false,
@ -644,7 +597,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: false,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -681,7 +633,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
@ -725,7 +676,6 @@ describe('OC.SetupChecks tests', function() {
},
JSON.stringify({
isFairUseOfFreePushService: true,
isSettimelimitAvailable: true,
areWebauthnExtensionsEnabled: true,
isMysqlUsedWithoutUTF8MB4: false,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,

Loading…
Cancel
Save