-
Notifications
You must be signed in to change notification settings - Fork 0
Announce a sub-plugin before its file is required #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+169
−16
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: stellarwp/plugin-absorber
Length of output: 50383
🏁 Script executed:
Repository: stellarwp/plugin-absorber
Length of output: 20326
🌐 Web query:
WordPress 6.4 class-wp-hook.php apply_filters exception cleanup wp_current_filter do_action source💡 Result:
The WordPress hook system, managed primarily via the
WP_Hookclass inwp-includes/class-wp-hook.phpand wrapper functions inwp-includes/plugin.php, maintains the state of active hooks using the global array$wp_current_filter[1][2][3]. In WordPress 6.4 and beyond, theapply_filtersanddo_actionmethods withinWP_Hookutilize anesting_levelandcurrent_prioritytracking mechanism to execute callbacks [4][5][6]. When a hook is triggered, theapply_filtersfunction inplugin.php(which is called by bothapply_filters()anddo_action()) handles the lifecycle of$wp_current_filter[7][2][8]: 1. Before execution, the hook name is pushed onto the$wp_current_filterstack [1][7][9]. 2.WP_Hook::apply_filters()is invoked to process the callbacks [4][7][3]. 3. After the callbacks have finished execution,array_pop()is called to remove the hook name from the stack [1][7][9]. Regarding exception handling and "cleanup," the WordPress core hook system does not natively wrap callback execution intry-catchblocks for individual plugins, meaning fatal errors or uncaught exceptions during a hook's execution can interrupt this process [10][11]. If an exception occurs, the code may terminate before the correspondingarray_pop()can run, potentially leaving the hook name in$wp_current_filter[1][10]. Furthermore, as of recent WordPress versions, it is documented thatcurrent_filter()andcurrent_action()can returnfalseif they are called when no hooks are active, such as during the early stages of the bootstrap process or within a custom exception handler [10]. Developers are advised that these functions returnstring|false, and relying on them inside global exception handlers requires verifying that a hook is actually currently active [10]. The internal use of_doing_it_wrong()and input validation has also been enhanced in recent versions to prevent fatalTypeErrorswhen invalid callables are passed to hooks [11].Citations:
🏁 Script executed:
Repository: stellarwp/plugin-absorber
Length of output: 2449
🏁 Script executed:
Repository: stellarwp/plugin-absorber
Length of output: 7631
🏁 Script executed:
Repository: stellarwp/plugin-absorber
Length of output: 3734
Preserve WordPress hook state when a loading listener throws.
When a
give/plugin_absorber/loadinglistener throws fromdo_action_ref_array(), WordPress 6.4 skipsWP_Hookcleanup and thewp_current_filterpop.load_all()then catches the exception and continues with the next sub-plugin. Later callbacks can observe stale loading state throughcurrent_filter()ordoing_action().Ensure the loading dispatch restores WordPress hook state before
load_all()handles the failure. Add a regression test that checks hook state after a throwing listener and then loads another sub-plugin.🤖 Prompt for AI Agents