nextcloud /
server
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @copyright Copyright (c) 2016 Arthur Schiwon <[email protected]> |
||
| 4 | * |
||
| 5 | * @author Arthur Schiwon <[email protected]> |
||
| 6 | * |
||
| 7 | * @license GNU AGPL version 3 or any later version |
||
| 8 | * |
||
| 9 | * This program is free software: you can redistribute it and/or modify |
||
| 10 | * it under the terms of the GNU Affero General Public License as |
||
| 11 | * published by the Free Software Foundation, either version 3 of the |
||
| 12 | * License, or (at your option) any later version. |
||
| 13 | * |
||
| 14 | * This program is distributed in the hope that it will be useful, |
||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 17 | * GNU Affero General Public License for more details. |
||
| 18 | * |
||
| 19 | * You should have received a copy of the GNU Affero General Public License |
||
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 21 | * |
||
| 22 | */ |
||
| 23 | |||
| 24 | namespace OC\Settings\Admin; |
||
| 25 | |||
| 26 | use Doctrine\DBAL\Connection; |
||
| 27 | use Doctrine\DBAL\DBALException; |
||
| 28 | use Doctrine\DBAL\Platforms\SqlitePlatform; |
||
| 29 | use OC\Lock\DBLockingProvider; |
||
| 30 | use OC\Lock\NoopLockingProvider; |
||
| 31 | use OCP\AppFramework\Http\TemplateResponse; |
||
| 32 | use OCP\IConfig; |
||
| 33 | use OCP\IDBConnection; |
||
| 34 | use OCP\IL10N; |
||
| 35 | use OCP\IRequest; |
||
| 36 | use OCP\Lock\ILockingProvider; |
||
| 37 | use OCP\Settings\ISettings; |
||
| 38 | |||
| 39 | class Server implements ISettings { |
||
| 40 | /** @var IDBConnection|Connection */ |
||
| 41 | private $db; |
||
| 42 | /** @var IRequest */ |
||
| 43 | private $request; |
||
| 44 | /** @var IConfig */ |
||
| 45 | private $config; |
||
| 46 | /** @var ILockingProvider */ |
||
| 47 | private $lockingProvider; |
||
| 48 | /** @var IL10N */ |
||
| 49 | private $l; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param IDBConnection $db |
||
| 53 | * @param IRequest $request |
||
| 54 | * @param IConfig $config |
||
| 55 | * @param ILockingProvider $lockingProvider |
||
| 56 | * @param IL10N $l |
||
| 57 | */ |
||
| 58 | public function __construct(IDBConnection $db, |
||
| 59 | IRequest $request, |
||
| 60 | IConfig $config, |
||
| 61 | ILockingProvider $lockingProvider, |
||
| 62 | IL10N $l) { |
||
| 63 | $this->db = $db; |
||
| 64 | $this->request = $request; |
||
| 65 | $this->config = $config; |
||
| 66 | $this->lockingProvider = $lockingProvider; |
||
| 67 | $this->l = $l; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @return TemplateResponse |
||
| 72 | */ |
||
| 73 | public function getForm() { |
||
| 74 | try { |
||
| 75 | if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { |
||
| 76 | $invalidTransactionIsolationLevel = false; |
||
| 77 | } else { |
||
| 78 | $invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED; |
||
| 79 | } |
||
| 80 | } catch (DBALException $e) { |
||
| 81 | // ignore |
||
| 82 | $invalidTransactionIsolationLevel = false; |
||
| 83 | } |
||
| 84 | |||
| 85 | $envPath = getenv('PATH'); |
||
| 86 | |||
| 87 | // warn if outdated version of a memcache module is used |
||
| 88 | $caches = [ |
||
| 89 | 'apcu' => ['name' => $this->l->t('APCu'), 'version' => '4.0.6'], |
||
| 90 | 'redis' => ['name' => $this->l->t('Redis'), 'version' => '2.2.5'], |
||
| 91 | ]; |
||
| 92 | $outdatedCaches = []; |
||
| 93 | foreach ($caches as $php_module => $data) { |
||
| 94 | $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); |
||
| 95 | if ($isOutdated) { |
||
| 96 | $outdatedCaches[$php_module] = $data; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | if ($this->lockingProvider instanceof NoopLockingProvider) { |
||
| 101 | $fileLockingType = 'none'; |
||
| 102 | } else if ($this->lockingProvider instanceof DBLockingProvider) { |
||
| 103 | $fileLockingType = 'db'; |
||
| 104 | } else { |
||
| 105 | $fileLockingType = 'cache'; |
||
| 106 | } |
||
| 107 | |||
| 108 | $suggestedOverwriteCliUrl = ''; |
||
| 109 | if ($this->config->getSystemValue('overwrite.cli.url', '') === '') { |
||
| 110 | $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; |
||
| 111 | if (!$this->config->getSystemValue('config_is_read_only', false)) { |
||
| 112 | // Set the overwrite URL when it was not set yet. |
||
| 113 | $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl); |
||
| 114 | $suggestedOverwriteCliUrl = ''; |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | $parameters = [ |
||
| 119 | // Diagnosis |
||
| 120 | 'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(), |
||
| 121 | 'isLocaleWorking' => \OC_Util::isSetLocaleWorking(), |
||
| 122 | 'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(), |
||
| 123 | 'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true), |
||
| 124 | 'has_fileinfo' => \OC_Util::fileInfoLoaded(), |
||
| 125 | 'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel, |
||
| 126 | 'getenvServerNotWorking' => empty($envPath), |
||
| 127 | 'OutdatedCacheWarning' => $outdatedCaches, |
||
| 128 | 'fileLockingType' => $fileLockingType, |
||
| 129 | 'suggestedOverwriteCliUrl' => $suggestedOverwriteCliUrl, |
||
| 130 | |||
| 131 | // Background jobs |
||
| 132 | 'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'), |
||
| 133 | 'lastcron' => $this->config->getAppValue('core', 'lastcron', false), |
||
|
0 ignored issues
–
show
|
|||
| 134 | 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), |
||
| 135 | 'cli_based_cron_possible' => function_exists('posix_getpwuid'), |
||
| 136 | 'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '', |
||
| 137 | ]; |
||
| 138 | |||
| 139 | return new TemplateResponse('settings', 'settings/admin/server', $parameters, ''); |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @return string the section ID, e.g. 'sharing' |
||
| 144 | */ |
||
| 145 | public function getSection() { |
||
| 146 | return 'server'; |
||
| 147 | } |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @return int whether the form should be rather on the top or bottom of |
||
| 151 | * the admin section. The forms are arranged in ascending order of the |
||
| 152 | * priority values. It is required to return a value between 0 and 100. |
||
| 153 | * |
||
| 154 | * E.g.: 70 |
||
| 155 | */ |
||
| 156 | public function getPriority() { |
||
| 157 | return 0; |
||
| 158 | } |
||
| 159 | } |
||
| 160 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: