0

I am trying to add a Redis object cash server with my WWrdPress site. I am following this article and I've crated account in redislabs.com

As per the tutorial, my object-cache.php file has

 define("WP_REDIS_BACKEND_HOST", "HOST_URL");
 define("WP_REDIS_BACKEND_PORT", "12345");
 define("WP_REDIS_BACKEND_DB", "DATABAES_NAME");
 define("WP_REDIS_PASSWORD", "PA$$WORD");

and

347         $this->redis->auth( $redis['password'] );
348
349         if ( isset( $redis['database'] ) ) {
350           $this->redis->select( $redis['database'] );
351         }

But I get this error in line 350

Error

[Sun Apr 30 19:54:30.579728 2017] [:error] [pid 1750] [client 162.158.26.98:21176] PHP Warning: Redis::select() expects parameter 1 to be integer, string given in /var/www/public/wordpress/wp-content/object-cache.php on line 350, referer: mysite.com/about-us/

How can I solve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
Ariful Haque
  • 3,662
  • 5
  • 37
  • 59

2 Answers2

0

Redis Cloud, and other responsibly-minded Redis-as-a-Service providers, supports only the default database name (or 0). Just remove lines 349-351 from the file, or define("WP_REDIS_BACKEND_DB", 0); and you should be fine.

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117
0

The problem is a strongly typed comparison of variables, meaning phpredis is looking or database name and port to be of type integer, but putting them in "" makes them strings. When you compare variables with === vs. == both type and value match, e.g. 1 !== '1'.

As Itamar mentioned, Redis database "names" are actually numbers, they don't have string names like other databases.

Try:

 define("WP_REDIS_BACKEND_HOST", "HOST_URL");
 define("WP_REDIS_BACKEND_PORT", 12345); // this is different
 define("WP_REDIS_BACKEND_DB", 0); // this is different
 define("WP_REDIS_PASSWORD", "PA$$WORD");
repat
  • 320
  • 3
  • 12