Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Zheng committed Jun 11, 2024
1 parent 36fe299 commit 2e5eca3
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/object-cache.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public function __construct($cfg = false)
}
// If OC is OFF, will hit here to init OC after conf initialized
elseif (defined('LITESPEED_CONF_LOADED')) {

$this->_cfg_debug = $this->conf(Base::O_DEBUG) ? $this->conf(Base::O_DEBUG) : false;
$this->_cfg_debug = $this->conf(Base::O_DEBUG) ? $this->conf(Base::O_DEBUG) : false;
$this->_cfg_method = $this->conf(Base::O_OBJECT_KIND) ? true : false;
$this->_cfg_host = $this->conf(Base::O_OBJECT_HOST);
$this->_cfg_port = $this->conf(Base::O_OBJECT_PORT);
Expand All @@ -115,7 +114,7 @@ public function __construct($cfg = false)
// Use self::const to avoid loading more classes
$cfg = json_decode(file_get_contents(WP_CONTENT_DIR . '/' . self::CONF_FILE), true);
if (!empty($cfg[self::O_OBJECT_HOST])) {
$this->_cfg_debug = !empty($cfg[Base::O_DEBUG]) ? $cfg[Base::O_DEBUG] : false;
$this->_cfg_debug = !empty($cfg[Base::O_DEBUG]) ? $cfg[Base::O_DEBUG] : false;
$this->_cfg_method = !empty($cfg[self::O_OBJECT_KIND]) ? $cfg[self::O_OBJECT_KIND] : false;
$this->_cfg_host = $cfg[self::O_OBJECT_HOST];
$this->_cfg_port = $cfg[self::O_OBJECT_PORT];
Expand All @@ -140,24 +139,26 @@ public function __construct($cfg = false)
$this->_cfg_enabled = false;
}
}

/**
* Add debug.
*
* @since 6.3
* @access private
*/
private function debug_oc( $text, $show_error = false ){
if( defined('LSCWP_LOG') ){
Debug2::debug( $text );
private function debug_oc($text, $show_error = false)
{
if (defined('LSCWP_LOG')) {
Debug2::debug($text);

return;
}

if (!$show_error && !$this->_cfg_debug) return;
}

if (!$show_error && !$this->_cfg_debug) {
return;
}

error_log( gmdate('m/d/y H:i:s') . ' - ' . $text . PHP_EOL, 3, WP_CONTENT_DIR . '/debug.log' );
error_log(gmdate('m/d/y H:i:s') . ' - ' . $text . PHP_EOL, 3, WP_CONTENT_DIR . '/debug.log');
}

/**
Expand Down Expand Up @@ -333,10 +334,10 @@ private function _connect()
$failed = true;
}
} catch (\Exception $e) {
$this->debug_oc( 'Redis connect exception: ' . $e->getMessage(), true );
$this->debug_oc('Redis connect exception: ' . $e->getMessage(), true);
$failed = true;
} catch (\ErrorException $e) {
$this->debug_oc( 'Redis connect error: ' . $e->getMessage(), true );
$this->debug_oc('Redis connect error: ' . $e->getMessage(), true);
$failed = true;
}
restore_error_handler();
Expand Down

0 comments on commit 2e5eca3

Please sign in to comment.