fix(object-cache): ensure wp_cache_delete returns boolean - #1028
Open
faisalahammad wants to merge 1 commit into
Open
fix(object-cache): ensure wp_cache_delete returns boolean#1028faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Collaborator
|
Please use |
faisalahammad
force-pushed
the
fix/924-wp-cache-delete-return-bool
branch
from
August 7, 2026 14:49
88a3c40 to
2bfd528
Compare
Contributor
Author
|
Rebased branch onto dev and updated target base to dev branch. |
faisalahammad
force-pushed
the
fix/924-wp-cache-delete-return-bool
branch
from
August 7, 2026 15:18
2bfd528 to
77d4d31
Compare
- Add is_object check for global object cache in wp_cache_delete - Explicitly cast delete return values to boolean in WP_Object_Cache and wp_cache_delete - Add local group tracking for global and non-persistent groups Fixes litespeedtech#924
faisalahammad
force-pushed
the
fix/924-wp-cache-delete-return-bool
branch
from
August 7, 2026 15:24
77d4d31 to
efe1036
Compare
Contributor
Author
|
Resolved conflicts. PR is now clean against dev branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Guarantees that
wp_cache_delete()andWP_Object_Cache::delete()strictly return a boolean (trueorfalse) rather thannull. This prevents PHPTypeErrorfatal exceptions in PHP 8.x when standard object cache functions are called.Fixes #924
Changes
Object Cache (
src/object.lib.php&src/object-cache-wp.cls.php)Before:
After:
Why: Directly returning the object cache method call could return
nullif the instance was uninitialized or returned non-boolean values. Adding anis_object()check and explicit(bool)typecast guarantees a boolean return value.WP Object Cache Class (
src/object-cache-wp.cls.php)Before:
After:
Why: Ensures deletion from runtime memory is returned for non-persistent groups or missing instances, and persistent store deletion output is explicitly cast to
bool.Testing
Test 1: Delete cache key
wp_cache_delete( 'test_key', 'default' ).false(ortrueif item exists) and nevernull.Test 2: Delete cache key with uninitialized object cache
$wp_object_cache = nulland invokewp_cache_delete( 'test_key' ).falsewithout throwing PHPTypeError.