Repository navigation
Expand file tree
/
Copy pathstatus.php
More file actions
101 lines (97 loc) · 3.86 KB
/
Copy pathstatus.php
File metadata and controls
101 lines (97 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* @author Andreas Fischer <bantu@owncloud.com>
* @author Christopher Schäpers <kondou@ts.unde.re>
* @author Frank Karlitschek <frank@karlitschek.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Kristof Provost <github@sigsegv.be>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author martin.mattel@diemattels.at <martin.mattel@diemattels.at>
* @author Masaki Kawabata Neto <masaki.kawabata@gmail.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Philipp Schaffrath <github@philippschaffrath.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2020, ownCloud GmbH
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2026, BW-Tech GmbH
*
* Modified by BW-Tech GmbH on 2026-07-02.
* Changes:
* - cut per-request hot-path costs across session, cache, storage and status
*/
try {
/**
* Fast path: status.php is polled by every desktop/mobile client on connection
* validation, yet the answer only changes on upgrades or maintenance toggles.
* Serve the last known-good answer from APCu — keyed on config.php/version.php
* mtimes, so occ upgrade (toggles maintenance in config.php) and code deploys
* invalidate immediately — and skip the full bootstrap. Only a "green" state
* (installed, no maintenance, no pending upgrade) is ever cached; anything else
* always takes the full path below so upgrade/maintenance semantics stay exact.
*/
if (PHP_SAPI !== 'cli' && \function_exists('apcu_fetch')) {
$statusConfigFile = __DIR__ . '/config/config.php';
$statusVersionFile = __DIR__ . '/version.php';
if (@\is_file($statusConfigFile)) {
$statusCacheKey = 'oco_status_' . \md5(
__DIR__ . '|' . @\filemtime($statusConfigFile) . '|' . @\filesize($statusConfigFile) . '|' . @\filemtime($statusVersionFile)
);
$statusCached = \apcu_fetch($statusCacheKey, $statusCacheHit);
if ($statusCacheHit && \is_string($statusCached)) {
\header('Access-Control-Allow-Origin: *');
\header('Content-Type: application/json');
echo $statusCached;
return;
}
}
}
require_once __DIR__ . '/lib/base.php';
# show the version details based on config.php parameter,
# but do not expose the servername in the public via url
$values = \OCP\Util::getStatusInfo(
null,
\OC::$server->getConfig()->getSystemValue('show_server_hostname', false) !== true,
\OC::$server->getConfig()->getSystemValue('use_relative_domain_name', false) === true
);
if (OC::$CLI) {
\print_r($values);
} else {
\header('Access-Control-Allow-Origin: *');
\header('Content-Type: application/json');
$statusBody = \json_encode($values);
if (isset($statusCacheKey)
&& $values['installed'] === true
&& $values['maintenance'] === false
&& $values['needsDbUpgrade'] === false
) {
// short TTL as safety net for app-only upgrades that do not touch config.php
\apcu_store($statusCacheKey, $statusBody, 90);
}
echo $statusBody;
}
} catch (\Throwable $ex) {
try {
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
} catch (\Throwable $ex2) {
// log through the crashLog
\header("{$_SERVER['SERVER_PROTOCOL']} 599 Broken");
\OC::crashLog($ex);
\OC::crashLog($ex2);
}
}