[wp-trac] [WordPress Trac] #64323: fetch_rss() uses incorrect function signature for XML `start_element_handler`

WordPress Trac noreply at wordpress.org
Mon Dec 1 03:53:32 UTC 2025


#64323: fetch_rss() uses incorrect function signature for XML
`start_element_handler`
--------------------------+------------------------------
 Reporter:  avibrender    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Feeds         |     Version:  trunk
 Severity:  minor         |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by manhphucofficial):

 I’ve prepared a patch that removes the reference from `$attrs` in
 `feed_start_element()` to match the required handler signature for
 `xml_set_element_handler()`.

 PHP’s XML parser always passes the attributes array by value, and the
 official handler signature is:

 start_element_handler(XMLParser $parser, string $name, array $attributes):
 void

 Using `&$attrs` triggers this PHP 8+ warning:

 “Argument #3 ($attrs) must be passed by reference, value given”

 The function only normalizes `$attrs` internally and does not require a
 reference, so removing `&` is safe and keeps behavior unchanged.

 Before patch:
 - Warning is triggered every time `fetch_rss()` runs.

 After patch:
 - No warning, feed parsing remains correct.

 Patch attached. Thanks!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64323#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list