Title: Undefined array key &#8220;timeout&#8221;
Last modified: July 29, 2022

---

# Undefined array key “timeout”

 *  Resolved [Michael](https://wordpress.org/support/users/michaelwp85/)
 * (@michaelwp85)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/)
 * W3TC version **2.2.3** throws warnings.
 *     ```
       Warning: Undefined array key "timeout" in ....plugins/w3-total-cache/Cache_Redis.php on line 99
       Warning: Undefined array key "retry_interval" in ...plugins/w3-total-cache/Cache_Redis.php on line 100
       Warning: Undefined array key "read_timeout" in ...plugins/w3-total-cache/Cache_Redis.php on line 101
       ```
   
 * **How to reproduce:**
    Use redis to cache the W3TC config. Set W3TC_CONFIG_CACHE_ENGINE
   to redis.
 * **Root cause:**
    Cache_Redis.php 99-101:
 *     ```
       $this->_timeout                = $config['timeout'];
       $this->_retry_interval          = $config['retry_interval'];
       $this->_read_timeout            = $config['read_timeout'];
       ```
   
 * The config that is returned in ConfigCache 74:
 *     ```
       $engineConfig = array(
           'servers' => explode( ',', W3TC_CONFIG_CACHE_REDIS_SERVERS ),
           'persistent' =>
               ( defined( 'W3TC_CONFIG_CACHE_REDIS_PERSISTENT' ) ?
                   W3TC_CONFIG_CACHE_REDIS_PERSISTENT : true ),
           'dbid' =>
               ( defined( 'W3TC_CONFIG_CACHE_REDIS_DBID' ) ?
                   W3TC_CONFIG_CACHE_REDIS_DBID : 0 ),
           'password' =>
               ( defined( 'W3TC_CONFIG_CACHE_REDIS_PASSWORD' ) ?
                   W3TC_CONFIG_CACHE_REDIS_PASSWORD : '' ),
           'key_version_mode' => 'disabled'
       );
       ```
   
 * The returned config is missing the keys that are expected.
 * The issue was introduced in version 2.2.2.
    Downgrading to 2.2.1 removes the 
   warnings.
 * Additionally, there are multiple deprecation notices:
    `Deprecated: Redis::pconnect():
   Passing null to parameter #3 ($timeout) of type float is deprecated in ...plugins/
   w3-total-cache/Cache_Redis.php on line 506`
    -  This topic was modified 3 years, 8 months ago by [Michael](https://wordpress.org/support/users/michaelwp85/).

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15871478)
 * Hello [@michaelwp85](https://wordpress.org/support/users/michaelwp85/)
 * Thank you for reaching out and I m happy to assist you with this.
    I’ve tried
   to replicate the problem, however, Redis works as expected with the PHP Redis
   installed. Have you made any changes in the db-config.php? What is the PHP version
   you are using? Thanks!
 *  Thread Starter [Michael](https://wordpress.org/support/users/michaelwp85/)
 * (@michaelwp85)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15871594)
 * Hi [@vmarko](https://wordpress.org/support/users/vmarko/),
 * No changes are made to the db-config.php, this file is in my git ignore and I
   always let w3 be responsible for creating it.
 * I’m currently running PHP 8.1, but we also have loads of production sites running
   8 with the same issue. And I’ve just tested 7.4 same issues.
 * To be clear it’s not just using PHP Redis, it’s storing the W3TC config in Redis
   using the constants. Following the stack trace and looking at the code I shared
   this will always throw these warnings since the array keys are never filled in
   ConfigCache.php on line 74.
 * Kind regards,
    Michael
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15871658)
 * Hello [@michaelwp85](https://wordpress.org/support/users/michaelwp85/)
 * Thank you for your feedback.
    Let me get back to you once we investigate this
   and Have more information. Thanks!
 *  Thread Starter [Michael](https://wordpress.org/support/users/michaelwp85/)
 * (@michaelwp85)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15876459)
 * Thanks, [@vmarko](https://wordpress.org/support/users/vmarko/).
    If you need 
   more input or a git repo to be able to reproduce the issue please let me know.
 * P.S.
    I don’t think the warnings are breaking anything at the moment but it’s
   not possible to configure certain settings and it is flooding logs and CLI output.
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15876911)
 * Hello [@michaelwp85](https://wordpress.org/support/users/michaelwp85/)
 * Thank you for your patience.
    1. The settings fields for Redis should be checked
   to ensure that they can’t be saved as blank 2. The 0 defaults should be checked
   to ensure that they are being interpreted as int 0 3. Try adding the lines below
   in ConfigCache.php lines 86+ See below:
 *     ```
       case 'redis':
       			$engineConfig = array(
       				'servers' => explode( ',', W3TC_CONFIG_CACHE_REDIS_SERVERS ),
       				'persistent' =>
       					( defined( 'W3TC_CONFIG_CACHE_REDIS_PERSISTENT' ) ?
       						W3TC_CONFIG_CACHE_REDIS_PERSISTENT : true ),
       				'dbid' =>
       					( defined( 'W3TC_CONFIG_CACHE_REDIS_DBID' ) ?
       						W3TC_CONFIG_CACHE_REDIS_DBID : 0 ),
       				'password' =>
       					( defined( 'W3TC_CONFIG_CACHE_REDIS_PASSWORD' ) ?
       						W3TC_CONFIG_CACHE_REDIS_PASSWORD : '' ),
       		'key_version_mode' => 'disabled',
                       'timeout' => 0,
       		'retry_interval' => 0,
       		'read_timeout' => 0,
       			);
       			break;
       ```
   
 * To clarify add the lines:
 *     ```
       'timeout' => 0,
         'retry_interval' => 0,
         'read_timeout' => 0,
       ```
   
 * Just after the line:
 * `'key_version_mode' => 'disabled'`
 * Let me know if this helps!
 * Thanks!
 *  Thread Starter [Michael](https://wordpress.org/support/users/michaelwp85/)
 * (@michaelwp85)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15876981)
 * [@vmarko](https://wordpress.org/support/users/vmarko/) thanks for your reply 
   but this is not my code, this is the W3TC plugin code. This is a bug in the plugin
   not in my codebase. That’s why I’m posting here.
 * [https://plugins.trac.wordpress.org/browser/w3-total-cache/trunk/ConfigCache.php#L73](https://plugins.trac.wordpress.org/browser/w3-total-cache/trunk/ConfigCache.php#L73)
 * This config (`$engineConfig`) is passed to the following constructor:
    [https://plugins.trac.wordpress.org/browser/w3-total-cache/trunk/Cache_Redis.php#L91](https://plugins.trac.wordpress.org/browser/w3-total-cache/trunk/Cache_Redis.php#L91)
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15877544)
 * Hello [@michaelwp85](https://wordpress.org/support/users/michaelwp85/)
 * Thank you for your feedback.
    I understand this, and this why I asked you to 
   add those lines to /wp-content/plugins/w3-total-cache/ConfigCache.php So can 
   you please add the following to the mentioned file
 *     ```
        'timeout' => 0,
         'retry_interval' => 0,
         'read_timeout' => 0,
       ```
   
 * Just after the line `'key_version_mode' => 'disabled'`
    and see if the problem
   persists. Thanks!
 *  Thread Starter [Michael](https://wordpress.org/support/users/michaelwp85/)
 * (@michaelwp85)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15877624)
 * Hi [@vmarko](https://wordpress.org/support/users/vmarko/),
 * Sorry, I thought you suggested a fix instead of requesting me to check if this
   would resolve the problem.
    Looking at the code I already knew this would fix
   it. But I double-checked and can confirm this resolves the issues. Adding the
   configuration values will remove the warnings.
 * The better fix would be to retrieve these values from the stored config instead
   of hardcoding values to 0.
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15877746)
 * Hello [@michaelwp85](https://wordpress.org/support/users/michaelwp85/)
 * Thank you for your feedback.
    Thank you for your confirmation. Let me bring this
   to the team for more testing and I’ll get back to you. Thanks!
 *  Thread Starter [Michael](https://wordpress.org/support/users/michaelwp85/)
 * (@michaelwp85)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15877787)
 * [@vmarko](https://wordpress.org/support/users/vmarko/) Thanks!
 * Quick question for any future issues if they may arise, would it be better to
   create a ticket on GitHub or report it here? I could try to provide a PR on GitHub
   to resolve the issue.
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15878314)
 * Hello [@michaelwp85](https://wordpress.org/support/users/michaelwp85/)
 * The Github repo should be used for the PR, and confirmed bugs so feel free to
   create a pull request which will be reviewed by the devs.
 * Thanks!
 *  Thread Starter [Michael](https://wordpress.org/support/users/michaelwp85/)
 * (@michaelwp85)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15880218)
 * PR has been created here: [https://github.com/W3EDGE/w3-total-cache/pull/542](https://github.com/W3EDGE/w3-total-cache/pull/542)
 *  Plugin Author [Joe Cartonia](https://wordpress.org/support/users/joemoto/)
 * (@joemoto)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15881311)
 * [@michaelwp85](https://wordpress.org/support/users/michaelwp85/) Thank you for
   your contribution. We’ll include this fix in the next patch release (2.2.4).

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Undefined array key “timeout”’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 13 replies
 * 3 participants
 * Last reply from: [Joe Cartonia](https://wordpress.org/support/users/joemoto/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/undefined-array-key-timeout/#post-15881311)
 * Status: resolved