WP Cerber PHP 8.3 Compatibility Fixes
Plugin: WP Cerber Security 9.6.11
PHP: 8.3.28 | WordPress: 6.9
Files: cerber-common.php, cerber-load.php, cerber-lab.php
1) hexdec/octdec Deprecation Warning
File: cerber-common.php | Line: 5162
E_DEPRECATED: Invalid characters passed for attempted conversion
Before:
if ( $v[0] == '0' ) {
$v = ( $v[1] == 'x' || $v[1] == 'X' ) ? hexdec( $v ) : octdec( $v );
}
After:
if ( isset( $v[0] ) && $v[0] == '0' && strlen( $v ) > 1 ) {
if ( isset( $v[1] ) && ( $v[1] == 'x' || $v[1] == 'X' ) ) {
$hex_part = substr( $v, 2 );
if ( $hex_part !== false && preg_match( '/^[0-9a-fA-F]+$/', $hex_part ) ) {
$v = hexdec( $v );
} else {
$v = 0;
}
} else {
$oct_part = substr( $v, 1 );
if ( $oct_part !== false && preg_match( '/^[0-7]+$/', $oct_part ) ) {
$v = octdec( $v );
} else {
$v = 0;
}
}
}
2) Constant Already Defined Warning
File: cerber-common.php | Line: 3992
E_WARNING: Constant DB_NAME already defined
Before:
@eval( $config );
After:
$config = preg_replace(
"/define\s*\(\s*(['\"])([^'\"]+)\\1/",
"defined('$2') || define($1$2$1",
$config
);
@eval( $config );
3) Undefined Array Key HTTP_HOST / REQUEST_METHOD
File: cerber-load.php | Lines: 8067-8068
E_WARNING: Undefined array key "HTTP_HOST"
E_WARNING: Undefined array key "REQUEST_METHOD"
Before:
$uri = $scheme . '://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$method = crb_sanitize_alphanum( $_SERVER['REQUEST_METHOD'] );
After:
$http_host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
$request_uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';
$request_method = isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'GET';
$uri = $scheme . '://'. $http_host . $request_uri;
$method = crb_sanitize_alphanum( $request_method );
4) preg_replace() Null Parameter
File: cerber-common.php | Line: 1389
E_DEPRECATED: preg_replace(): Passing null to parameter #3 ($subject) is deprecated
Before:
function crb_sanitize_alphanum( $value, $check_utf8 = false ) {
if ( is_array( $value ) ) { ... }
if ( $check_utf8 && ! preg_match('/^[\x00-\x7F]*$/', $value) ) {
$value = iconv( 'UTF-8', 'UTF-8//IGNORE', $value );
}
return preg_replace( '/\W/', '', $value );
}
After:
function crb_sanitize_alphanum( $value, $check_utf8 = false ) {
if ( is_array( $value ) ) { ... }
if ( $value === null || $value === '' ) {
return '';
}
$value = (string) $value;
if ( $check_utf8 && ! preg_match('/^[\x00-\x7F]*$/', $value) ) {
$value = iconv( 'UTF-8', 'UTF-8//IGNORE', $value );
if ( $value === false ) {
return '';
}
}
return preg_replace( '/\W/', '', $value );
}
5) Wrong Translation Function _() vs __()
File: cerber-lab.php | Line: 741
E_ERROR: Uncaught ArgumentCountError: _() expects exactly 1 argument, 2 given
Cause: Developer used PHP’s _() (gettext, 1 arg) instead of WordPress’s __() (i18n, 2 args).
Before:
$site_ip = $ret['net_connection_ip'] ?? _( 'Unknown', 'wp-cerber' );
After:
$site_ip = $ret['net_connection_ip'] ?? __( 'Unknown', 'wp-cerber' );
Compatibility
| PHP | Status |
|---|---|
| 7.4 - 8.4+ |
Files to Upload
wp-cerber/cerber-common.php
wp-cerber/cerber-load.php
wp-cerber/cerber-lab.php
Performance Enhancement Suggestion
Problem: Database Bloat from Traffic Logging
The cerber_traffic table can grow to 3+ GB on active sites, causing connection errors.
Affected Functions:
| Function | File | Line |
|---|---|---|
cerber_traffic_log() |
cerber-load.php | ~7957 |
INSERT to CERBER_TRAF_TABLE |
cerber-load.php | ~8241 |
Suggested: File-Based Logging Option
/wp-content/cerber-logs/
├── traffic-2026-02-01.jsonl
├── traffic-2026-02-02.jsonl
└── .htaccess (deny all)
Recommendation:
- Keep
cerber_login MySQL (security-critical) - Move
cerber_trafficto file-based (analytics-only)