Commit 136d14ec authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1093 Added ServiceUnavailableException to class loader, updated

config description, don't show legal information if service is
unavailable, check if config value is greater than zero, throw
ServiceUnavailableException if states need to be upgraded.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 83045c56
......@@ -272,11 +272,12 @@
define('SYNC_TIMEOUT_MEDIUM_DEVICETYPES', "SAMSUNGGTI");
define('SYNC_TIMEOUT_LONG_DEVICETYPES', "iPod, iPad, iPhone, WP, WindowsOutlook");
// The delay in second the device should wait whenever the service is unavailable
// A service is unavailable whenever z-push sends a 503 http code. This can be accomplished
// by throwing the ServiceUnavailableException.
// Time in seconds the device should wait whenever the service is unavailable,
// e.g. when a backend service is unavailable.
// Z-Push sends a "Retry-After" header in the response with the here defined value.
// It is up to the device to respect or not this directive so even if this option is set,
// the device might not wait the time.
// the device might not wait requested time frame.
// Number of seconds before retry, to disable set to: false
define('RETRY_AFTER_DELAY', 300);
/**********************************************************************************
......
......@@ -347,7 +347,7 @@ class ZPush {
if (!defined('RETRY_AFTER_DELAY')) {
define('RETRY_AFTER_DELAY', 300);
}
elseif (RETRY_AFTER_DELAY !== false && !is_int(RETRY_AFTER_DELAY) || RETRY_AFTER_DELAY < 0) {
elseif (RETRY_AFTER_DELAY !== false && (!is_int(RETRY_AFTER_DELAY) || RETRY_AFTER_DELAY < 1)) {
throw new FatalMisconfigurationException("The RETRY_AFTER_DELAY value must be 'false' or a number greater than 0.");
}
......@@ -463,7 +463,7 @@ class ZPush {
if (ZPush::$stateMachine->GetStateVersion() !== ZPush::GetLatestStateVersion()) {
if (class_exists("TopCollector")) self::GetTopCollector()->AnnounceInformation("Run migration script!", true);
throw new HTTPReturnCodeException(sprintf("The state version available to the %s is not the latest version - please run the state upgrade script. See release notes for more information.", get_class(ZPush::$stateMachine), 503));
throw new ServiceUnavailableException(sprintf("The state version available to the %s is not the latest version - please run the state upgrade script. See release notes for more information.", get_class(ZPush::$stateMachine)));
}
}
return ZPush::$stateMachine;
......
......@@ -2,7 +2,7 @@
/***********************************************
* File : serviceunavailableexception.php
* Project : Z-Push
* Descr : Exception sending a '503 Service Unavailable' to the mobile
* Descr : Exception sending a '503 Service Unavailable' to the mobile.
*
* Created : 09.08.2016
*
......@@ -46,7 +46,7 @@ class ServiceUnavailableException extends HTTPReturnCodeException {
protected $httpReturnCode = HTTP_CODE_503;
protected $httpReturnMessage = "Service Unavailable";
protected $httpHeaders = array();
protected $showLegal = true;
protected $showLegal = false;
public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) {
parent::__construct($message, $code, $previous, $logLevel);
......
......@@ -112,6 +112,7 @@ return array(
'Search' => $baseDir . '/lib/request/search.php',
'SearchProvider' => $baseDir . '/lib/default/searchprovider.php',
'SendMail' => $baseDir . '/lib/request/sendmail.php',
'ServiceUnavailableException' => $baseDir . '/lib/exceptions/serviceunavailableexception.php',
'Settings' => $baseDir . '/lib/request/settings.php',
'SimpleMutex' => $baseDir . '/lib/default/simplemutex.php',
'SqlStateMachine' => $baseDir . '/backend/sqlstatemachine/sqlstatemachine.php',
......
......@@ -119,6 +119,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f
'Search' => __DIR__ . '/../..' . '/lib/request/search.php',
'SearchProvider' => __DIR__ . '/../..' . '/lib/default/searchprovider.php',
'SendMail' => __DIR__ . '/../..' . '/lib/request/sendmail.php',
'ServiceUnavailableException' => __DIR__ . '/../..' . '/lib/exceptions/serviceunavailableexception.php',
'Settings' => __DIR__ . '/../..' . '/lib/request/settings.php',
'SimpleMutex' => __DIR__ . '/../..' . '/lib/default/simplemutex.php',
'SqlStateMachine' => __DIR__ . '/../..' . '/backend/sqlstatemachine/sqlstatemachine.php',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment