Repository navigation
Resolve ping details at ping time rather than relying on init - #21
Merged
Merged
Conversation
Activating a plugin includes its file and fires activate_{file} after
`init` has already passed, so the callback registered in the Integration
constructor never runs. Tracker::product_activated() then pinged with
admin_email and admin_name empty, and the server wrote those blanks over
the stored contact details.
product_version escaped only by accident: product_activated() calls
clear_updates_transient() first, which fires the update_plugins transient
filter and backfills the version from $transient->checked.
- Add Integration::prepare_product_data(), filling only what is missing
unless forced, so the normal ping path does no extra work
- Updater::init() delegates to it with $force, keeping today's behaviour
- Client::ping() calls it, making the payload complete whatever the hook
timing
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
admin_emailandadmin_nameare resolved inUpdater::init(), hooked toinit. The request that activates a plugin includes the plugin file and firesactivate_{file}afterinithas already passed — so theadd_action( 'init', … )registered in the constructor during that include is too late to ever run, andTracker::product_activated()pings with the constructor defaults of''.Observed in the wild, two pings six seconds apart from the same site:
Deactivation is unaffected — the plugin loaded normally at
plugins_loadedin that request, soinitran.product_versionsurvives only by accident:product_activated()callsclear_updates_transient()before pinging, which sets theupdate_pluginstransient, firespre_set_site_transient_update_plugins, and backfills the version from$transient->checked[…](Updater.php:106). That middleupdatesrequest is that path firing. The admin fields have no equivalent fallback.Change
Integration::prepare_product_data( $force = false )resolves version, name, admin email and admin name. Without$forceit fills only what is missing, so the normal ping path costs a fewempty()checks and nothing more.Updater::init()delegates to it with$force = true— byte-for-byte today's behaviour on theinitpath.Client::ping()calls it, so a ping is self-sufficient whatever the hook timing.wp-admin/includes/plugin.phpinclude is now guarded byfunction_exists( 'get_plugin_data' )instead of running unconditionally.shazzad-plugin-repoPR #50 is the server-side half: it stops writing empty admin fields over stored ones, which protects already-deployed clients that will not pick this library up for a while.Test plan
ping_resolves_details_when_init_has_not_run— with all four fields blanked, ping reports the resolved version, admin email and admin nameping_does_not_re_resolve_details_already_set— assertsget_plugin_dataandget_usersare never called when values are present'2.5.0.5-feed'vs'') and passes with the changephpcsnet-zero: the two new hits inIntegrationare theget_users()array's existing sniff warnings, moved out ofUpdater(16→14). Total across the three files is 42 before and afterNote
Both this and #20 add a
1.4.0heading toCHANGELOG.md, so merging both will conflict there — trivial to resolve by combining the bullets under one heading.🤖 Generated with Claude Code