-
Notifications
You must be signed in to change notification settings - Fork 413
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
Tweak - Allow Allow 3rd parties to suppress the "invalid meta" PHP notice #347
Comments
Could you elaborate on this? Do you mean that many plugin and theme developers expect their update server to return valid JSON that is missing certain entries, and they've designed their code to handle that case? This seems unlikely to me. |
I worked on at least two projects where the call to the update endpoint returns a JSON without that information, because it's used for premium products. If a valid licence is not found, the JSON is valid, but it doesn't contain any plugin meta. That's different from the update server example, which always return the plugin meta, but removes the download URL. In other words, the call to "get latest version" may return a response that is valid in such context, but doesn't contain the expected meta. That condition is handled gracefully, therefore there is no need to raise a notice in that case. In addition to that, both the client and the server plugins I worked on use their own logging system, instead of relying on the |
If the server response doesn't contain any plugin meta, it doesn't seem like a valid update API response even if it contains syntactically valid JSON. Could you perhaps make it return an error instead, like a The update checker already contains some code to handle non-200 responses and that seems like a better place to deal with this issue than the metadata class. |
In this specific case, that might not be that easy. An "invalid licence" is returned with a response code of 200, because it's considered a successful request. It all works fine, the only issue is that PHP notice, which is unnecessary to anyone except the developers. In any case, I will propose the change on the response header, maybe it will work too. In general, the PHP notice is useful for debugging, and it's only shown when the |
I wouldn't be opposed to the idea of adding a "debug mode" filter. The update checker already has something similar in the form of the Still, I think this kind of thing should happen in the update checker class, not in the metadata parser. Maybe the parser could call the |
Currently, class
Puc_v4p9_Metadata
raises a PHP notice when the response from the update server doesn't contain what the client library expects, such as thename
andversion
entries. This notice can be superfluous, as in many cases there's already an error handling system in place to deal with this condition.The notice is automatically hidden when the
WP_DEBUG
constant is not defined, but many live sites keep that notice on, causing the notice to appear in log files or to be shown to visitors. Adding a filter to allow 3rd parties to explicitly suppress the notice will allow to hide that notice as needed.The text was updated successfully, but these errors were encountered: