Map global variable receivers to their classes - #282
Open
sirreal wants to merge 2 commits into
Open
Conversation
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.
Method_Call_Reflector::_getClassMapping()maps well-known WordPress globals to their classes with keys like'wpdb', but the pretty-printed receiver it is matched against is'$wpdb'— the comment documenting the list's generation even shows thesed "s/\\$//g"stage that stripped the sigils. The$wp_globalshalf of the mapping has therefore never matched; the existing test pinned the fallout (class => '$wpdb'), evidently unintentionally. The$wp_functionshalf (get_current_screen()→WP_Screen) was unaffected.The keys now carry the
$sigil, so the mapping matches. This is a deliberate behavior change to exporteduses.methods[].classfor calls on these globals:$wp_the_query,$post,$authordata,$userdata,$wp_customize,$wp_hasher,$wp_json,$phpmailer,$custom_background,$custom_image_header— the exported class (and thus the method slug built from it) now points at the real method post. Those cross-links have been broken all along.$wpdb,$wp_query, …) only the exported string changes ($wpdb→wpdb); the link slug was already rescued bysanitize_title()dropping the$.The alternative — deleting the dead half — was considered and rejected: the mapping repairs real cross-links. A corpus regeneration diff will show class-name changes for these receivers; they are intended.
The updated
$wpdbexpectation and the new$wp_the_query→WP_Queryassertion fail on master and pass with the fix; the full suite passes.Found by the multi-agent review during #262; extracted as a standalone change.
🤖 Generated with Claude Code