Recent-links bug

There’s a small bug in Rebelpixel’s recent-links plug-in: clicking the monthly archive pages always appeared to return all the recent links, instead of the (selected) month/year. A quick look in the code tells me that it goes wrong between line 572 and 580 in the file rp_plugin_recent_links.php:


if (strlen(get_settings('permalink_structure')) > 0) {
$y = strval($_GET['y']);
$m = strval($_GET['m']);
} else {
$y = strval(substr($_GET['m'], 0, 4));
if (strlen($_GET['m']) > 4) {
$m = strval(substr($_GET['m'], 4, 2));
}
}

You may have noticed that I’m not a great fan of ‘clean permalinks’ (I have it turned off), which means that you can skip the True branch of the If condition. Obviously, there’s something not right in the ‘False’ branch. First of all, the $y variable gets the value of the $m variable. Second, there’s an extra IF condition to verify if the length of $m is greater than 4.

I presume that the function originally accepted values like ‘200601’ (for January of 2006) and that the programmer then decided to separate the GETs for month and year. The solution (when browsing through the code and confirming this behaviour) is simple: delete the whole if condition and replace it with:


$y = strip_tags($_GET['y']);
$m = strip_tags($_GET['m']);

Monthly Archives should work now.

I also readded the feed for the recent-links stuff: there’s something weird going on with the feed though. It doesn’t appear to be well-formed.

Update: There: that should do it

This entry was posted in Wordpress. Bookmark the permalink.