Closed EvanShaw closed 4 years ago
Here are some ideas:
$license
is always correctly initialized, even when the code runs in an AJAX handler or outside the WP admin. If the code that loads the license key depends on is_admin()
or similar conditions, it could be a potential source of bugs.$license
isn't overwritten/unset somewhere.$license
variable has the expected value.
Something basic like error_log("License = " . $license)
could work.@YahnisElsts Thanks for the suggestions.
End-to-end testing like this is really difficult to debug so I decided to set up parallel client and server environments in Docker containers so I could use XDebug. It turned out to be an issue with our authentication handling on the server end. We verify the clients domain via HTTP_REFERER
but the way WordPress sets this in wp_remote_get
differs from how we set it in a different client library which uses vanilla cURL. This was causing our authentication API to reject the request.
In short, the bug was in our own code and not yours :+1: . I'll close this issue. Again, thanks for the help!
I'm using a custom implementation of wp-update-server in a plugin on my companies online store which uses the same technique for handling licenses as described in this blog post. If a customer does not have a license then the
download_url
will be omitted from the JSON result forget_metadata
.I've verified that the license handling logic is running as expected. When I paste the
get_metadata
URL with a valid license provided as a query argument in the browser the JSON displayed shows thedownload_url
. However, when I invokeCheck for updates
manually from the plugins page, thedownload_url
is missing and the following message is displayed in place of the download link:Automatic update is unavailable for this plugin.
As per the authors recommendation, I installed Debug Bar to narrow down the problem but nothing appears amiss. The
get_metadata
URL displayed in the debug panel is correct, but when I invokeRequest Info
thedownload_url
in the returned JSON is blank. If I copy the URL directly and paste it into the browser as I described above, thedownload_url
is present.My suspicion is that the URL which WordPress actually uses is not correct (ie. the license is not being added). Here is the PHP where I instantiate the update checker:
Any help would be greatly appreciated.