WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#33241 closed enhancement (duplicate)

wp_get_http should stream directly to the file

Reported by: rmccue Owned by: rmccue
Milestone: Priority: normal
Severity: normal Version:
Component: HTTP API Keywords: has-patch
Focuses: Cc:
PR Number:

Description

Right now, wp_get_http does a regular HTTP request via WP_Http, then saves out to a file. This necessitates loading the entire file into memory, then saving it out, which can massively increase the memory usage. This is important in imports (the only place I can see where the function is used).

Instead, we should use WP_Http's native file streaming functionality, which pushes the bytes into the file as we go, rather than loading into memory.

In addition, I'd propose we deprecate wp_get_http, and anything using it (notably WordPress Importer) should use the normal HTTP functions.

Attachments (1)

33241.diff (1.6 KB) - added by rmccue 4 years ago.
Use direct file streaming, and deprecate the function

Download all attachments as: .zip

Change History (5)

#1 @rmccue
4 years ago

Also:

  • The function calls set_time_limit (#21521)
  • The function manually handles redirection for HEAD requests, noting "WP_HTTP no longer follows redirects for HEAD requests", but that's not actually true. WP_Http simply changes the *default* to 0 for HEAD requests, but the redirection setting still applies. (I suspect this was changed, but wp_get_http wasn't kept up-to-date)

@rmccue
4 years ago

Use direct file streaming, and deprecate the function

#2 @rmccue
4 years ago

  • Keywords has-patch added
  • Owner set to rmccue
  • Status changed from new to assigned

Added patch, including a deprecated message.

This ticket was mentioned in Slack in #core by rmccue. View the logs.


4 years ago

#4 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #33709.

Note: See TracTickets for help on using tickets.