#49209 closed defect (bug) (worksforme)
Site health issue due to issues in processing wp_remote_retrieve_body
Reported by: | aparnascodex | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Site Health | Keywords: | |
Focuses: | Cc: |
Description
I have activated one plugin on my site which results in 'Background updates are not working as expected'.
I found that, the code to validate the http response is not working as expected.
if ( 'yes' !== $response) then show warning. (file class-wp-site-health-auto-updates.php)
On debugging the issue, I found that the function wp_remote_retrieve_body is returning 'yes' as response. But, I guess some space is returning with response because of which the above condition is failing. If I change the condition to if ( 'yes' !== trim($response)), then it works fine.
Change History (4)
#2
@
5 years ago
- Focuses performance removed
- Keywords needs-patch needs-unit-tests removed
- Milestone Awaiting Review deleted
#4
in reply to:
↑ 1
@
5 years ago
Replying to aparnascodex:
I was able to trace the issue. This was due to space before <?php tag in one of the plugin file
I was initially going to suggest that changing the condition from 'yes' !== $response
to 'yes' !== trim($response)
does not seem like a good idea because instead of trimming/processing the $response content, the original problem should be solved - that is the remote service should return a proper response. While additional space is not a problem in itself, it could be an indicator that something wrong is going on. This way, by forcing the response to be strictly correct, you push the developer for finding the root cause of the problem.
And all this indeed happened. The problem was elsewhere and you successfully located the root cause.
I was able to trace the issue. This was due to space before <?php tag in one of the plugin file