Need a little help with extends Wpup_UpdateServer
Closed this issue · 5 comments
Hi, i need some help, if you please.
Using wp-update-server 2.0.1 to update themes,
the update should be done only if there is a license key.
I send the key (theme_key) with wsh_filter_update_checks,
The request is sent ok from the theme
https://site1.name/update/
?action=get_metadata
&slug=theme-name
&installed_version=1.0.0
&php=8.2.8
&theme_key=123456789
200 OK
In the wp-update-server logs also is fine, the request has been received,
get_metadata theme-name 1.0.0 6.2.2 https://site2.name action=get_metadata&slug=theme-name&installed_version=1.0.0&php=8.2.8&theme_key=123456789
...
But in the test
https://site1.name/update/?action=get_metadata&slug=theme-name
license_status returns as invalid
"license_status": "License invalid",
and the theme can't be updated.
The theme's zip with the new version has been uploaded as well.
I don't understand what I did wrong. Missed something at checkLicense class?
I don't see anything wrong with the filterMetadata()
method. In the checkAuthorization()
method, you're looking for a data
parameter instead of theme_key
, which is probably unintended, but this should not affect the contents of the license_status
field.
But in the test
https://site1.name/update/?action=get_metadata&slug=theme-name
license_status returns as invalid
That test URL doesn't seem to contain a theme_key
parameter. If you omitted the parameter, "License invalid" would be the expected result, right?
Hi!
Sorry for inaccuracy with data, it's because of the replacement of real properties before asking. I've changed this parametr.
If test with all bunch like
instead of
https://site1.name/update/?action=get_metadata&slug=theme-name
yes, it shows correct:
"download_url": "https:\/\/site1.name\/update\/?action=download&slug=theme-name",
"license_status": "License valid",
But attempt to update still gives an error:
Downloading update from https://site1.name/update/?action=download&slug=theme-name…
An error occurred while updating Alba Longa: Download failed. Forbidden
May be an update url in the theme must contain some absence parameters?
$themeUpdateChecker = YahnisElsts\PluginUpdateChecker\v5\PucFactory::buildUpdateChecker(
$this->api_update_url,
get_template_directory() . '/functions.php',
$this->slug,
12,
);
where $this->api_update_url is https://site1.name/update/?action=get_metadata&slug=theme-name ?
This could be because the download URL doesn't include the license key. You could add it in the plugin, or you could extend filterMetadata()
and add the key to $meta['download_url']
.
Also, I noticed that the code in checkAuthorization()
doesn't seem to do anything with $message
after setting it. Did you omit $this->exitWithError($message, 403)
?
Well, the key has been added in wsh_filter_update_checks
It's already a part of the request and it can be seen in the log.
But I added $meta['download_url'] into filterMetadata, and it works. Thank you very much!
Nnow i've got a new issue
Update failed: The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature
But obviously it's not related to the wp-update-server , and I can handle it.
Thank you for help!
All right, I'll close this issue then.
And in case it helps, PCLZIP_ERR_BAD_FORMAT usually means that the ZIP file is invalid, so make sure you're not sending some extra data in the "download" response, like some PHP output.