summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Christoph Borchardt <hey@jancborchardt.net>2014-07-01 11:52:39 +0200
committerJan-Christoph Borchardt <hey@jancborchardt.net>2014-07-01 11:52:39 +0200
commit75a5746b7042875606bffd27e0c8ac4c65bc4437 (patch)
treef5fd2b401194b0b333ef69c3fa6edf0907164069
parent08e49e9b074e0aa35f22a2f5bd94aeed83e77995 (diff)
parent972fffbe02d1e0493d498859b76de698ecf5d067 (diff)
downloadnextcloud-server-75a5746b7042875606bffd27e0c8ac4c65bc4437.tar.gz
nextcloud-server-75a5746b7042875606bffd27e0c8ac4c65bc4437.zip
Merge pull request #9306 from owncloud/publicneedsupgrade
Return 503 in public.php and OCS API when upgrade is due
-rw-r--r--lib/private/api.php2
-rw-r--r--ocs/v1.php9
-rw-r--r--public.php8
3 files changed, 18 insertions, 1 deletions
diff --git a/lib/private/api.php b/lib/private/api.php
index 74887690952..e9c144564f0 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -301,7 +301,7 @@ class OC_API {
* @param OC_OCS_Result $result
* @param string $format the format xml|json
*/
- private static function respond($result, $format='xml') {
+ public static function respond($result, $format='xml') {
// Send 401 headers if unauthorised
if($result->getStatusCode() === self::RESPOND_UNAUTHORISED) {
header('WWW-Authenticate: Basic realm="Authorisation Required"');
diff --git a/ocs/v1.php b/ocs/v1.php
index d69904fc495..0a86fb06411 100644
--- a/ocs/v1.php
+++ b/ocs/v1.php
@@ -23,6 +23,15 @@
require_once '../lib/base.php';
+if (\OCP\Util::needUpgrade()) {
+ // since the behavior of apps or remotes are unpredictable during
+ // an upgrade, return a 503 directly
+ OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
+ $response = new OC_OCS_Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
+ OC_API::respond($response, OC_API::requestedFormat());
+ exit;
+}
+
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
diff --git a/public.php b/public.php
index eed63948112..1f858fd073d 100644
--- a/public.php
+++ b/public.php
@@ -3,6 +3,14 @@
try {
require_once 'lib/base.php';
+ if (\OCP\Util::needUpgrade()) {
+ // since the behavior of apps or remotes are unpredictable during
+ // an upgrade, return a 503 directly
+ OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
+ OC_Template::printErrorPage('Service unavailable');
+ exit;
+ }
+
OC::checkMaintenanceMode();
OC::checkSingleUserMode();
$pathInfo = OC_Request::getPathInfo();