]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't use deprecated getIniWrapper() anymore
authorJoas Schilling <coding@schilljs.com>
Thu, 20 Aug 2020 12:08:18 +0000 (14:08 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 20 Aug 2020 14:35:38 +0000 (16:35 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
14 files changed:
apps/files_sharing/templates/public.php
apps/settings/lib/Controller/CheckSetupController.php
core/Command/Maintenance/Install.php
lib/base.php
lib/private/LargeFileHelper.php
lib/private/Memcache/APCu.php
lib/private/Server.php
lib/private/Setup.php
lib/private/TempManager.php
lib/private/TemplateLayout.php
lib/private/legacy/OC_Files.php
lib/private/legacy/OC_Helper.php
lib/private/legacy/OC_Util.php
tests/lib/LargeFileHelperGetFileSizeTest.php

index 82544385dec94d75454c73e64edbf3fb306ab215..ffc449f9e6381ca2bf2e5f40bcba09fbc5ba89c6 100644 (file)
@@ -23,8 +23,8 @@
 <input type="hidden" name="hideDownload" value="<?php p($_['hideDownload'] ? 'true' : 'false'); ?>" id="hideDownload">
 <input type="hidden" id="disclaimerText" value="<?php p($_['disclaimer']) ?>">
 <?php
-$upload_max_filesize = OC::$server->getIniWrapper()->getBytes('upload_max_filesize');
-$post_max_size = OC::$server->getIniWrapper()->getBytes('post_max_size');
+$upload_max_filesize = OC::$server->get(\bantu\IniGetWrapper\IniGetWrapper::class)->getBytes('upload_max_filesize');
+$post_max_size = OC::$server->get(\bantu\IniGetWrapper\IniGetWrapper::class)->getBytes('post_max_size');
 $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
 ?>
 <input type="hidden" name="maxFilesizeUpload" value="<?php p($maxUploadFilesize); ?>" id="maxFilesizeUpload">
index 476b58e564a88e17016d9818f5576dfd10df3d27..6d237e04c1c781cb6624f5ab89407b656fccc776 100644 (file)
@@ -98,6 +98,8 @@ class CheckSetupController extends Controller {
        private $memoryInfo;
        /** @var ISecureRandom */
        private $secureRandom;
+       /** @var IniGetWrapper */
+       private $iniGetWrapper;
 
        public function __construct($AppName,
                                                                IRequest $request,
@@ -112,7 +114,8 @@ class CheckSetupController extends Controller {
                                                                ILockingProvider $lockingProvider,
                                                                IDateTimeFormatter $dateTimeFormatter,
                                                                MemoryInfo $memoryInfo,
-                                                               ISecureRandom $secureRandom) {
+                                                               ISecureRandom $secureRandom,
+                                                               IniGetWrapper $iniGetWrapper) {
                parent::__construct($AppName, $request);
                $this->config = $config;
                $this->clientService = $clientService;
@@ -126,6 +129,7 @@ class CheckSetupController extends Controller {
                $this->dateTimeFormatter = $dateTimeFormatter;
                $this->memoryInfo = $memoryInfo;
                $this->secureRandom = $secureRandom;
+               $this->iniGetWrapper = $iniGetWrapper;
        }
 
        /**
@@ -407,25 +411,23 @@ Raw output
         * @return bool
         */
        protected function isOpcacheProperlySetup() {
-               $iniWrapper = new IniGetWrapper();
-
-               if (!$iniWrapper->getBool('opcache.enable')) {
+               if (!$this->iniGetWrapper->getBool('opcache.enable')) {
                        return false;
                }
 
-               if (!$iniWrapper->getBool('opcache.save_comments')) {
+               if (!$this->iniGetWrapper->getBool('opcache.save_comments')) {
                        return false;
                }
 
-               if ($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
+               if ($this->iniGetWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
                        return false;
                }
 
-               if ($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
+               if ($this->iniGetWrapper->getNumeric('opcache.memory_consumption') < 128) {
                        return false;
                }
 
-               if ($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
+               if ($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
                        return false;
                }
 
index 9cca77bb9c0882d30205de43297c967a118d5a39..a8032e24af51ed7fdea1580b5460577d28dbb148 100644 (file)
@@ -32,6 +32,7 @@
 
 namespace OC\Core\Command\Maintenance;
 
+use bantu\IniGetWrapper\IniGetWrapper;
 use InvalidArgumentException;
 use OC\Installer;
 use OC\Setup;
@@ -46,14 +47,15 @@ use Symfony\Component\Console\Question\Question;
 
 class Install extends Command {
 
-       /**
-        * @var SystemConfig
-        */
+       /** @var SystemConfig */
        private $config;
+       /** @var IniGetWrapper  */
+       private $iniGetWrapper;
 
-       public function __construct(SystemConfig $config) {
+       public function __construct(SystemConfig $config, IniGetWrapper $iniGetWrapper) {
                parent::__construct();
                $this->config = $config;
+               $this->iniGetWrapper = $iniGetWrapper;
        }
 
        protected function configure() {
@@ -79,7 +81,7 @@ class Install extends Command {
                $server = \OC::$server;
                $setupHelper = new Setup(
                        $this->config,
-                       $server->getIniWrapper(),
+                       $this->iniGetWrapper,
                        $server->getL10N('lib'),
                        $server->query(Defaults::class),
                        $server->getLogger(),
index 8b8e8e5fe32c2bc82e9452ac6a64867f6ccc17e5..6b715f9c2489123f4968e8f69e71eec07d36c93d 100644 (file)
@@ -936,7 +936,7 @@ class OC {
                        \OC::$server->getSession()->clear();
                        $setupHelper = new OC\Setup(
                                $systemConfig,
-                               \OC::$server->getIniWrapper(),
+                               \OC::$server->get(\bantu\IniGetWrapper\IniGetWrapper::class),
                                \OC::$server->getL10N('lib'),
                                \OC::$server->query(\OCP\Defaults::class),
                                \OC::$server->getLogger(),
index 2a6a6714eb35631cd8f068e9270de98cfa46657e..c4e76d22c5a3c2cd6d1a180fb6dc91950fd0b622 100755 (executable)
@@ -29,6 +29,8 @@
 
 namespace OC;
 
+use bantu\IniGetWrapper\IniGetWrapper;
+
 /**
  * Helper class for large files on 32-bit platforms.
  */
@@ -117,7 +119,7 @@ class LargeFileHelper {
         *                        null on failure.
         */
        public function getFileSizeViaCurl($fileName) {
-               if (\OC::$server->getIniWrapper()->getString('open_basedir') === '') {
+               if (\OC::$server->get(IniGetWrapper::class)->getString('open_basedir') === '') {
                        $encodedFileName = rawurlencode($fileName);
                        $ch = curl_init("file:///$encodedFileName");
                        curl_setopt($ch, CURLOPT_NOBODY, true);
index 87d72ec1968b6663b41155cd151945eb7a8f9f6e..f7ef6eb2d3e0b8e059bf5ae9565889b3265cac2b 100644 (file)
@@ -28,6 +28,7 @@
 
 namespace OC\Memcache;
 
+use bantu\IniGetWrapper\IniGetWrapper;
 use OCP\IMemcache;
 
 class APCu extends Cache implements IMemcache {
@@ -154,9 +155,9 @@ class APCu extends Cache implements IMemcache {
        public static function isAvailable() {
                if (!extension_loaded('apcu')) {
                        return false;
-               } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) {
+               } elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enabled')) {
                        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;
                } elseif (
                                version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 &&
index 9b452f21ce17832fe7d589c56d3786fd08231672..e1dce286a2a8c23d7de112a20392bd2c459c48d8 100644 (file)
@@ -1012,7 +1012,7 @@ class Server extends ServerContainer implements IServerContainer {
                        return $factory->getLDAPProvider();
                });
                $this->registerService(ILockingProvider::class, function (Server $c) {
-                       $ini = $c->getIniWrapper();
+                       $ini = $c->get(IniGetWrapper::class);
                        $config = $c->getConfig();
                        $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
                        if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
@@ -1953,7 +1953,7 @@ class Server extends ServerContainer implements IServerContainer {
         * @deprecated
         */
        public function getIniWrapper() {
-               return $this->query('IniWrapper');
+               return $this->query(IniGetWrapper::class);
        }
 
        /**
index 775c2d0a952e81131553732f3a296aadb08d4086..839ef9f7bead1ef9d885fa994d254ff9aac8ea45 100644 (file)
@@ -503,7 +503,7 @@ class Setup {
 
                $setupHelper = new \OC\Setup(
                        $config,
-                       \OC::$server->getIniWrapper(),
+                       \OC::$server->get(IniGetWrapper::class),
                        \OC::$server->getL10N('lib'),
                        \OC::$server->query(Defaults::class),
                        \OC::$server->getLogger(),
index 49d4ee94cf61471ce25df9aa76be73f7584907b8..b4db44f6b1ca45182838670bb60f13f791957c58 100644 (file)
 
 namespace OC;
 
+use bantu\IniGetWrapper\IniGetWrapper;
 use OCP\IConfig;
-use OCP\ILogger;
 use OCP\ITempManager;
+use Psr\Log\LoggerInterface;
 
 class TempManager implements ITempManager {
        /** @var string[] Current temporary files and folders, used for cleanup */
        protected $current = [];
        /** @var string i.e. /tmp on linux systems */
        protected $tmpBaseDir;
-       /** @var ILogger */
+       /** @var LoggerInterface */
        protected $log;
        /** @var IConfig */
        protected $config;
+       /** @var IniGetWrapper */
+       protected $iniGetWrapper;
 
        /** Prefix */
        public const TMP_PREFIX = 'oc_tmp_';
 
-       /**
-        * @param \OCP\ILogger $logger
-        * @param \OCP\IConfig $config
-        */
-       public function __construct(ILogger $logger, IConfig $config) {
+       public function __construct(LoggerInterface $logger, IConfig $config, IniGetWrapper $iniGetWrapper) {
                $this->log = $logger;
                $this->config = $config;
+               $this->iniGetWrapper = $iniGetWrapper;
                $this->tmpBaseDir = $this->getTempBaseDir();
        }
 
@@ -218,7 +218,7 @@ class TempManager implements ITempManager {
                if ($temp = $this->config->getSystemValue('tempdirectory', null)) {
                        $directories[] = $temp;
                }
-               if ($temp = \OC::$server->getIniWrapper()->get('upload_tmp_dir')) {
+               if ($temp = $this->iniGetWrapper->get('upload_tmp_dir')) {
                        $directories[] = $temp;
                }
                if ($temp = getenv('TMP')) {
index af3aeb440d2b009409f30c9259519d478475b71b..4a0ec75b5178990bf49085ec5ba447a41f09c090 100644 (file)
@@ -44,6 +44,7 @@
 
 namespace OC;
 
+use bantu\IniGetWrapper\IniGetWrapper;
 use OC\Search\SearchQuery;
 use OC\Template\JSCombiner;
 use OC\Template\JSConfigHelper;
@@ -202,7 +203,7 @@ class TemplateLayout extends \OC_Template {
                                        \OC::$server->getUserSession()->getUser(),
                                        $this->config,
                                        \OC::$server->getGroupManager(),
-                                       \OC::$server->getIniWrapper(),
+                                       \OC::$server->get(IniGetWrapper::class),
                                        \OC::$server->getURLGenerator(),
                                        \OC::$server->getCapabilitiesManager(),
                                        \OC::$server->query(IInitialStateService::class)
@@ -259,7 +260,7 @@ class TemplateLayout extends \OC_Template {
                                }
                        }
                }
-               
+
                $this->assign('initialStates', $this->initialState->getInitialStates());
        }
 
index ddb824cd6cd6e5057135ca698a25ceb3742fdc1b..f5f91fc99583b8a69b52e13a9003309e025b5a0d 100644 (file)
@@ -41,6 +41,7 @@
  *
  */
 
+use bantu\IniGetWrapper\IniGetWrapper;
 use OC\Files\View;
 use OC\Streamer;
 use OCP\Lock\ILockingProvider;
@@ -164,7 +165,7 @@ class OC_Files {
                        OC_Util::obEnd();
 
                        $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) {
                                @set_time_limit(0);
                        }
index 8cd492de1176eda718c99d93606d7c22b03a5c32..4e9c5cffe98a95506bc12d327424a08c251e3fb7 100644 (file)
@@ -44,6 +44,7 @@
  *
  */
 
+use bantu\IniGetWrapper\IniGetWrapper;
 use Symfony\Component\Process\ExecutableFinder;
 
 /**
@@ -220,7 +221,7 @@ class OC_Helper {
                // Default check will be done with $path directories :
                $dirs = explode(PATH_SEPARATOR, $path);
                // 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") {
                        $obd_values = explode(PATH_SEPARATOR, $obd);
                        if (count($obd_values) > 0 and $obd_values[0]) {
@@ -414,7 +415,7 @@ class OC_Helper {
         * @return int PHP upload file size limit
         */
        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'));
                $post_max_size = OCP\Util::computerFileSize($ini->get('post_max_size'));
                if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) {
@@ -436,7 +437,7 @@ class OC_Helper {
                if (!function_exists($function_name)) {
                        return false;
                }
-               $ini = \OC::$server->getIniWrapper();
+               $ini = \OC::$server->get(IniGetWrapper::class);
                $disabled = explode(',', $ini->get('disable_functions') ?: '');
                $disabled = array_map('trim', $disabled);
                if (in_array($function_name, $disabled)) {
index f2aa0545afda749a569ce863981ef23d594c8727..caae862ad41a599f52e30168dc048b3354a8135a 100644 (file)
@@ -62,6 +62,7 @@
  *
  */
 
+use bantu\IniGetWrapper\IniGetWrapper;
 use OC\AppFramework\Http\Request;
 use OC\Files\Storage\LocalRootStorage;
 use OCP\IConfig;
@@ -738,7 +739,7 @@ class OC_Util {
                $webServerRestart = false;
                $setup = new \OC\Setup(
                        $config,
-                       \OC::$server->getIniWrapper(),
+                       \OC::$server->get(IniGetWrapper::class),
                        \OC::$server->getL10N('lib'),
                        \OC::$server->query(\OCP\Defaults::class),
                        \OC::$server->getLogger(),
@@ -863,7 +864,7 @@ class OC_Util {
                $missingDependencies = [];
                $invalidIniSettings = [];
 
-               $iniWrapper = \OC::$server->getIniWrapper();
+               $iniWrapper = \OC::$server->get(IniGetWrapper::class);
                foreach ($dependencies['classes'] as $class => $module) {
                        if (!class_exists($class)) {
                                $missingDependencies[] = $module;
index 3ad8f5b88069128e78b7337636809935c7774151..e21ac4ee64be750184ff0ae61e63ef2314b5282e 100644 (file)
@@ -8,6 +8,8 @@
 
 namespace Test;
 
+use bantu\IniGetWrapper\IniGetWrapper;
+
 /**
  * Tests whether LargeFileHelper is able to determine file size at all.
  * Large files are not considered yet.
@@ -43,7 +45,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
                                '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(
                                'The PHP curl extension does not work with the file:// protocol when open_basedir is enabled.'
                        );