Problem/Motivation

Noticed that some of the statistics are not shown correctly in Memcache Statistics page, e.g.
- Gets
- Transferred
- Per-connection average

Reason for that seems to be slight misinterpretation of syntax when stats lines in code using ternary operator were changed to use new null coalescing operator (PHP7), i.e.

$hits = isset($this->stats['get_hits']) ? $this->stats['get_hits'] : 0;
was changed to
$hits = isset($this->stats['get_hits']) ?? 0;
which will result either 1 or 0.

Intended / correct change would be:
$hits = $this->stats['get_hits'] ?? 0;

that is identical to this if/else statement

if (isset($this->stats['get_hits'])) {
  $hits = $this->stats['get_hits'];
} else {
  $hits = 0;
}

Steps to reproduce

- Install memcache
- Install memcache_admin
- Visit in Memcache Statistics page

Proposed resolution

Fix stats lines syntax having null coalescing operator

CommentFileSizeAuthor
#2 3232501-1.patch3.41 KBmitrpaka

Issue fork memcache-3232501

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mitrpaka created an issue. See original summary.

mitrpaka’s picture

Status: Active » Needs review
StatusFileSize
new3.41 KB

... and here is the patch file for the fixes.

mitrpaka’s picture

it-cru’s picture

Status: Needs review » Reviewed & tested by the community

Added code from MR as a patch to my smaller projects and it solves this issue that memcache stats are now working again.

Only the Counters: 0 increments, 0 decrements doesn't display anything. Maybe they could be removed from memcache stats?

Tested with:

  • Memcache: v1.6.9
  • PECL Driver in Use: Memcached v3.1.5

japerry made their first commit to this issue’s fork.

  • japerry committed 8323327 on 8.x-2.x authored by mitrpaka
    Issue #3232501 by mitrpaka: Memcache Admin - Some of the statistics not...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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