Using PHP 5.3.6 I get the following notices on the statistics page:

Notice: Undefined index: incr_hits in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: incr_misses in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_hits in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_misses in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: incr_hits in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: incr_misses in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_hits in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_misses in _memcache_admin_stats_counters() (line 168 of /var/www/dev/drupal/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

millwardesque’s picture

I'm seeing this in PHP 5.2.11 as well.

christowm’s picture

Version: 7.x-1.x-dev » 6.x-1.9

Hi folks,

I am getting the same error. Here are my environment stats:
Ubuntu Linux 10.04
memcached 1.0.2
Pressflow 6.22
Memcached package 1.4.5-1ubuntu2
Memcache Module 6.x-1.9

The error message that I get when I access the memcache report is:

Notice: Undefined index: incr_hits in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: incr_misses in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_hits in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_misses in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: incr_hits in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: incr_misses in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_hits in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).
Notice: Undefined index: decr_misses in _memcache_admin_stats_counters() (line 160 of /home/quickstart/websites/demo.dev/sites/all/modules/memcache/memcache_admin/memcache_admin.module).

Hopefully someone can figure out why this is happening.

Cheers,
Mitch

tonylegrone’s picture

I have this problem in d7 as well. I've only been learning about memcached for the last 5 days. So I'm not sure how to truly fix the problem at the source, but I did alter the function to stop the notices.

function _memcache_admin_stats_counters($stats) {
  
  $stats['incr_hits'] = (isset($stats['incr_hits']))? $stats['incr_hits']:0;
  $stats['incr_misses'] = (isset($stats['incr_misses']))? $stats['incr_misses']:0;
  $stats['decr_hits'] = (isset($stats['decr_hits']))? $stats['decr_hits']:0;
  $stats['decr_misses'] = (isset($stats['decr_misses']))? $stats['decr_misses']:0;
  
  return t('!incr increments, !decr decrements',
    array(
      '!incr' => number_format($stats['incr_hits'] + $stats['incr_misses']),
      '!decr' => number_format($stats['decr_hits'] + $stats['decr_misses'])
    )
  );
}

That takes care of the notices, but it doesn't solve the problem that the indexes are undefined in the first place.

Robin Millette’s picture

I had the same notices with php5-memcached (debian lenny package) but using the php5-memcache package fixed those warnings.

Can you confirm if you are using the memcache PECL or the memcached one?

tonylegrone’s picture

I had the notices while using PECL memcached 1.0.2 and php 5.3.6.

EdgarPE’s picture

Same, as comment #4.
The notices only appear with php5-memcached package (version 1.0.0). With php5-memcache package (v. 3.0.4) there is no problem.

Edit: Drupal memcache module version: 7.x-1.0

Konstantin Boyandin’s picture

Confirming the same problem, Drupal 7.12, PHP 5.3.10, the latest PECL memcached (2.0.1)
Sorry, wrong Drupal version - but it seems the problem has the same origin.

pgrond’s picture

Same for me PECL memcached (v1.0.2) and Drupal 7.13

brianV’s picture

Title: Undefined index notices » Undefined index notices on memcache stats page when using PECL memcached
Version: 6.x-1.9 » 7.x-1.x-dev
Priority: Minor » Normal

Marked #1517086: Undefined index notices on memcache stats page and #1558648: Undefined index notices, for v7.x-1.x-dev + Drupal 7.14 as dupes.

Manarth in http://drupal.org/node/1517086#comment-6365978 points out:

This error was introduced in commit 63bc6f2f52107b39fe6f300d46f39eea11b16068.

$stats is the output of a getStats/getExtendedStats call (via PECL's memcache/memcached extensions). Neither of these provide incr_hits/incr_misses/decr_hits/decr_misses data.

InternetDevels’s picture

Patch for notices fixing.

InternetDevels’s picture

Status: Active » Needs review

changed status

brianV’s picture

Status: Needs review » Needs work

Seems like a good patch; however, if the stats are not available, maybe a message should be set on the page indicating that the stats can not be fetched?

Without some kind of on-page documentation, users may sit there wondering why their memcache looks like it's not working at all!

InternetDevels’s picture

Status: Needs work » Needs review
FileSize
1.33 KB

Here is updated patch which informs user about statistic fetching may be disabled.

FluxSauce’s picture

Patch in #13 stated incorrect reason for the stats not showing; PECL Memcached getStats() doesn't support increment and decrement statistics as pointed out in #9. Additionally, the use of drupal_set_message was a bit extreme (FYI, the third option is repeat, so no need for the static).

Recreated patch to provide contextually appropriate information (if server is up and the stats are missing, assume PECL Memcached and show message) and adhered to Drupal coding standards.

Side note, memcache_admin.module has Windows line endings; that should be corrected at some point.

InternetDevels’s picture

Component: memcache_admin » Documentation

@FluxSauce

I agree with comment above. But your patch has a little mistake. In t() function "!incr" placeholder replaced incorrectly - $decrements variable is using instead of $increments.

InternetDevels’s picture

Here is patch fixing mistake above:

Sam Moore’s picture

Component: Documentation » memcache_admin

Thanks for the patch in #16.

This not only fixed the error message, but also cleared a bug whereby the statistics were appearing twice on a page, when the "Show Memcache Statistics" box was checked, and once when it wasn't (!).
Oddly none of this happened on one of my other sites, hosted on the same codebase...

FluxSauce’s picture

@InternetDevels.Com HAH, good catch. Teamwork!

FluxSauce’s picture

Status: Needs review » Reviewed & tested by the community

To maintainers: request dual commit credit with InternetDevels.Com on this fix.

brianV’s picture

+1 on this patch

Anonymous’s picture

Can please a maintainer push the patch to master? Thanks!

fgm’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1022 bytes

The current patch assumes that the lack of incr/decr implies use of PECL memcached, but this can also happen simply because the counters are really zero, not because this version of that extension is used and they have been set to 0 by the code.

How about removing this assumption and using a simpler patch ?

markpavlitski’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #22 works for both PECL extensions and seems like the most elegant solution.

fayedrupal’s picture

Thanks for the #22 patch it work for me :-)

Jeremy’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed #22 -- thanks!
http://drupalcode.org/project/memcache.git/commit/a878c95

Needs to be ported to 6.x.

Jeremy’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.