[wp-trac] [WordPress Trac] #58798: Fix possible PHP warning in /wp-includes/feed.php
WordPress Trac
noreply at wordpress.org
Fri Oct 11 21:30:47 UTC 2024
#58798: Fix possible PHP warning in /wp-includes/feed.php
--------------------------------------+------------------------------
Reporter: zahardoc | Owner: johnjamesjacoby
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.7
Component: Feeds | Version: 6.2.2
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Comment (by Rahmohn):
I've created a PR to fix this possible PHP warning. Also, I created some
tests for the function `rss_enclosure()`.
I noticed that the function `atom_enclosure()` doesn't need to be applied
the same fix because this function sets default values when the
`enclosure` meta field is not stored in a multiline string i.e. this
function checks if the keys exist before accessing them:
{{{#!php
<?php
// Parse URL.
if ( isset( $enclosure[0] ) && is_string( $enclosure[0] ) ) {
$url = trim( $enclosure[0] );
}
// Parse length and type.
for ( $i = 1; $i <= 2; $i++ ) {
if ( isset( $enclosure[ $i ] ) ) {
if ( is_numeric( $enclosure[ $i ] ) ) {
$length = trim( $enclosure[ $i ] );
} elseif ( in_array( $enclosure[ $i ], $mimes, true ) ) {
$type = trim( $enclosure[ $i ] );
}
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58798#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list