ZP-765 Add cache value for the check of the AuthUser in the SpecialLogUser...

ZP-765 Add cache value for the check of the AuthUser in the SpecialLogUser array. Released under the Affero GNU General Public License (AGPL) version 3.
parent 332004ba
...@@ -68,11 +68,17 @@ abstract class Log { ...@@ -68,11 +68,17 @@ abstract class Log {
protected $specialLogUsers = array(); protected $specialLogUsers = array();
/** /**
* Only used as a cache value for IsUserInSpecialLogUsers function * Only used as a cache value for IsUserInSpecialLogUsers.
* @var array * @var array
*/ */
private $isUserInSpecialLogUsers = array(); private $isUserInSpecialLogUsers = array();
/**
* Only used as a cache value for IsAuthUserInSpecialLogUsers function
* @var bool
*/
private $isAuthUserInSpecialLogUsers = false;
/** /**
* @var array * @var array
*/ */
...@@ -109,9 +115,29 @@ abstract class Log { ...@@ -109,9 +115,29 @@ abstract class Log {
* @access public * @access public
*/ */
public function SetAuthUser($value) { public function SetAuthUser($value) {
$this->isAuthUserInSpecialLogUsers = false;
$this->authUser = $value; $this->authUser = $value;
} }
/**
* Check that the current authUser ($this->GetAuthUser) is in the special log user array.
* This call is equivalent to `$this->IsUserInSpecialLogUsers($this->GetAuthUser())` at the exception that this
* call uses cache so there won't be more than one check to the specialLogUser for the AuthUser.
*
* @access public
* @return bool
*/
public function IsAuthUserInSpecialLogUsers(){
if ($this->isAuthUserInSpecialLogUsers) {
return true;
}
if($this->IsUserInSpecialLogUsers($this->GetAuthUser())){
$this->isAuthUserInSpecialLogUsers = true;
return true;
}
return false;
}
/** /**
* @access public * @access public
* @return string * @return string
...@@ -200,7 +226,7 @@ abstract class Log { ...@@ -200,7 +226,7 @@ abstract class Log {
if ($loglevel <= LOGLEVEL) { if ($loglevel <= LOGLEVEL) {
$this->Write($loglevel, $message); $this->Write($loglevel, $message);
} }
if ($loglevel <= LOGUSERLEVEL && $this->IsUserInSpecialLogUsers($this->GetAuthUser())) { if ($loglevel <= LOGUSERLEVEL && $this->IsAuthUserInSpecialLogUsers()) {
if (RequestProcessor::isUserAuthenticated()) { if (RequestProcessor::isUserAuthenticated()) {
// something was logged before the user was authenticated, write this to the log // something was logged before the user was authenticated, write this to the log
if (!empty($this->unauthMessageCache)) { if (!empty($this->unauthMessageCache)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment