Make WordPress Core

Changeset 55581


Ignore:
Timestamp:
03/22/2023 09:25:32 AM (13 months ago)
Author:
SergeyBiryukov
Message:

Tests: Consistently sanitize expiration in the test suite's Memcached implementation.

In a previous commit, the ::sanitize_expiration() call in the ::add() method was moved closer to where the value is used.

This commit does the same for the other methods:

  • ::cas()
  • ::replace()
  • ::set()
  • ::setMulti()

Follow-up to [40561], [55577].

See #57841, #57963.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/object-cache.php

    r55577 r55581  
    11821182    public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    11831183        $derived_key = $this->buildKey( $key, $group );
    1184         $expiration  = $this->sanitize_expiration( $expiration );
    11851184
    11861185        /**
     
    11931192            return true;
    11941193        }
     1194
     1195        $expiration = $this->sanitize_expiration( $expiration );
    11951196
    11961197        // Save to Memcached.
     
    19071908    public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    19081909        $derived_key = $this->buildKey( $key, $group );
    1909         $expiration  = $this->sanitize_expiration( $expiration );
    19101910
    19111911        // If group is a non-Memcached group, save to runtime cache, not Memcached.
     
    19201920            return true;
    19211921        }
     1922
     1923        $expiration = $this->sanitize_expiration( $expiration );
    19221924
    19231925        // Save to Memcached.
     
    19721974    public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    19731975        $derived_key = $this->buildKey( $key, $group );
    1974         $expiration  = $this->sanitize_expiration( $expiration );
    19751976
    19761977        // If group is a non-Memcached group, save to runtime cache, not Memcached.
     
    19791980            return true;
    19801981        }
     1982
     1983        $expiration = $this->sanitize_expiration( $expiration );
    19811984
    19821985        // Save to Memcached.
     
    20342037        // Build final keys and replace $items keys with the new keys.
    20352038        $derived_keys  = $this->buildKeys( array_keys( $items ), $groups );
    2036         $expiration    = $this->sanitize_expiration( $expiration );
    20372039        $derived_items = array_combine( $derived_keys, $items );
    20382040
     
    20492051            }
    20502052        }
     2053
     2054        $expiration = $this->sanitize_expiration( $expiration );
    20512055
    20522056        // Save to memcached.
Note: See TracChangeset for help on using the changeset viewer.