Skip to content

fix(attachment): suppress core IRI deprecation on external image requests - #230

Merged
bordoni merged 1 commit into
mainfrom
fix/188-iri-deprecation-safe-remote-get
Jul 16, 2026
Merged

fix(attachment): suppress core IRI deprecation on external image requests#230
bordoni merged 1 commit into
mainfrom
fix/188-iri-deprecation-safe-remote-get

Conversation

@bordoni

@bordoni bordoni commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Fixes #188

Problem

With WP_DEBUG_LOG on, generating attachments (especially with Lorem Picsum) floods debug.log with:

PHP Deprecated: Using null as an array offset is deprecated, use an empty string instead in /wp-includes/Requests/src/Iri.php on lines 672, 675, ...

Root cause

A WordPress core bug in Requests/src/Iri.php::scheme_normalization() uses a null $scheme as an array offset. It is triggered by the HTTP requests FakerPress makes to external image services while parsing their URLs.

Fix

Since core files cannot be modified, the Attachment module now routes its external requests through helpers that temporarily disable E_DEPRECATED and always restore the previous level:

  • without_iri_deprecations( callable ) — clears E_DEPRECATED, runs the callback, restores the level in finally.
  • safe_remote_get( $url, $args )esc_url_raw() + the wrapper around wp_remote_get().

Applied to download_url() and the Lorem Picsum metadata request.

Tests

AttachmentRemoteTest: E_DEPRECATED is disabled inside the callback and restored after (including when the callback throws), and safe_remote_get() still performs the request (mocked via pre_http_request).

Milestone: 0.9.2

…ests

Generating attachments logged repeated PHP 8.1+ 'Using null as an array
offset is deprecated' notices from WordPress core's Requests/src/Iri.php while
parsing the URLs FakerPress fetches from picsum.photos / placehold.co. Add
without_iri_deprecations() (clears E_DEPRECATED, restored in finally) and a
safe_remote_get() wrapper, and route download_url() and the Lorem Picsum
metadata request through them. Adds regression coverage for the suppression
and restoration behaviour.

Fixes #188
@bordoni bordoni added this to the 0.9.2 milestone Jul 16, 2026
@bordoni
bordoni merged commit 69e2480 into main Jul 16, 2026
3 of 5 checks passed
@bordoni
bordoni deleted the fix/188-iri-deprecation-safe-remote-get branch July 16, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP 8.1+ Deprecated Warnings: Using null as an array offset in WordPress Requests/Iri.php when generating Attachments

1 participant