[wp-trac] [WordPress Trac] #64784: Refactor: Remove unnecessary false check in oEmbed data fetching
WordPress Trac
noreply at wordpress.org
Tue Mar 3 15:58:46 UTC 2026
#64784: Refactor: Remove unnecessary false check in oEmbed data fetching
------------------------------+---------------------
Reporter: Soean | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 7.0
Component: Embeds | Version:
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses:
------------------------------+---------------------
Comment (by sajib1223):
== Patch Testing Report
Patch tested: https://core.trac.wordpress.org/raw-
attachment/ticket/64784/64784.diff
=== Environment
- WordPress: 7.0-beta2-20260303.130610
- PHP: 7.4.33
- Server: PHP.wasm
- Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
- Browser: Firefox 148.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.4
- MU Plugins: None activated
- Plugins:
* Test Reports 1.2.1
=== Steps taken
- Created an mu-plugin (`wp-content/mu-plugins/test-oembed-get-data.php`)
to directly call `WP_oEmbed::get_data()` and inspect the return values
before and after applying the patch.
{{{#!php
<?php
add_action( 'admin_init', function () {
if ( ! isset( $_GET['test-oembed'] ) ) {
return;
}
$oembed = _wp_oembed_get_object();
// Test 1: Valid oEmbed URL.
$valid = $oembed->get_data(
'https://www.youtube.com/watch?v=dQw4w9WgXcQ' );
// Test 2: Invalid / non-embeddable URL.
$invalid = $oembed->get_data( 'https://example.com/not-embeddable' );
echo '<h2>oEmbed get_data() Test</h2>';
echo '<h3>Test 1 – Valid URL (YouTube)</h3>';
echo '<pre>';
var_dump( $valid );
echo '</pre>';
echo '<h3>Test 2 – Invalid URL</h3>';
echo '<pre>';
var_dump( $invalid );
echo '</pre>';
exit;
});
}}}
- Visited `wp-admin/?test-oembed=1` **before** the patch and recorded the
output.
- Applied the patch.
- Visited `wp-admin/?test-oembed=1` **after** the patch and compared.
=== Expected outcome
- ✅ The patch should keep the return data unchanged.
- ✅ Valid oEmbed URL returns an object with embed data (type, title,
html, etc.) — identical before and after.
- ✅ Invalid URL returns `bool(false)` — identical before and after.
- ✅ No PHP notices, warnings, or errors introduced.
=== Additional Notes
- This patch is a code simplification only. The removed intermediate
variable `$data` and the `false === $data` check were redundant since
`$this->fetch()` already returns `false` on failure. Returning its result
directly is functionally identical.
- Networking must be available for the valid URL test to succeed (oEmbed
fetches an external provider).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64784#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list