From 14dab54f2c9eb34072bb120886d1a7b33def139a Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Thu, 17 Oct 2024 13:55:38 +0900 Subject: [PATCH] Update DB\IO and do not print call steck on DB_INFO calls, array list entry clean up --- src/Combined/ArrayHandler.php | 16 ++++++++++++++++ src/DB/IO.php | 24 ++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Combined/ArrayHandler.php b/src/Combined/ArrayHandler.php index bbe3943..b100294 100644 --- a/src/Combined/ArrayHandler.php +++ b/src/Combined/ArrayHandler.php @@ -509,6 +509,22 @@ class ArrayHandler } return $array; } + + /** + * Remove entries from a simple array, will not keep key order + * + * any array content is allowed + * + * https://stackoverflow.com/a/369608 + * + * @param array $array Array where elements are located + * @param array $remove Elements to remove + * @return array Array with $remove elements removed + */ + public static function arrayRemoveEntry(array $array, array $remove): array + { + return array_diff($array, $remove); + } } // __END__ diff --git a/src/DB/IO.php b/src/DB/IO.php index a006b1a..9f1a59d 100644 --- a/src/DB/IO.php +++ b/src/DB/IO.php @@ -823,6 +823,11 @@ class IO ); break; default: + // no context on DB_INFO + if ($id == 'DB_INFO') { + echo "DB INFO
"; + $context = []; + } // used named arguments so we can easy change the order of debug $this->log->debug( group_id: $debug_id, @@ -1814,14 +1819,13 @@ class IO $html_tags = ['{b}', '{/b}', '{br}']; $replace_html = ['', '', '
']; $replace_text = ['', '', ' **** ']; - $string = ''; - $string .= '{b}-DB-info->{/b} Connected to db {b}\'' . $this->db_name . '\'{/b} '; - $string .= 'with schema {b}\'' . $this->db_schema . '\'{/b} '; - $string .= 'as user {b}\'' . $this->db_user . '\'{/b} '; - $string .= 'at host {b}\'' . $this->db_host . '\'{/b} '; - $string .= 'on port {b}\'' . $this->db_port . '\'{/b} '; - $string .= 'with ssl mode {b}\'' . $this->db_ssl . '\'{/b}{br}'; - $string .= '{b}-DB-info->{/b} DB IO Class debug output: {b}' + $string = '{b}-DB-info->{/b} Connected to db {b}\'' . $this->db_name . '\'{/b} ' + . 'with schema {b}\'' . $this->db_schema . '\'{/b} ' + . 'as user {b}\'' . $this->db_user . '\'{/b} ' + . 'at host {b}\'' . $this->db_host . '\'{/b} ' + . 'on port {b}\'' . $this->db_port . '\'{/b} ' + . 'with ssl mode {b}\'' . $this->db_ssl . '\'{/b}{br}' + . '{b}-DB-info->{/b} DB IO Class debug output: {b}' . ($this->dbGetDebug() ? 'Yes' : 'No') . '{/b}'; if ($log === true) { // if debug, remove / change b @@ -1829,7 +1833,7 @@ class IO $html_tags, $replace_text, $string - ), 'dbInfo'); + ), 'DB_INFO'); } else { $string = $string . '{br}'; } @@ -1985,7 +1989,7 @@ class IO if (is_array($array)) { $this->nbsp = ''; $string .= $this->__printArray($array); - $this->__dbDebugMessage('db', $string, 'dbDumpData'); + $this->__dbDebugMessage('db', $string, 'DB_INFO'); } return $string; }