[wp-trac] [WordPress Trac] #62354: fetch_feed should use `get_bloginfo( 'charset' )` over `get_option( 'blog_charset' )` when setting the output encoding
WordPress Trac
noreply at wordpress.org
Thu Nov 7 09:42:08 UTC 2024
#62354: fetch_feed should use `get_bloginfo( 'charset' )` over `get_option(
'blog_charset' )` when setting the output encoding
--------------------------+-----------------------------
Reporter: david.binda | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Feeds | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Testing the SimplePie 1.8.0 which is part of the upcoming WordPress 6.7
release, I've run into some fatal errors on blogs which have the
`blog_charset` option empty:
```
Fatal error: Uncaught ValueError: mb_convert_encoding(): Argument #2
($to_encoding) must be a valid encoding, "" given in wp-
includes/SimplePie/src/Misc.php:344
```
It turns out that the `fetch_feed` function is setting the SimplePie's
output encoding by passing in the `get_option( 'blog_charset' )` (
[https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/feed.php?rev=59241#L845 related code] ) which might be empty in
some cases.
While I'm not sure how or why the option is empty, the `get_bloginfo(
'charset' )` accounts for such a case and outputs the default `UTF-8`
encoding in such case ( [https://core.trac.wordpress.org/browser/trunk/src
/wp-includes/general-template.php?rev=59010#L873 related code] ).
IMHO, the `fetch_feed` function should use the `get_bloginfo( 'charset' )`
over the unchecked option value.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62354>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list