APC Object Cache Backend
[resolved] APC Object Cache Backend causes WP_DEBUG notices for Undefined index: (6 posts)

  1. Jeremy Clarke
    Posted 4 years ago #

    This is probably simple to fix. They go something like this:

    NOTICE: wp-content/object-cache.php:111 - Undefined index: add

    which is caused by this line:

    @ ++$this->stats['add'];

    Because you start ++ing the 'add' index without initializing it. The @ even implies that you know this generates errors. Unfortunately WP_DEBUG does not abide the @ trick and still shows the notice in Debug Bar at the top of every screen.

    At the top of the object you define stats thus:

    var $stats = array();

    Why not add the stats indices there?

    var $stats = array('get' => 0, 'delete' => 0, 'add' => 0);

    The only difference I can see when doing it that way is that when the stats method is called (e.g. in the Object Cache section of debug bar) you see the 0 value for Delete rather than having it be missing if there are no deletes, which is more useful IMHO:

    Alternately, you could just add some isset($this->stats['add']) action to the three places where you use the stats property and initialize the keys there if they are missing.

    Thanks for considering this, WP_DEBUG is good for everybody.


  2. Mark Jaquith
    WordPress Lead Dev
    Plugin Author

    Posted 4 years ago #

    Fixed in trunk. Can you test out trunk? I'd like to release it soon.

  3. Jeremy Clarke
    Posted 4 years ago #

    Seems to work for me. Lots of other changes in there that I didn't test out FWIW. I'm just using it on a single-install.

    Also, thanks for the quick reply!

  4. Jeremy Clarke
    Posted 4 years ago #

    Actually I take that back. I'm having serious issues with the new version. It causes get_the_terms() to return an object full of objects instead of an array full of objects, which causes functions like get_the_category to explode.

  5. Jeff Sebring
    Posted 4 years ago #

    2.0.2b is working for me.

    print_r( get_the_terms( 1, 'category' ) );


    Array ( [0] => stdClass Object ( [term_id] => 1 [name] => Uncategorized [slug] => uncategorized [term_group] => 0 [term_taxonomy_id] => 1 [taxonomy] => category [description] => [parent] => 0 [count] => 20 ) )

  6. Mark Jaquith
    WordPress Lead Dev
    Plugin Author

    Posted 4 years ago #

    Jeremy — how is 2.0.3 working for you?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • APC Object Cache Backend
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic