Don't use deprecated getIniWrapper() anymore

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-08-20 14:08:18 +02:00 committed by Morris Jobke
parent 420a3762cb
commit b09620651c
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
14 changed files with 52 additions and 39 deletions

View File

@ -23,8 +23,8 @@
<input type="hidden" name="hideDownload" value="<?php p($_['hideDownload'] ? 'true' : 'false'); ?>" id="hideDownload"> <input type="hidden" name="hideDownload" value="<?php p($_['hideDownload'] ? 'true' : 'false'); ?>" id="hideDownload">
<input type="hidden" id="disclaimerText" value="<?php p($_['disclaimer']) ?>"> <input type="hidden" id="disclaimerText" value="<?php p($_['disclaimer']) ?>">
<?php <?php
$upload_max_filesize = OC::$server->getIniWrapper()->getBytes('upload_max_filesize'); $upload_max_filesize = OC::$server->get(\bantu\IniGetWrapper\IniGetWrapper::class)->getBytes('upload_max_filesize');
$post_max_size = OC::$server->getIniWrapper()->getBytes('post_max_size'); $post_max_size = OC::$server->get(\bantu\IniGetWrapper\IniGetWrapper::class)->getBytes('post_max_size');
$maxUploadFilesize = min($upload_max_filesize, $post_max_size); $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
?> ?>
<input type="hidden" name="maxFilesizeUpload" value="<?php p($maxUploadFilesize); ?>" id="maxFilesizeUpload"> <input type="hidden" name="maxFilesizeUpload" value="<?php p($maxUploadFilesize); ?>" id="maxFilesizeUpload">

View File

@ -98,6 +98,8 @@ class CheckSetupController extends Controller {
private $memoryInfo; private $memoryInfo;
/** @var ISecureRandom */ /** @var ISecureRandom */
private $secureRandom; private $secureRandom;
/** @var IniGetWrapper */
private $iniGetWrapper;
public function __construct($AppName, public function __construct($AppName,
IRequest $request, IRequest $request,
@ -112,7 +114,8 @@ class CheckSetupController extends Controller {
ILockingProvider $lockingProvider, ILockingProvider $lockingProvider,
IDateTimeFormatter $dateTimeFormatter, IDateTimeFormatter $dateTimeFormatter,
MemoryInfo $memoryInfo, MemoryInfo $memoryInfo,
ISecureRandom $secureRandom) { ISecureRandom $secureRandom,
IniGetWrapper $iniGetWrapper) {
parent::__construct($AppName, $request); parent::__construct($AppName, $request);
$this->config = $config; $this->config = $config;
$this->clientService = $clientService; $this->clientService = $clientService;
@ -126,6 +129,7 @@ class CheckSetupController extends Controller {
$this->dateTimeFormatter = $dateTimeFormatter; $this->dateTimeFormatter = $dateTimeFormatter;
$this->memoryInfo = $memoryInfo; $this->memoryInfo = $memoryInfo;
$this->secureRandom = $secureRandom; $this->secureRandom = $secureRandom;
$this->iniGetWrapper = $iniGetWrapper;
} }
/** /**
@ -407,25 +411,23 @@ Raw output
* @return bool * @return bool
*/ */
protected function isOpcacheProperlySetup() { protected function isOpcacheProperlySetup() {
$iniWrapper = new IniGetWrapper(); if (!$this->iniGetWrapper->getBool('opcache.enable')) {
if (!$iniWrapper->getBool('opcache.enable')) {
return false; return false;
} }
if (!$iniWrapper->getBool('opcache.save_comments')) { if (!$this->iniGetWrapper->getBool('opcache.save_comments')) {
return false; return false;
} }
if ($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { if ($this->iniGetWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
return false; return false;
} }
if ($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { if ($this->iniGetWrapper->getNumeric('opcache.memory_consumption') < 128) {
return false; return false;
} }
if ($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { if ($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
return false; return false;
} }

View File

@ -32,6 +32,7 @@
namespace OC\Core\Command\Maintenance; namespace OC\Core\Command\Maintenance;
use bantu\IniGetWrapper\IniGetWrapper;
use InvalidArgumentException; use InvalidArgumentException;
use OC\Installer; use OC\Installer;
use OC\Setup; use OC\Setup;
@ -46,14 +47,15 @@ use Symfony\Component\Console\Question\Question;
class Install extends Command { class Install extends Command {
/** /** @var SystemConfig */
* @var SystemConfig
*/
private $config; private $config;
/** @var IniGetWrapper */
private $iniGetWrapper;
public function __construct(SystemConfig $config) { public function __construct(SystemConfig $config, IniGetWrapper $iniGetWrapper) {
parent::__construct(); parent::__construct();
$this->config = $config; $this->config = $config;
$this->iniGetWrapper = $iniGetWrapper;
} }
protected function configure() { protected function configure() {
@ -79,7 +81,7 @@ class Install extends Command {
$server = \OC::$server; $server = \OC::$server;
$setupHelper = new Setup( $setupHelper = new Setup(
$this->config, $this->config,
$server->getIniWrapper(), $this->iniGetWrapper,
$server->getL10N('lib'), $server->getL10N('lib'),
$server->query(Defaults::class), $server->query(Defaults::class),
$server->getLogger(), $server->getLogger(),

View File

@ -936,7 +936,7 @@ class OC {
\OC::$server->getSession()->clear(); \OC::$server->getSession()->clear();
$setupHelper = new OC\Setup( $setupHelper = new OC\Setup(
$systemConfig, $systemConfig,
\OC::$server->getIniWrapper(), \OC::$server->get(\bantu\IniGetWrapper\IniGetWrapper::class),
\OC::$server->getL10N('lib'), \OC::$server->getL10N('lib'),
\OC::$server->query(\OCP\Defaults::class), \OC::$server->query(\OCP\Defaults::class),
\OC::$server->getLogger(), \OC::$server->getLogger(),

View File

@ -29,6 +29,8 @@
namespace OC; namespace OC;
use bantu\IniGetWrapper\IniGetWrapper;
/** /**
* Helper class for large files on 32-bit platforms. * Helper class for large files on 32-bit platforms.
*/ */
@ -117,7 +119,7 @@ class LargeFileHelper {
* null on failure. * null on failure.
*/ */
public function getFileSizeViaCurl($fileName) { public function getFileSizeViaCurl($fileName) {
if (\OC::$server->getIniWrapper()->getString('open_basedir') === '') { if (\OC::$server->get(IniGetWrapper::class)->getString('open_basedir') === '') {
$encodedFileName = rawurlencode($fileName); $encodedFileName = rawurlencode($fileName);
$ch = curl_init("file:///$encodedFileName"); $ch = curl_init("file:///$encodedFileName");
curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_NOBODY, true);

View File

@ -28,6 +28,7 @@
namespace OC\Memcache; namespace OC\Memcache;
use bantu\IniGetWrapper\IniGetWrapper;
use OCP\IMemcache; use OCP\IMemcache;
class APCu extends Cache implements IMemcache { class APCu extends Cache implements IMemcache {
@ -154,9 +155,9 @@ class APCu extends Cache implements IMemcache {
public static function isAvailable() { public static function isAvailable() {
if (!extension_loaded('apcu')) { if (!extension_loaded('apcu')) {
return false; return false;
} elseif (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) { } elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enabled')) {
return false; return false;
} elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) { } elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enable_cli') && \OC::$CLI) {
return false; return false;
} elseif ( } elseif (
version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 && version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 &&

View File

@ -1012,7 +1012,7 @@ class Server extends ServerContainer implements IServerContainer {
return $factory->getLDAPProvider(); return $factory->getLDAPProvider();
}); });
$this->registerService(ILockingProvider::class, function (Server $c) { $this->registerService(ILockingProvider::class, function (Server $c) {
$ini = $c->getIniWrapper(); $ini = $c->get(IniGetWrapper::class);
$config = $c->getConfig(); $config = $c->getConfig();
$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
@ -1953,7 +1953,7 @@ class Server extends ServerContainer implements IServerContainer {
* @deprecated * @deprecated
*/ */
public function getIniWrapper() { public function getIniWrapper() {
return $this->query('IniWrapper'); return $this->query(IniGetWrapper::class);
} }
/** /**

View File

@ -503,7 +503,7 @@ class Setup {
$setupHelper = new \OC\Setup( $setupHelper = new \OC\Setup(
$config, $config,
\OC::$server->getIniWrapper(), \OC::$server->get(IniGetWrapper::class),
\OC::$server->getL10N('lib'), \OC::$server->getL10N('lib'),
\OC::$server->query(Defaults::class), \OC::$server->query(Defaults::class),
\OC::$server->getLogger(), \OC::$server->getLogger(),

View File

@ -31,30 +31,30 @@
namespace OC; namespace OC;
use bantu\IniGetWrapper\IniGetWrapper;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger;
use OCP\ITempManager; use OCP\ITempManager;
use Psr\Log\LoggerInterface;
class TempManager implements ITempManager { class TempManager implements ITempManager {
/** @var string[] Current temporary files and folders, used for cleanup */ /** @var string[] Current temporary files and folders, used for cleanup */
protected $current = []; protected $current = [];
/** @var string i.e. /tmp on linux systems */ /** @var string i.e. /tmp on linux systems */
protected $tmpBaseDir; protected $tmpBaseDir;
/** @var ILogger */ /** @var LoggerInterface */
protected $log; protected $log;
/** @var IConfig */ /** @var IConfig */
protected $config; protected $config;
/** @var IniGetWrapper */
protected $iniGetWrapper;
/** Prefix */ /** Prefix */
public const TMP_PREFIX = 'oc_tmp_'; public const TMP_PREFIX = 'oc_tmp_';
/** public function __construct(LoggerInterface $logger, IConfig $config, IniGetWrapper $iniGetWrapper) {
* @param \OCP\ILogger $logger
* @param \OCP\IConfig $config
*/
public function __construct(ILogger $logger, IConfig $config) {
$this->log = $logger; $this->log = $logger;
$this->config = $config; $this->config = $config;
$this->iniGetWrapper = $iniGetWrapper;
$this->tmpBaseDir = $this->getTempBaseDir(); $this->tmpBaseDir = $this->getTempBaseDir();
} }
@ -218,7 +218,7 @@ class TempManager implements ITempManager {
if ($temp = $this->config->getSystemValue('tempdirectory', null)) { if ($temp = $this->config->getSystemValue('tempdirectory', null)) {
$directories[] = $temp; $directories[] = $temp;
} }
if ($temp = \OC::$server->getIniWrapper()->get('upload_tmp_dir')) { if ($temp = $this->iniGetWrapper->get('upload_tmp_dir')) {
$directories[] = $temp; $directories[] = $temp;
} }
if ($temp = getenv('TMP')) { if ($temp = getenv('TMP')) {

View File

@ -44,6 +44,7 @@
namespace OC; namespace OC;
use bantu\IniGetWrapper\IniGetWrapper;
use OC\Search\SearchQuery; use OC\Search\SearchQuery;
use OC\Template\JSCombiner; use OC\Template\JSCombiner;
use OC\Template\JSConfigHelper; use OC\Template\JSConfigHelper;
@ -202,7 +203,7 @@ class TemplateLayout extends \OC_Template {
\OC::$server->getUserSession()->getUser(), \OC::$server->getUserSession()->getUser(),
$this->config, $this->config,
\OC::$server->getGroupManager(), \OC::$server->getGroupManager(),
\OC::$server->getIniWrapper(), \OC::$server->get(IniGetWrapper::class),
\OC::$server->getURLGenerator(), \OC::$server->getURLGenerator(),
\OC::$server->getCapabilitiesManager(), \OC::$server->getCapabilitiesManager(),
\OC::$server->query(IInitialStateService::class) \OC::$server->query(IInitialStateService::class)

View File

@ -41,6 +41,7 @@
* *
*/ */
use bantu\IniGetWrapper\IniGetWrapper;
use OC\Files\View; use OC\Files\View;
use OC\Streamer; use OC\Streamer;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;
@ -164,7 +165,7 @@ class OC_Files {
OC_Util::obEnd(); OC_Util::obEnd();
$streamer->sendHeaders($name); $streamer->sendHeaders($name);
$executionTime = (int)OC::$server->getIniWrapper()->getNumeric('max_execution_time'); $executionTime = (int)OC::$server->get(IniGetWrapper::class)->getNumeric('max_execution_time');
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
@set_time_limit(0); @set_time_limit(0);
} }

View File

@ -44,6 +44,7 @@
* *
*/ */
use bantu\IniGetWrapper\IniGetWrapper;
use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\ExecutableFinder;
/** /**
@ -220,7 +221,7 @@ class OC_Helper {
// Default check will be done with $path directories : // Default check will be done with $path directories :
$dirs = explode(PATH_SEPARATOR, $path); $dirs = explode(PATH_SEPARATOR, $path);
// WARNING : We have to check if open_basedir is enabled : // WARNING : We have to check if open_basedir is enabled :
$obd = OC::$server->getIniWrapper()->getString('open_basedir'); $obd = OC::$server->get(IniGetWrapper::class)->getString('open_basedir');
if ($obd != "none") { if ($obd != "none") {
$obd_values = explode(PATH_SEPARATOR, $obd); $obd_values = explode(PATH_SEPARATOR, $obd);
if (count($obd_values) > 0 and $obd_values[0]) { if (count($obd_values) > 0 and $obd_values[0]) {
@ -414,7 +415,7 @@ class OC_Helper {
* @return int PHP upload file size limit * @return int PHP upload file size limit
*/ */
public static function uploadLimit() { public static function uploadLimit() {
$ini = \OC::$server->getIniWrapper(); $ini = \OC::$server->get(IniGetWrapper::class);
$upload_max_filesize = OCP\Util::computerFileSize($ini->get('upload_max_filesize')); $upload_max_filesize = OCP\Util::computerFileSize($ini->get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize($ini->get('post_max_size')); $post_max_size = OCP\Util::computerFileSize($ini->get('post_max_size'));
if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) { if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) {
@ -436,7 +437,7 @@ class OC_Helper {
if (!function_exists($function_name)) { if (!function_exists($function_name)) {
return false; return false;
} }
$ini = \OC::$server->getIniWrapper(); $ini = \OC::$server->get(IniGetWrapper::class);
$disabled = explode(',', $ini->get('disable_functions') ?: ''); $disabled = explode(',', $ini->get('disable_functions') ?: '');
$disabled = array_map('trim', $disabled); $disabled = array_map('trim', $disabled);
if (in_array($function_name, $disabled)) { if (in_array($function_name, $disabled)) {

View File

@ -62,6 +62,7 @@
* *
*/ */
use bantu\IniGetWrapper\IniGetWrapper;
use OC\AppFramework\Http\Request; use OC\AppFramework\Http\Request;
use OC\Files\Storage\LocalRootStorage; use OC\Files\Storage\LocalRootStorage;
use OCP\IConfig; use OCP\IConfig;
@ -738,7 +739,7 @@ class OC_Util {
$webServerRestart = false; $webServerRestart = false;
$setup = new \OC\Setup( $setup = new \OC\Setup(
$config, $config,
\OC::$server->getIniWrapper(), \OC::$server->get(IniGetWrapper::class),
\OC::$server->getL10N('lib'), \OC::$server->getL10N('lib'),
\OC::$server->query(\OCP\Defaults::class), \OC::$server->query(\OCP\Defaults::class),
\OC::$server->getLogger(), \OC::$server->getLogger(),
@ -863,7 +864,7 @@ class OC_Util {
$missingDependencies = []; $missingDependencies = [];
$invalidIniSettings = []; $invalidIniSettings = [];
$iniWrapper = \OC::$server->getIniWrapper(); $iniWrapper = \OC::$server->get(IniGetWrapper::class);
foreach ($dependencies['classes'] as $class => $module) { foreach ($dependencies['classes'] as $class => $module) {
if (!class_exists($class)) { if (!class_exists($class)) {
$missingDependencies[] = $module; $missingDependencies[] = $module;

View File

@ -8,6 +8,8 @@
namespace Test; namespace Test;
use bantu\IniGetWrapper\IniGetWrapper;
/** /**
* Tests whether LargeFileHelper is able to determine file size at all. * Tests whether LargeFileHelper is able to determine file size at all.
* Large files are not considered yet. * Large files are not considered yet.
@ -43,7 +45,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
'The PHP curl extension is required for this test.' 'The PHP curl extension is required for this test.'
); );
} }
if (\OC::$server->getIniWrapper()->getString('open_basedir') !== '') { if (\OC::$server->get(IniGetWrapper::class)->getString('open_basedir') !== '') {
$this->markTestSkipped( $this->markTestSkipped(
'The PHP curl extension does not work with the file:// protocol when open_basedir is enabled.' 'The PHP curl extension does not work with the file:// protocol when open_basedir is enabled.'
); );