Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d06769c48b | ||
|
|
4c0390f082 | ||
|
|
95bee3dc8c | ||
|
|
65132d8a4a |
@@ -44,6 +44,11 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
||||
'str' => 'INFO',
|
||||
'expected' => 'info',
|
||||
],
|
||||
'notice' => [
|
||||
'level' => 'notice',
|
||||
'str' => 'NOTICE',
|
||||
'expected' => 'notice',
|
||||
],
|
||||
'warn' => [
|
||||
'level' => 'warn',
|
||||
'str' => 'WARN',
|
||||
@@ -238,6 +243,22 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
||||
'log_error' => true,
|
||||
'expected' => '<ERROR> OTHER ERROR MESSAGE',
|
||||
],
|
||||
'notice' => [
|
||||
'id' => '100',
|
||||
'level' => 'notice',
|
||||
'str' => 'NOTICE MESSAGE',
|
||||
'message' => null,
|
||||
'log_error' => null,
|
||||
'expected' => '<NOTICE> NOTICE MESSAGE',
|
||||
],
|
||||
'notice, message' => [
|
||||
'id' => '100',
|
||||
'level' => 'notice',
|
||||
'str' => 'NOTICE MESSAGE',
|
||||
'message' => 'OTHER NOTICE MESSAGE',
|
||||
'log_error' => null,
|
||||
'expected' => '<NOTICE> OTHER NOTICE MESSAGE',
|
||||
],
|
||||
'crash' => [
|
||||
'id' => '300',
|
||||
'level' => 'crash',
|
||||
|
||||
6
www/admin/edit_base_page_test.php
Normal file
6
www/admin/edit_base_page_test.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// empty file for add and remove test
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -198,7 +198,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
public function dbCheckPkSet(): bool
|
||||
{
|
||||
// if pk_id is set, overrule ...
|
||||
if ($this->pk_id) {
|
||||
if (!empty($this->pk_id)) {
|
||||
$this->table_array[$this->pk_name]['value'] = $this->pk_id;
|
||||
}
|
||||
// if not set ... produce error
|
||||
|
||||
@@ -3232,7 +3232,7 @@ class IO
|
||||
*
|
||||
* @param array<mixed> $write_array list of elements to write
|
||||
* @param array<mixed> $not_write_array list of elements not to write
|
||||
* @param int $primary_key id key to decide if we write insert or update
|
||||
* @param int|null $primary_key id key to decide if we write insert or update
|
||||
* @param string $table name for the target table
|
||||
* @param array<mixed> $data data array to override _POST data
|
||||
* @return int|false primary key
|
||||
@@ -3240,7 +3240,7 @@ class IO
|
||||
public function dbWriteData(
|
||||
array $write_array,
|
||||
array $not_write_array,
|
||||
int $primary_key,
|
||||
?int $primary_key,
|
||||
string $table,
|
||||
array $data = []
|
||||
): int|false {
|
||||
@@ -3260,19 +3260,19 @@ class IO
|
||||
* PARAM INFO: $primary key
|
||||
* this can be a plain string/int and will be internal transformed into the array form
|
||||
* or it takes the array form of array [row => column, value => pk value]
|
||||
* @param array<mixed> $write_array list of elements to write
|
||||
* @param int|string|array<mixed> $primary_key primary key string or array set
|
||||
* @param string $table name for the target table
|
||||
* @param array<mixed> $not_write_array list of elements not to write (optional)
|
||||
* @param array<mixed> $not_write_update_array list of elements not
|
||||
* to write during update (optional)
|
||||
* @param array<mixed> $data optional array with data
|
||||
* if not _POST vars are used
|
||||
* @return int|false primary key
|
||||
* @param array<mixed> $write_array list of elements to write
|
||||
* @param null|int|string|array<mixed> $primary_key primary key string or array set
|
||||
* @param string $table name for the target table
|
||||
* @param array<mixed> $not_write_array list of elements not to write (optional)
|
||||
* @param array<mixed> $not_write_update_array list of elements not
|
||||
* to write during update (optional)
|
||||
* @param array<mixed> $data optional array with data
|
||||
* if not _POST vars are used
|
||||
* @return int|false primary key
|
||||
*/
|
||||
public function dbWriteDataExt(
|
||||
array $write_array,
|
||||
int|string|array $primary_key,
|
||||
null|int|string|array $primary_key,
|
||||
string $table,
|
||||
array $not_write_array = [],
|
||||
array $not_write_update_array = [],
|
||||
|
||||
@@ -42,6 +42,7 @@ class ErrorMessage
|
||||
* error_id: internal Error ID (should be unique)
|
||||
* level: error level, can only be ok, info, warn, error, abort, crash
|
||||
* ok and info are positive response: success
|
||||
* notice: a debug message for information only
|
||||
* warn: success, but there might be some things that are not 100% ok
|
||||
* error: input error or error in executing request
|
||||
* abort: an internal error happened as mandatory information that normally is
|
||||
@@ -98,6 +99,12 @@ class ErrorMessage
|
||||
];
|
||||
// write to log for abort/crash
|
||||
switch ($level) {
|
||||
case 'notice':
|
||||
$this->log->notice($message ?? $str, array_merge([
|
||||
'id' => $error_id,
|
||||
'level' => $original_level,
|
||||
], $context));
|
||||
break;
|
||||
case 'error':
|
||||
if ($log_error) {
|
||||
$this->log->error($message ?? $str, array_merge([
|
||||
|
||||
@@ -15,6 +15,7 @@ enum MessageLevel: int
|
||||
{
|
||||
case ok = 100;
|
||||
case info = 200;
|
||||
case notice = 250;
|
||||
case warn = 300;
|
||||
case error = 400;
|
||||
case abort = 500;
|
||||
@@ -30,6 +31,7 @@ enum MessageLevel: int
|
||||
return match (strtolower($name)) {
|
||||
'ok' => self::ok,
|
||||
'info' => self::info,
|
||||
'notice' => self::notice,
|
||||
'warn', 'warning' => self::warn,
|
||||
'error' => self::error,
|
||||
'abort' => self::abort,
|
||||
|
||||
Reference in New Issue
Block a user