[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 14:48:02 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:  6.7.1
Component:  Feeds         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------
Changes (by sabernhardt):

 * milestone:  Awaiting Review => 6.7.1


Old description:

> 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.

New description:

 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&marks=845#L845 related code in fetch_feed] )
 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&marks=873-875#L873 related
 code in get_bloginfo] ).

 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#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list