Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 9 additions & 1 deletion lib/equal/log/Logger.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/equal/orm/Model.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
37 changes: 8 additions & 29 deletions lib/equal/orm/ObjectManager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']) {
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions packages/core/classes/Mail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down