Draft
Conversation
Persistent object caches (Redis, Memcached) can deserialize null values as empty string during serialization round-trip. Since calculate_grade() legitimately returns null for posts with no gradable content, this null gets cached and later retrieved as ''. The existing check `false === $grade` does not match '', so the empty string is treated as a valid cached grade. It then bypasses the is_null() conversion to "N/A" in LLMS_Student::get_grade() and propagates to rendering code as 0%. Normalizes '' to false in get_grade_from_cache() so the standard cache-miss logic triggers recalculation. Made-with: Cursor
When a quiz attempt ends, only the usermeta overall_grade was cleared. The wp_cache entries for the quiz, lesson, and course grades were left intact. On sites with persistent object caches (Redis, Memcached), these stale entries persisted across requests, preventing recalculation of grades after quiz completion. Adds wp_cache_delete calls for the quiz, lesson, and parent course grade cache keys in the student's cache group. Made-with: Cursor
Persistent object caches (Redis, Memcached) can deserialize null as empty string. Both get_enrollment_date() and get_enrollment_status() cache null values from $wpdb->get_var() and check for false === to detect cache misses. While these methods happen to produce correct results due to downstream truthiness checks, the stale empty string prevents cache self-healing. Adding '' === checks ensures a fresh DB query runs when a corrupted null is encountered. Made-with: Cursor
Tests that get_grade() correctly handles cache values that may be corrupted by Redis/Memcached serialization round-trips: - Empty string in cache (deserialized null) triggers recalculation - Numeric grade in cache is returned as-is - Null in cache is treated as a valid "no grade" hit Made-with: Cursor
…m element has no override.
Contributor
Author
|
Need to test and verify this doesn't create a marked increase in attempts to re-try the grade calculation early. |
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.
Description
Handling of empty string cached values when determining if a cached value should be re-calculated, for grades
Fixes #3116
How has this been tested?
Manually
Checklist: