Merge pull request #9306 from owncloud/publicneedsupgrade

Return 503 in  public.php and OCS API when upgrade is due
This commit is contained in:
Jan-Christoph Borchardt 2014-07-01 11:52:39 +02:00
commit 75a5746b70
3 changed files with 18 additions and 1 deletions

View File

@ -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"');

View File

@ -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;

View File

@ -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();