[wp-trac] [WordPress Trac] #62236: Why do wp_cache_incr / wp_cache_decr not allow negative values?

WordPress Trac noreply at wordpress.org
Wed Oct 16 09:20:52 UTC 2024


#62236: Why do wp_cache_incr / wp_cache_decr not allow negative values?
-------------------------+------------------------------
 Reporter:  docjojo      |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Cache API    |     Version:  6.6.2
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by dd32):

 I believe this would be caused by it being modeled on one of the original
 object caches in use, Memcache.

 https://www.php.net/manual/en/memcached.decrement.php

 > Memcached::decrement() decrements a numeric item's value by the
 specified offset. If the item's value is not numeric, an error will
 result. **If the operation would decrease the value below 0, the new value
 will be 0.** Memcached::decrement() will set the item to the initial_value
 parameter if the key doesn't exist.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62236#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list