From be04b6becf10a752bdfb3bcb74e7560566c6bf69 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 10 Sep 2020 10:38:35 +0200 Subject: [PATCH] Add warning on unknown key requested using __get methods --- src/includes/class/class.LSldapObject.php | 2 ++ src/includes/class/class.LSlog_logger.php | 6 +++++- src/includes/class/class.LSrelation.php | 2 ++ src/includes/class/class.LSsearchEntry.php | 7 +++---- src/includes/class/class.LSurlRequest.php | 2 ++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/includes/class/class.LSldapObject.php b/src/includes/class/class.LSldapObject.php index 65ae7625..1f191fbe 100644 --- a/src/includes/class/class.LSldapObject.php +++ b/src/includes/class/class.LSldapObject.php @@ -1841,6 +1841,8 @@ class LSldapObject extends LSlog_staticLoggerClass { } return false; } + // Unknown key, log warning + self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context()); } diff --git a/src/includes/class/class.LSlog_logger.php b/src/includes/class/class.LSlog_logger.php index d782384a..d0d8028f 100644 --- a/src/includes/class/class.LSlog_logger.php +++ b/src/includes/class/class.LSlog_logger.php @@ -20,12 +20,14 @@ ******************************************************************************/ +LSsession :: loadLSclass('LSlog_staticLoggerClass'); + /** * Logger class for LSlog * * @author Benjamin Renard */ -class LSlog_logger { +class LSlog_logger extends LSlog_staticLoggerClass { // Name private $name; @@ -95,6 +97,8 @@ class LSlog_logger { case 'level': return $this -> level; } + // Unknown key, log warning + self :: log_warning("$this -> __get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context()); return; } diff --git a/src/includes/class/class.LSrelation.php b/src/includes/class/class.LSrelation.php index 061e5076..d8243268 100644 --- a/src/includes/class/class.LSrelation.php +++ b/src/includes/class/class.LSrelation.php @@ -122,6 +122,8 @@ class LSrelation extends LSlog_staticLoggerClass { $this -> getConfig('linkAttribute', false) ); } + // Unknown key, log warning + self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context()); } /** diff --git a/src/includes/class/class.LSsearchEntry.php b/src/includes/class/class.LSsearchEntry.php index f45dc5cb..17f303ad 100644 --- a/src/includes/class/class.LSsearchEntry.php +++ b/src/includes/class/class.LSsearchEntry.php @@ -253,10 +253,9 @@ class LSsearchEntry extends LSlog_staticLoggerClass { else self :: log_error("__get($key): custom info function is not callable: ".varDump($this->params['customInfos'][$key]['function'])); } - else { - self :: log_warning('LSsearchEntry : '.$this -> dn.' => Unknown property '.$key.' !'); - return __("Unknown property !"); - } + // Unknown key, log warning + self :: log_warning("$this -> __get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context()); + return __("Unknown property !"); } /** diff --git a/src/includes/class/class.LSurlRequest.php b/src/includes/class/class.LSurlRequest.php index d3325552..6f83e7d9 100644 --- a/src/includes/class/class.LSurlRequest.php +++ b/src/includes/class/class.LSurlRequest.php @@ -65,6 +65,8 @@ class LSurlRequest { if (array_key_exists($key, $this->url_params)) { return urldecode($this->url_params[$key]); } + // Unknown key, log warning + self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context()); } /**