From 9257e533c2ccc333ebd602cdb69d92cb180463eb Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Thu, 27 Apr 2017 12:18:35 -0400 Subject: [PATCH 1/6] HOR-1750 --- framework/src/Maveriks/WebApplication.php | 4 ++ .../Policies/ControlUnderUpdating.php | 56 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php diff --git a/framework/src/Maveriks/WebApplication.php b/framework/src/Maveriks/WebApplication.php index 21c9473e1..4296a8fac 100644 --- a/framework/src/Maveriks/WebApplication.php +++ b/framework/src/Maveriks/WebApplication.php @@ -254,6 +254,8 @@ class WebApplication $authenticationClass = 'ProcessMaker\\Services\\OAuth2\\Server'; // $accessControlClass - contains the class name that validate the Access Control for Restler $accessControlClass = 'ProcessMaker\\Policies\\AccessControl'; + // $controlUnderUpdating - ControlUnderUpdating sends an error signal 503 to report that the application is in update + $controlUnderUpdating = 'ProcessMaker\\Policies\\ControlUnderUpdating'; // $pmOauthClientId - contains PM Local OAuth Id (Web Designer) $pmOauthClientId = 'x-pm-local-client'; @@ -301,6 +303,8 @@ class WebApplication $this->rest->addAuthenticationClass($authenticationClass, ''); // adding $accessControlClass to Restler $this->rest->addAuthenticationClass($accessControlClass); + // adding $controlUnderUpdating to Restler + $this->rest->addAuthenticationClass($controlUnderUpdating); // Setting database connection source list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, ''); diff --git a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php new file mode 100644 index 000000000..c5c37e595 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php @@ -0,0 +1,56 @@ + Date: Fri, 28 Apr 2017 08:11:19 -0400 Subject: [PATCH 2/6] HOR-1750 --- .../engine/src/ProcessMaker/Policies/ControlUnderUpdating.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php index c5c37e595..78e5dacc1 100644 --- a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php +++ b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php @@ -30,11 +30,11 @@ class ControlUnderUpdating implements iAuthenticate $sysTemp = $underUpdating['workspace'] == SYS_TEMP; } if ($underUpdating['workspace'] == "true" || $sysTemp) { - $mesage = 'The server is currently unable to handle the request ' + $message = 'The server is currently unable to handle the request ' . 'due to a temporary overloading or maintenance of the ' . 'server (An application update has probably been ' . 'performed on the server).'; - throw new RestException(503, $mesage); + throw new RestException(503, $message); } } return $response; From feed5454f194ae2615d319ae1afc5284716e1c1b Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Fri, 28 Apr 2017 09:28:38 -0400 Subject: [PATCH 3/6] HOR-1750 --- .../src/ProcessMaker/Policies/ControlUnderUpdating.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php index 78e5dacc1..5247f160f 100644 --- a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php +++ b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php @@ -26,14 +26,14 @@ class ControlUnderUpdating implements iAuthenticate $underUpdating = \Bootstrap::isPMUnderUpdating(); if ($underUpdating['action']) { $sysTemp = true; - if (defined("SYS_TEMP")) { + if (defined('SYS_TEMP')) { $sysTemp = $underUpdating['workspace'] == SYS_TEMP; } - if ($underUpdating['workspace'] == "true" || $sysTemp) { + if ($underUpdating['workspace'] == 'true' || $sysTemp) { $message = 'The server is currently unable to handle the request ' - . 'due to a temporary overloading or maintenance of the ' - . 'server (An application update has probably been ' - . 'performed on the server).'; + . 'due to temporary overloading or server maintenance (' + . 'an application update has probably been performed on ' + . 'the server)'; throw new RestException(503, $message); } } From 154f5dc4cc60d6a91f0f99c8d4827ab8d29481bd Mon Sep 17 00:00:00 2001 From: dheeyi william Date: Thu, 4 May 2017 14:36:19 -0400 Subject: [PATCH 4/6] HOR-3177 MySQL Exception in APP when the Mobile Notifications are enabled in env.ini --- .../model/map/NotificationDeviceMapBuilder.php | 2 +- .../classes/model/om/BaseNotificationDevice.php | 4 ++-- workflow/engine/config/schema.xml | 11 ++++++++++- workflow/engine/data/mysql/schema.sql | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php b/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php index 97a2a9823..ce26120b7 100644 --- a/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php +++ b/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php @@ -71,7 +71,7 @@ class NotificationDeviceMapBuilder $tMap->addColumn('SYS_LANG', 'SysLang', 'string', CreoleTypes::VARCHAR, false, 10); - $tMap->addColumn('DEV_REG_ID', 'DevRegId', 'string', CreoleTypes::VARCHAR, true, 150); + $tMap->addColumn('DEV_REG_ID', 'DevRegId', 'string', CreoleTypes::LONGVARCHAR, true, null); $tMap->addColumn('DEV_TYPE', 'DevType', 'string', CreoleTypes::VARCHAR, true, 50); diff --git a/workflow/engine/classes/model/om/BaseNotificationDevice.php b/workflow/engine/classes/model/om/BaseNotificationDevice.php index 56a8f3bb4..2f33fbf7b 100644 --- a/workflow/engine/classes/model/om/BaseNotificationDevice.php +++ b/workflow/engine/classes/model/om/BaseNotificationDevice.php @@ -49,7 +49,7 @@ abstract class BaseNotificationDevice extends BaseObject implements Persistent * The value for the dev_reg_id field. * @var string */ - protected $dev_reg_id = ''; + protected $dev_reg_id; /** * The value for the dev_type field. @@ -283,7 +283,7 @@ abstract class BaseNotificationDevice extends BaseObject implements Persistent $v = (string) $v; } - if ($this->dev_reg_id !== $v || $v === '') { + if ($this->dev_reg_id !== $v) { $this->dev_reg_id = $v; $this->modifiedColumns[] = NotificationDevicePeer::DEV_REG_ID; } diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 3e16c46f2..64ce0a367 100644 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -5543,7 +5543,16 @@ - + + + + + + + + + + diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 7a4bfe380..6a6b4a9e5 100644 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -3077,7 +3077,7 @@ CREATE TABLE `NOTIFICATION_DEVICE` `DEV_UID` VARCHAR(32) default '' NOT NULL, `USR_UID` VARCHAR(32) default '' NOT NULL, `SYS_LANG` VARCHAR(10) default '', - `DEV_REG_ID` VARCHAR(150) default '' NOT NULL, + `DEV_REG_ID` MEDIUMTEXT default '' NOT NULL, `DEV_TYPE` VARCHAR(50) default '' NOT NULL, `DEV_CREATE` DATETIME NOT NULL, `DEV_UPDATE` DATETIME NOT NULL, From 7a60e17367888664a98ef8896f23e270f0e9a59b Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Mon, 8 May 2017 15:22:46 -0400 Subject: [PATCH 5/6] HOR-1750 --- .../Policies/ControlUnderUpdating.php | 38 ++++++++++++------- .../ProcessMaker/Services/OAuth2/Server.php | 2 + 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php index 5247f160f..c40363912 100644 --- a/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php +++ b/workflow/engine/src/ProcessMaker/Policies/ControlUnderUpdating.php @@ -23,20 +23,7 @@ class ControlUnderUpdating implements iAuthenticate public function __isAllowed() { $response = true; - $underUpdating = \Bootstrap::isPMUnderUpdating(); - if ($underUpdating['action']) { - $sysTemp = true; - if (defined('SYS_TEMP')) { - $sysTemp = $underUpdating['workspace'] == SYS_TEMP; - } - if ($underUpdating['workspace'] == 'true' || $sysTemp) { - $message = 'The server is currently unable to handle the request ' - . 'due to temporary overloading or server maintenance (' - . 'an application update has probably been performed on ' - . 'the server)'; - throw new RestException(503, $message); - } - } + self::verifyUnderUpgrading(); return $response; } @@ -53,4 +40,27 @@ class ControlUnderUpdating implements iAuthenticate return ''; } + /** + * Verify under upgrading, if the state is under update an exception is + * thrown of type RestException. + * @throws RestException + */ + public static function verifyUnderUpgrading() + { + $underUpdating = \Bootstrap::isPMUnderUpdating(); + if ($underUpdating['action']) { + $sysTemp = true; + if (defined('SYS_TEMP')) { + $sysTemp = $underUpdating['workspace'] == SYS_TEMP; + } + if ($underUpdating['workspace'] == 'true' || $sysTemp) { + $message = 'The server is currently unable to handle the request ' + . 'due to temporary overloading or server maintenance (' + . 'an application update has probably been performed on ' + . 'the server)'; + throw new RestException(503, $message); + } + } + } + } diff --git a/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php b/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php index 4e1563fc9..1e7c77f8c 100644 --- a/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php +++ b/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php @@ -284,6 +284,8 @@ class Server implements iAuthenticate */ public function postToken($request = null, $returnResponse = false) { + \ProcessMaker\Policies\ControlUnderUpdating::verifyUnderUpgrading(); + // Handle a request for an OAuth2.0 Access Token and send the response to the client if ($request == null) { $request = \OAuth2\Request::createFromGlobals(); From c4a19d555db01bc357e8941b0b6844f674367b0b Mon Sep 17 00:00:00 2001 From: dheeyi william Date: Tue, 9 May 2017 08:34:50 -0400 Subject: [PATCH 6/6] HOR-3177 MySQL Exception in APP when the Mobile Notifications are enabled in env.ini --- .../model/map/NotificationDeviceMapBuilder.php | 2 +- .../classes/model/om/BaseNotificationDevice.php | 4 ++-- workflow/engine/config/schema.xml | 11 +---------- workflow/engine/data/mysql/schema.sql | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php b/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php index ce26120b7..403ec193f 100644 --- a/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php +++ b/workflow/engine/classes/model/map/NotificationDeviceMapBuilder.php @@ -71,7 +71,7 @@ class NotificationDeviceMapBuilder $tMap->addColumn('SYS_LANG', 'SysLang', 'string', CreoleTypes::VARCHAR, false, 10); - $tMap->addColumn('DEV_REG_ID', 'DevRegId', 'string', CreoleTypes::LONGVARCHAR, true, null); + $tMap->addColumn('DEV_REG_ID', 'DevRegId', 'string', CreoleTypes::VARCHAR, true, 255); $tMap->addColumn('DEV_TYPE', 'DevType', 'string', CreoleTypes::VARCHAR, true, 50); diff --git a/workflow/engine/classes/model/om/BaseNotificationDevice.php b/workflow/engine/classes/model/om/BaseNotificationDevice.php index 2f33fbf7b..56a8f3bb4 100644 --- a/workflow/engine/classes/model/om/BaseNotificationDevice.php +++ b/workflow/engine/classes/model/om/BaseNotificationDevice.php @@ -49,7 +49,7 @@ abstract class BaseNotificationDevice extends BaseObject implements Persistent * The value for the dev_reg_id field. * @var string */ - protected $dev_reg_id; + protected $dev_reg_id = ''; /** * The value for the dev_type field. @@ -283,7 +283,7 @@ abstract class BaseNotificationDevice extends BaseObject implements Persistent $v = (string) $v; } - if ($this->dev_reg_id !== $v) { + if ($this->dev_reg_id !== $v || $v === '') { $this->dev_reg_id = $v; $this->modifiedColumns[] = NotificationDevicePeer::DEV_REG_ID; } diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 64ce0a367..cbfc3271e 100644 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -5543,16 +5543,7 @@ - - - - - - - - - - + diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 6a6b4a9e5..ed28ed375 100644 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -3077,7 +3077,7 @@ CREATE TABLE `NOTIFICATION_DEVICE` `DEV_UID` VARCHAR(32) default '' NOT NULL, `USR_UID` VARCHAR(32) default '' NOT NULL, `SYS_LANG` VARCHAR(10) default '', - `DEV_REG_ID` MEDIUMTEXT default '' NOT NULL, + `DEV_REG_ID` VARCHAR(255) default '' NOT NULL, `DEV_TYPE` VARCHAR(50) default '' NOT NULL, `DEV_CREATE` DATETIME NOT NULL, `DEV_UPDATE` DATETIME NOT NULL,