Skip to content

Valdation of Redis servers rejects auth parameter #315

@stklcode

Description

@stklcode

Describe the bug

Redis server configuration rejects valid auth parameter.

To Reproduce

On a system with Redis support, add a filter for Redis servers with 7th (auth) parameter:

add_filter( 'cachify_redis_servers', fn () => [
    '127.0.0.1', 6379, 1, null, 0, 0,
    [ 'auth' => [ 'username', 'password' ] ]
] );

Validation rejects the last parameter, because the condition is invalid:

Internally: Cachify_REDIS::sanitize_con_parameters() returns false because of

if ( count( $con ) > 6 && ! is_null( $con[6] ) && is_array( $con[6] ) ) {
//                                             ^^^^^^^^
	return false;  // Context parameters, e.g. authentication (since PhpRedis 5.3).
}

Expected behavior

Cachify should try to connect to the configured Redis server using "username:password" credentals.

I.e. Cachify_REDIS::sanitize_con_parameters() should return the (sanitized) array.

System:

  • Cachify 2.4.0

Additional context

Cross reference: https://wordpress.org/support/topic/php-fatal-error-457

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions