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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3232501-1.patch | 3.41 KB | mitrpaka |
Issue fork memcache-3232501
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
Comment #2
mitrpaka commented... and here is the patch file for the fixes.
Comment #3
mitrpaka commentedComment #5
it-cruAdded 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 decrementsdoesn't display anything. Maybe they could be removed from memcache stats?Tested with:
Comment #8
japerry