|
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\Lock\ILockingProvider; |
|
36
|
|
|
use OCP\Settings\ISettings; |
|
37
|
|
|
|
|
38
|
|
|
class Server implements ISettings { |
|
39
|
|
|
/** @var IDBConnection|Connection */ |
|
40
|
|
|
private $db; |
|
41
|
|
|
/** @var IConfig */ |
|
42
|
|
|
private $config; |
|
43
|
|
|
/** @var ILockingProvider */ |
|
44
|
|
|
private $lockingProvider; |
|
45
|
|
|
/** @var IL10N */ |
|
46
|
|
|
private $l; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param IDBConnection $db |
|
50
|
|
|
* @param IConfig $config |
|
51
|
|
|
* @param ILockingProvider $lockingProvider |
|
52
|
|
|
* @param IL10N $l |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct(IDBConnection $db, |
|
55
|
|
|
IConfig $config, |
|
56
|
|
|
ILockingProvider $lockingProvider, |
|
57
|
|
|
IL10N $l) { |
|
58
|
|
|
$this->db = $db; |
|
59
|
|
|
$this->config = $config; |
|
60
|
|
|
$this->lockingProvider = $lockingProvider; |
|
61
|
|
|
$this->l = $l; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return TemplateResponse |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getForm() { |
|
68
|
|
|
try { |
|
69
|
|
|
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { |
|
|
|
|
|
|
70
|
|
|
$invalidTransactionIsolationLevel = false; |
|
71
|
|
|
} else { |
|
72
|
|
|
$invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED; |
|
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
} catch (DBALException $e) { |
|
|
|
|
|
|
75
|
|
|
// ignore |
|
76
|
|
|
$invalidTransactionIsolationLevel = false; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$envPath = getenv('PATH'); |
|
80
|
|
|
|
|
81
|
|
|
// warn if outdated version of a memcache module is used |
|
82
|
|
|
$caches = [ |
|
83
|
|
|
'apcu' => ['name' => $this->l->t('APCu'), 'version' => '4.0.6'], |
|
84
|
|
|
'redis' => ['name' => $this->l->t('Redis'), 'version' => '2.2.5'], |
|
85
|
|
|
]; |
|
86
|
|
|
$outdatedCaches = []; |
|
87
|
|
|
foreach ($caches as $php_module => $data) { |
|
88
|
|
|
$isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); |
|
89
|
|
|
if ($isOutdated) { |
|
90
|
|
|
$outdatedCaches[$php_module] = $data; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
if ($this->lockingProvider instanceof NoopLockingProvider) { |
|
95
|
|
|
$fileLockingType = 'none'; |
|
96
|
|
|
} else if ($this->lockingProvider instanceof DBLockingProvider) { |
|
97
|
|
|
$fileLockingType = 'db'; |
|
98
|
|
|
} else { |
|
99
|
|
|
$fileLockingType = 'cache'; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
// If the current web root is non-empty but the web root from the config is, |
|
103
|
|
|
// and system cron is used, the URL generator fails to build valid URLs. |
|
104
|
|
|
$shouldSuggestOverwriteCliUrl = $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' |
|
105
|
|
|
&& \OC::$WEBROOT && \OC::$WEBROOT !== '/' |
|
106
|
|
|
&& !$this->config->getSystemValue('overwrite.cli.url', ''); |
|
107
|
|
|
$suggestedOverwriteCliUrl = ($shouldSuggestOverwriteCliUrl) ? \OC::$WEBROOT : ''; |
|
108
|
|
|
|
|
109
|
|
|
$parameters = [ |
|
110
|
|
|
// Diagnosis |
|
111
|
|
|
'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(), |
|
112
|
|
|
'isLocaleWorking' => \OC_Util::isSetLocaleWorking(), |
|
113
|
|
|
'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(), |
|
114
|
|
|
'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true), |
|
115
|
|
|
'has_fileinfo' => \OC_Util::fileInfoLoaded(), |
|
116
|
|
|
'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel, |
|
117
|
|
|
'getenvServerNotWorking' => empty($envPath), |
|
118
|
|
|
'OutdatedCacheWarning' => $outdatedCaches, |
|
119
|
|
|
'fileLockingType' => $fileLockingType, |
|
120
|
|
|
'suggestedOverwriteCliUrl' => $suggestedOverwriteCliUrl, |
|
121
|
|
|
|
|
122
|
|
|
// Background jobs |
|
123
|
|
|
'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'), |
|
124
|
|
|
'cron_log' => $this->config->getSystemValue('cron_log', true), |
|
125
|
|
|
'lastcron' => $this->config->getAppValue('core', 'lastcron', false), |
|
|
|
|
|
|
126
|
|
|
'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), |
|
127
|
|
|
]; |
|
128
|
|
|
|
|
129
|
|
|
return new TemplateResponse('settings', 'admin/server', $parameters, ''); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @return string the section ID, e.g. 'sharing' |
|
134
|
|
|
*/ |
|
135
|
|
|
public function getSection() { |
|
136
|
|
|
return 'server'; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return int whether the form should be rather on the top or bottom of |
|
141
|
|
|
* the admin section. The forms are arranged in ascending order of the |
|
142
|
|
|
* priority values. It is required to return a value between 0 and 100. |
|
143
|
|
|
* |
|
144
|
|
|
* E.g.: 70 |
|
145
|
|
|
*/ |
|
146
|
|
|
public function getPriority() { |
|
147
|
|
|
return 0; |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.