Automattic / Automattic/wp-memcached

Key rotation does not work properly on 32-bit php

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
172
Forks
52
PR merge metrics
No merged PRs in 30d

Description

A bit of an edge case now, but `intval( microtime( true ) * 1e6 )` in `rotate_site_keys()` and `rotate_global_keys()` can overflow in 32-bit integers and the memcached daemon throws errors if the `Memcache::increment` method is called on a negative value.

Checking for `PHP_INT_SIZE == 4` and just using `time()` instead of `microtime()` is a quick fix.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate rotate_site_keys() and rotate_global_keys() in the plugin and inspect how microtime() is converted before Memcache::increment is called. Reproduce the 32-bit overflow case or review the PHP_INT_SIZE branch, then verify that key rotation no longer sends a negative value to memcached on 32-bit PHP.

Written by the indexing model from the issue text.

Assessment

Tech stack
memcached, php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.