Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#49209 closed defect (bug) (worksforme)

Site health issue due to issues in processing wp_remote_retrieve_body

Reported by: aparnascodex's profile aparnascodex Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Site Health Keywords:
Focuses: Cc:


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)

#1 follow-up: @aparnascodex
4 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

I was able to trace the issue. This was due to space before <?php tag in one of the plugin file

#2 @swissspidy
4 years ago

  • Focuses performance removed
  • Keywords needs-patch needs-unit-tests removed
  • Milestone Awaiting Review deleted

#3 @SergeyBiryukov
4 years ago

  • Component changed from REST API to Site Health
  • Focuses rest-api removed

#4 in reply to: ↑ 1 @pwatras
4 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.

Note: See TracTickets for help on using tickets.