From e6902f9c29a1d86bac8968401977cd61d5fa6bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fran=C3=A7oys?= Date: Tue, 6 Aug 2024 15:53:06 +0200 Subject: [PATCH 1/5] fixed cc & bcc assignment --- packages/core/classes/Mail.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/core/classes/Mail.class.php b/packages/core/classes/Mail.class.php index 9cf6d038a..8ec68aeff 100644 --- a/packages/core/classes/Mail.class.php +++ b/packages/core/classes/Mail.class.php @@ -351,10 +351,16 @@ private static function createEnvelope($message): \Swift_Message { // set sender and recipients $envelope ->setTo($message['to']) - ->setCc($message['cc']) - ->setBcc($message['bcc']) ->setFrom([constant('EMAIL_SMTP_ACCOUNT_EMAIL') => constant('EMAIL_SMTP_ACCOUNT_DISPLAYNAME')]); + if(isset($message['cc']) && strlen($message['cc']) > 0) { + $envelope->setCc($message['cc']); + } + + if(isset($message['bcc']) && strlen($message['bcc']) > 0) { + $envelope->setBcc($message['bcc']); + } + if(isset($message['reply_to']) && strlen($message['reply_to']) > 0) { $envelope->setReplyTo($message['reply_to']); } From 3682b5174fd27f8df1e8583551fecc04f1a6c613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fran=C3=A7oys?= Date: Wed, 7 Aug 2024 11:28:04 +0200 Subject: [PATCH 2/5] removed unused code --- lib/equal/orm/ObjectManager.class.php | 37 ++++++--------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/lib/equal/orm/ObjectManager.class.php b/lib/equal/orm/ObjectManager.class.php index 9dcbe202f..991ff7513 100644 --- a/lib/equal/orm/ObjectManager.class.php +++ b/lib/equal/orm/ObjectManager.class.php @@ -671,7 +671,7 @@ private function load($class, $ids, $fields, $lang) { } } if(count($missing_ids)) { - $res = $this->callonce($class, $schema[$field]['function'], $missing_ids, [], $lang, ['ids', 'lang']); + $res = $this->callonce($class, $schema[$field]['function'], $missing_ids, [], $lang); if($res > 0) { foreach($missing_ids as $oid) { if(isset($res[$oid])) { @@ -1620,32 +1620,11 @@ public function update($class, $ids=null, $fields=null, $lang=null, $create=fals // 3) make sure objects in the collection can be updated - - // if current call results from an object creation, the cancreate hook prevails over canupdate and we ignore the later - if(!$create) { - // always allow special fields to be updated - // #todo - is it right to do so? - $fields_to_check = array_diff_key($fields, $object::getSpecialColumns()); - foreach($fields_to_check as $field => $value) { - // always allow computed fields to be reset - if($schema[$field]['type'] == 'computed' && $value === null) { - unset($fields_to_check[$field]); - } - } - // #todo - split the tests with status check against the object workflow - /* - // #moved to Collection - $canupdate = $this->callonce($class, 'canupdate', $ids, $fields_to_check, $lang); - if($canupdate > 0 && !empty($canupdate)) { - throw new \Exception(serialize($canupdate), QN_ERROR_NOT_ALLOWED); - } - */ - } + // #memo - moved to Collection // #memo - writing an object does not change its state, unless when explicitly set in $fields $fields['modified'] = time(); - // 4) call 'onbeforeupdate' hook : notify objects that they're about to be updated with given values if(!$create) { @@ -1714,13 +1693,13 @@ public function update($class, $ids=null, $fields=null, $lang=null, $create=fals // #memo - several onupdate callbacks can, in turn, trigger a same other callback, which must then be called as many times as necessary foreach($onupdate_fields as $field) { // run onupdate callback (ignore undefined methods) - $this->callonce($class, $schema[$field]['onupdate'], $ids, $fields, $lang, ['ids', 'values', 'lang']); + $this->callonce($class, $schema[$field]['onupdate'], $ids, $fields, $lang); } } if(count($onrevert_fields)) { foreach($onrevert_fields as $field) { // run onrevert callback (ignore undefined methods) - $this->callonce($class, $schema[$field]['onrevert'], $ids, $fields, $lang, ['ids', 'values', 'lang']); + $this->callonce($class, $schema[$field]['onrevert'], $ids, $fields, $lang); } } } @@ -2086,10 +2065,10 @@ public function delete($class, $ids, $permanent=false) { // 3) call 'ondelete' hook : notify objects that they're about to be deleted if(method_exists($class, 'onbeforedelete')) { - $this->callonce($class, 'onbeforedelete', $ids, [], null, ['ids']); + $this->callonce($class, 'onbeforedelete', $ids); } else { - $this->callonce($class, 'ondelete', $ids, [], null, ['ids']); + $this->callonce($class, 'ondelete', $ids); } // 4) cascade deletions / relations updates @@ -2119,7 +2098,7 @@ public function delete($class, $ids, $permanent=false) { $rel_schema = $this->getObjectSchema($def['foreign_object']); // call ondelete method when defined (to allow cascade deletion) if(isset($rel_schema[$def['foreign_field']]) && isset($rel_schema[$def['foreign_field']]['ondelete'])) { - $call_res = $this->callonce($class, $rel_schema[$def['foreign_field']]['ondelete'], $rel_ids, [], null, ['ids']); + $call_res = $this->callonce($class, $rel_schema[$def['foreign_field']]['ondelete'], $rel_ids); // for unknown method, check special keywords 'cascade' and 'null' if($call_res < 0) { switch($rel_schema[$def['foreign_field']]['ondelete']) { @@ -2178,7 +2157,7 @@ public function delete($class, $ids, $permanent=false) { // 4) call 'onafterdelete' hook - $this->callonce($class, 'onafterdelete', $ids, [], null, ['ids']); + $this->callonce($class, 'onafterdelete', $ids); } catch(Exception $e) { trigger_error("ORM::".$e->getMessage(), QN_REPORT_ERROR); From 4abba28f6e47cf4dec5d7c40d844daf178bff360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fran=C3=A7oys?= Date: Wed, 7 Aug 2024 13:47:12 +0200 Subject: [PATCH 3/5] deactivated storing event data --- lib/equal/log/Logger.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/equal/log/Logger.class.php b/lib/equal/log/Logger.class.php index 50449c65b..70520a890 100644 --- a/lib/equal/log/Logger.class.php +++ b/lib/equal/log/Logger.class.php @@ -59,6 +59,12 @@ public function log($user_id, $action, $object_class, $object_id, $fields=null) $user_id = QN_ROOT_USER_ID; } + /* + // #todo - this feature is disabled and should be replaced with a link (m2o) to a Change object + // holding the optional payload of the event + + // #memo - with time, core_log table grows big and should only contain essential (meta) data + $json = json_encode($fields); // discard faulty JSON if($json === false) { @@ -69,12 +75,14 @@ public function log($user_id, $action, $object_class, $object_id, $fields=null) // drop payload $json = '{"ignored": "resulting JSON too large"}'; } + */ + $values = [ 'action' => $action, 'object_class' => $object_class, 'object_id' => $object_id, 'user_id' => $user_id, - 'value' => $json + // 'value' => $json ]; // logs are system objects (no permissions must be applied) From 806314be2e566954d6390e4688ab1b7d3555c45f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fran=C3=A7oys?= Date: Wed, 7 Aug 2024 13:47:48 +0200 Subject: [PATCH 4/5] update LOGGING_ENABLED description + help --- config/schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/schema.json b/config/schema.json index b15b760a3..d6247c777 100644 --- a/config/schema.json +++ b/config/schema.json @@ -284,7 +284,8 @@ "type": "boolean", "instant": true, "default": true, - "description": "Keep in mind that enabling logging increases I/O operations." + "description": "Flag for requesting to store meta data whenever an event occurs (creation, update, deletion or custom event).", + "help": "Keep in mind that enabling logging increases I/O operations and impacts performances." }, "UPLOAD_MAX_FILE_SIZE": { "type": "integer", From 999a42a4ed5d338a924f588f50df7f3337671d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fran=C3=A7oys?= Date: Thu, 8 Aug 2024 12:50:21 +0200 Subject: [PATCH 5/5] #167 fixed --- lib/equal/orm/Model.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/equal/orm/Model.class.php b/lib/equal/orm/Model.class.php index 34137ac7f..d122085b4 100644 --- a/lib/equal/orm/Model.class.php +++ b/lib/equal/orm/Model.class.php @@ -358,7 +358,7 @@ public final function getFields() { * * @return Field Associative array mapping fields names with their related Field instances. */ - public final function getField($field): Field { + public final function getField($field): ?Field { if(isset($this->schema[$field])) { $type = $this->schema[$field]['type']; while($type == 'alias') {