fix: [audit logs] monkey fix for the missing fields when coming from a CLI query
parent
b90e563aec
commit
8cf325d263
|
@ -58,7 +58,12 @@ class AuditLogsTable extends AppTable
|
||||||
$data['request_ip'] = '127.0.0.1';
|
$data['request_ip'] = '127.0.0.1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (['user_id', 'request_type', 'authkey_id'] as $field) {
|
$defaults = [
|
||||||
|
'user_id' => 0,
|
||||||
|
'request_type' => 'CLI',
|
||||||
|
'authkey_id' => 0
|
||||||
|
];
|
||||||
|
foreach (array_keys($defaults) as $field) {
|
||||||
if (!isset($data[$field])) {
|
if (!isset($data[$field])) {
|
||||||
if (!isset($userInfo)) {
|
if (!isset($userInfo)) {
|
||||||
$userInfo = $this->userInfo();
|
$userInfo = $this->userInfo();
|
||||||
|
@ -92,6 +97,11 @@ class AuditLogsTable extends AppTable
|
||||||
}
|
}
|
||||||
$data['changed'] = $changed;
|
$data['changed'] = $changed;
|
||||||
}
|
}
|
||||||
|
foreach ($defaults as $field => $default_value) {
|
||||||
|
if (!isset($data[$field])) {
|
||||||
|
$data[$field] = $default_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
|
public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
|
||||||
|
@ -157,7 +167,7 @@ class AuditLogsTable extends AppTable
|
||||||
if ($this->user !== null) {
|
if ($this->user !== null) {
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user = ['id' => 0, /*'org_id' => 0, */'authkey_id' => 0, 'request_type' => self::REQUEST_TYPE_DEFAULT, 'name' => ''];
|
$this->user = ['id' => 0, /*'org_id' => 0, */'authkey_id' => 0, 'request_type' => self::REQUEST_TYPE_DEFAULT, 'name' => ''];
|
||||||
|
|
||||||
$isShell = (php_sapi_name() === 'cli');
|
$isShell = (php_sapi_name() === 'cli');
|
||||||
|
|
Loading…
Reference in New Issue