WordPress 3.4.1 and AJAX problems

Overnight another team member updated the main blogs to the newest version of WP, and subsequently some plugins we use failed to work correctly.

The plugins display a list of items which are retrieved via an API call to our main database. The plugins offer paging, and when writing these I chose for the AJAX call to be made to the same page, and for the plugin to call the external API, format the items, and just return a block of HTML to be displayed by JS.

When paging, the params passed included ‘page=’ which was working fine before the upgrade. But, eventually, the post-upgrade error was tracked down to the fact that this was being rewritten within WP.

Original HTTP call returned with 301:
http://www.example.com/my-plugin-page?sortby=date&page=2

Redirected to:
http://www.example.com/2/my-plugin-page?sortby=date

The plugin code expects to see a $_GET[‘page’] which was no longer there, paging failed, and page 1 was always displayed no matter which page was being viewed.

In this case, it was easy to rename the ‘page’ param something that wasn’t going to conflict with the rewriting done within WP, but this was an unexpected bug to come up so I thought I’d document it here.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>