From 74c8b7f2de34f435d958b7f9cf6ade0681aba1f3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 4 Aug 2022 17:31:45 +0000 Subject: [PATCH] Tests: Add more test cases for `WP_Object_Cache::is_valid_key()`. A valid cache key for `wp_cache_*()` functions must be either an integer number or a non-empty string. To avoid potential compatibility issues or key collisions, a string that becomes empty after `trim()` should not be considered a valid cache key. Follow-up to [53818], [53821], [53822]. Props tillkruess. See #56198. git-svn-id: https://develop.svn.wordpress.org/trunk@53834 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/cache.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/phpunit/tests/cache.php b/tests/phpunit/tests/cache.php index ca986d6d04..b6b7d62d62 100644 --- a/tests/phpunit/tests/cache.php +++ b/tests/phpunit/tests/cache.php @@ -61,7 +61,11 @@ class Tests_Cache extends WP_UnitTestCase { return array( array( false, false ), array( null, false ), + array( "\n", false ), + array( "\0", false ), array( '', false ), + array( ' ', false ), + array( ' ', false ), array( 0.0, false ), array( 0, true ), array( 1, true ),