Title: Undefined array key
Last modified: August 30, 2024

---

# Undefined array key

 *  [Mikel King](https://wordpress.org/support/users/vizkr/)
 * (@vizkr)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/undefined-array-key-49/)
 * When working on WPCLI on WP Engine we have been seeing thousands of these notices
   since we upgraded to PHP8.2.
 *     ```wp-block-code
       PHP Warning: Undefined array key "get" in /nas/content/live/haymarketwp/wp-content/object-cache.php on line 348Warning: Undefined array key "get" in /nas/content/live/haymarketwp/wp-content/object-cache.php on line 348PHP Warning: Undefined array key "miss" in /nas/content/live/haymarketwp/wp-content/object-cache.php on line 351Warning: Undefined array key "miss" in /nas/content/live/haymarketwp/wp-content/object-cache.php on line 351PHP Warning: Undefined array key "add" in /nas/content/live/haymarketwp/wp-content/object-cache.php on line 237Warning: Undefined array key "add" in /nas/content/live/haymarketwp/wp-content/object-cache.php on line 237
       ```
   
 * The remediation solution is simple and I have patched the file.
 * At line 236:
 *     ```wp-block-code
       		if ( false !== $result ) {            $this->stats['add'] = $this->stats['add'] ?? 0;			++$this->stats['add'];			$this->group_ops[$group][] = "add $id";			$this->cache[$key] = $data;		}
       ```
   
 * At line 348:
 *     ```wp-block-code
       		if ( $found ) {            $this->stats['get'] = $this->stats['get'] ?? 0;			++$this->stats['get'];			$this->group_ops[$group][] = "get $id";		} else {            $this->stats['miss'] = $this->stats['miss'] ?? 0;			++$this->stats['miss'];		}
       ```
   
 * I have confirmed that this plugin is working on all versions up to WordPress 
   6.5.5 with PHP8.2. The null coalescence in the patch has been available since
   PHP7.0.
 * If older backward compatibility is required then replacing each null coalescence
   with the following condition check will also work.
 *     ```wp-block-code
                   if ( ! array_key_exists( 'miss', $this->stats ) ) {                $this->stats['miss'] = 0;            }
       ```
   
 * Obviously it would be good to completely unpack the stats array and understand
   where it should be properly initialized in the first place to eliminate all of
   this extra safety checking, but I needed an immediate resolution to the bloat
   of error notices.
 * Feel free to ping me in wp slack.
 * Cheers,
 * Mikel
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fundefined-array-key-49%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 * ![](https://s.w.org/plugins/geopattern-icon/memcached-redux_98a1ab.svg)
 * [Memcached Redux](https://wordpress.org/plugins/memcached-redux/)
 * [Support Threads](https://wordpress.org/support/plugin/memcached-redux/)
 * [Active Topics](https://wordpress.org/support/plugin/memcached-redux/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/memcached-redux/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/memcached-redux/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Mikel King](https://wordpress.org/support/users/vizkr/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/undefined-array-key-49/)
 * Status: not resolved