Fix for error in WordPress rss feed module

WordPress Pumpkin

Image by Eric M Martin via Flickr

Using WordPress 2.7.1, there is a problem with the Atom feed export.

In the apache error log are many occurrences of these two lines:

Bad arguments. in /var/www/.../wp-includes/rss.php on line 175,
The first argument, 'map_attrs', should be either NULL or a valid callback

The problem appears to be a simple coding error: the callback function should be called as array reference, array(object, user_func).

This has been reported as issue #9225, read on if you want to fix it for yourself right away…

This patch solves the problem (against trunk, rev. 10641):

Index: rss.php
===================================================================
--- rss.php	(revision 10641)
+++ rss.php	(working copy)
@@ -170,7 +170,7 @@
 		{
 			// if tags are inlined, then flatten
 			$attrs_str = join(' ',
-					array_map('map_attrs',
+					array_map(array($this, 'map_attrs'),
 					array_keys($attrs),
 					array_values($attrs) ) );

In plain English: open file wp-includes/rss.php, find the line containing ‘map_attrs‘ and replace this string by array($this, ‘map_attrs’).

That’s all folks!

Reblog this post [with Zemanta]