Technosailor.com Readers! Donate today to assist the Partners in Health Haiti Relief in their efforts.

26 February 2006 83 Comments

WordPress 2.0.1 Posting Bug

I’ve squashed a bug in WordPress 2.0.1 that has been preventing our bloggers from posting reliably. The write up on the fix is as follows:

For the handful of you that are running WordPress 2.0.1, there is a bug that is causing bloggers to not be able to post. I’ve done some research and squashed the bug and have submitted it to the WordPress core for inclusion there. For us, I’ll be deploying the patch to ONLY WP 2.0.1 blogs in the next day or so.

How do I know If I am affected by the bug?
The bug only applies to WordPress 2.0.1 users. You can find out what version of WordPress you are on by logging into wp-admin and looking at the footer. If it says 2.0.1, 2.0.1 rc1 or 2.0.1 rc2, then this affects you.

Symptoms of Bug
Bloggers on WordPress 2.0.1 have reported experiencing problems when they submit posts where WordPress redirects to a 404 Page Not Found or directs to the blog itself. Normal behavior from the post screen is to hit publish and be redirected after the publish back to the Manage page. The problem is detailed further in WordPress Trac Ticket #2498 and on the WordPress Support Forum.

Technical Patch Details
There is a line in

1
wp-includes/functions.php

which tests for the existence of a $posts array. Typically, the

1
$posts

array contains all details about a post entry such as ID, post_author, post_title, etc. If the

1
$posts

array exists, WordPress continues to assume certain things – namely, that all relevant data regarding an entry is available to the function and proceeds to try to create a list of IDs from the

1
$posts

array (which contains all the relevant posts in one array, not just one.

Unfortunately, in the context that

1
$posts

is called (from within the edit screen in wp-admin, there is very little available regarding a post prior to publishing. It is not saved with a title, URL, timestamp, etc. All it has really is a date. So when

1
$posts

is passed to this function in this context there is not enough information for the rest of the function to use. The essential data that is needed by the rest of the function is a list of the post IDs in the

1
$posts

array. It does not have this information, so it cannot construct a list which is needed for a database query. This causes the database query to fail and the error appears in the value of hidden form field “referredby” on the edit screen.

On publish, WordPress looks to find out if there is a hidden “referredby” field and if one exists, will redirect to that page.. Quite a complicated little problem.

My patch solves this problem by testing for the existence of post IDs as well as posts themselves. If there is post data but no post ID, the function will now skip over this feature and keep going causing posting to function as normal.

Whew!
If you run 2.0.1 and you’re interested to see the bug in action, follow these steps:

1. Login to WordPress wp-admin
2. Write a post
3. Save and Continue Editing (this runs a function in PHP which calculates the referredby field – which errors – which causes problems later)
4. View Source on the new page. You should see a bit like this down the page a ways:

1
<input name="referredby" type="hidden" id="referredby" value="
id='error'>

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY post_id, meta_key' at line 1]

1
2
SELECT post_id, meta_key, meta_value FROM wp2_postmeta
WHERE post_id IN() ORDER BY post_id, meta_key

Manual Fix
For those running WP 2.0.1 blogs that want to get this fixed, edit line 1403 of wp-includes/functions from:

1
if( !$posts )

to

1
if( !$posts || !$posts[0]->ID )

Or ask me to do it. I don’t charge much. ;)

Pick up your copy of the WordPress Bible, a wildly popular resource for beginners and experts alike.

Popularity: 1% [?]

Tags: ,

83 Responses to “WordPress 2.0.1 Posting Bug”

  1. Nimrod 14 March 2006 at 2:30 pm #

    [Comment ID #4698 Will Be Quoted Here]

    No, I don’t think so. I do have PHP Markdown installed. But since the words ‘curl’ is usually found in <code> or <pre> markup on my post, I was not able to use Markdown to format text with ‘curl’ in them. Markdown would use HTML entities for anything that is formatted as code (indented by 4 spaces). So I had to resort to using HTML tags.

  2. Nimrod 14 March 2006 at 2:30 pm #

    [Comment ID #4698 Will Be Quoted Here]

    No, I don’t think so. I do have PHP Markdown installed. But since the words ‘curl’ is usually found in <code> or <pre> markup on my post, I was not able to use Markdown to format text with ‘curl’ in them. Markdown would use HTML entities for anything that is formatted as code (indented by 4 spaces). So I had to resort to using HTML tags.

  3. Nimrod 14 March 2006 at 2:30 pm #

    [Comment ID #4698 Will Be Quoted Here]

    No, I don’t think so. I do have PHP Markdown installed. But since the words ‘curl’ is usually found in &lt;code&gt; or &lt;pre&gt; markup on my post, I was not able to use Markdown to format text with ‘curl’ in them. Markdown would use HTML entities for anything that is formatted as code (indented by 4 spaces). So I had to resort to using HTML tags.

  4. Nimrod 14 March 2006 at 2:30 pm #

    [Comment ID #4698 Will Be Quoted Here]

    No, I don’t think so. I do have PHP Markdown installed. But since the words ‘curl’ is usually found in &lt;code&gt; or &lt;pre&gt; markup on my post, I was not able to use Markdown to format text with ‘curl’ in them. Markdown would use HTML entities for anything that is formatted as code (indented by 4 spaces). So I had to resort to using HTML tags.

  5. Nimrod 14 March 2006 at 2:30 pm #

    [Comment ID #4698 Will Be Quoted Here]

    No, I don’t think so. I do have PHP Markdown installed. But since the words ‘curl’ is usually found in &lt;code&gt; or &lt;pre&gt; markup on my post, I was not able to use Markdown to format text with ‘curl’ in them. Markdown would use HTML entities for anything that is formatted as code (indented by 4 spaces). So I had to resort to using HTML tags.

  6. Stacie 15 March 2006 at 9:21 pm #

    Well, I finally did it and updated. Now, do I still do the second patch or will I mess something up? Everything is running great right now.

  7. Stacie 15 March 2006 at 9:21 pm #

    Well, I finally did it and updated. Now, do I still do the second patch or will I mess something up? Everything is running great right now.

  8. Stacie 15 March 2006 at 9:21 pm #

    Well, I finally did it and updated. Now, do I still do the second patch or will I mess something up? Everything is running great right now.

  9. Stacie 15 March 2006 at 9:21 pm #

    Well, I finally did it and updated. Now, do I still do the second patch or will I mess something up? Everything is running great right now.

  10. Stacie 15 March 2006 at 9:21 pm #

    Well, I finally did it and updated. Now, do I still do the second patch or will I mess something up? Everything is running great right now.

  11. Aaron 15 March 2006 at 9:36 pm #

    Which version are you running, Stacie?

  12. Aaron 15 March 2006 at 9:36 pm #

    Which version are you running, Stacie?

  13. Aaron 15 March 2006 at 9:36 pm #

    Which version are you running, Stacie?

  14. Aaron 15 March 2006 at 9:36 pm #

    Which version are you running, Stacie?

  15. Aaron 15 March 2006 at 9:36 pm #

    Which version are you running, Stacie?

  16. Minks 30 April 2006 at 12:56 am #

    I tried that on wp 2.02 and still face the same problem. Any other soloution

  17. Minks 30 April 2006 at 1:05 am #

    Finally, I found the problem. It’s the word that trigger the problem. So I changed it to plural or tense and the problem solved. This is crazy, because that sentence doesn’t make sense let alone is grammatically correct.

    I find this really ridculous, what is wrong with the word curl? Any significant issue to technical or program problem?

  18. Minks 30 April 2006 at 12:56 am #

    I tried that on wp 2.02 and still face the same problem. Any other soloution

  19. Minks 30 April 2006 at 12:56 am #

    I tried that on wp 2.02 and still face the same problem. Any other soloution

  20. Minks 30 April 2006 at 12:56 am #

    I tried that on wp 2.02 and still face the same problem. Any other soloution

  21. Minks 30 April 2006 at 12:56 am #

    I tried that on wp 2.02 and still face the same problem. Any other soloution

  22. Minks 30 April 2006 at 1:05 am #

    Finally, I found the problem. It’s the word that trigger the problem. So I changed it to plural or tense and the problem solved. This is crazy, because that sentence doesn’t make sense let alone is grammatically correct.

    I find this really ridculous, what is wrong with the word curl? Any significant issue to technical or program problem?

  23. Minks 30 April 2006 at 1:05 am #

    Finally, I found the problem. It’s the word that trigger the problem. So I changed it to plural or tense and the problem solved. This is crazy, because that sentence doesn’t make sense let alone is grammatically correct.

    I find this really ridculous, what is wrong with the word curl? Any significant issue to technical or program problem?

  24. Minks 30 April 2006 at 1:05 am #

    Finally, I found the problem. It’s the word that trigger the problem. So I changed it to plural or tense and the problem solved. This is crazy, because that sentence doesn’t make sense let alone is grammatically correct.

    I find this really ridculous, what is wrong with the word curl? Any significant issue to technical or program problem?

  25. Minks 30 April 2006 at 1:05 am #

    Finally, I found the problem. It’s the word that trigger the problem. So I changed it to plural or tense and the problem solved. This is crazy, because that sentence doesn’t make sense let alone is grammatically correct.

    I find this really ridculous, what is wrong with the word curl? Any significant issue to technical or program problem?

  26. Aaron Brazell 30 April 2006 at 10:54 pm #

    Are you running PHP exec or something? ‘curl‘ is a unix library for fetching/grokking URLs from the command line and PHP has wrapper functions around it.

  27. Aaron Brazell 30 April 2006 at 10:54 pm #

    Are you running PHP exec or something? ‘curl‘ is a unix library for fetching/grokking URLs from the command line and PHP has wrapper functions around it.

  28. Aaron Brazell 30 April 2006 at 10:54 pm #

    Are you running PHP exec or something? ‘curl‘ is a unix library for fetching/grokking URLs from the command line and PHP has wrapper functions around it.

  29. Aaron Brazell 30 April 2006 at 10:54 pm #

    Are you running PHP exec or something? ‘curl‘ is a unix library for fetching/grokking URLs from the command line and PHP has wrapper functions around it.

  30. Aaron Brazell 30 April 2006 at 10:54 pm #

    Are you running PHP exec or something? ‘curl‘ is a unix library for fetching/grokking URLs from the command line and PHP has wrapper functions around it.


Trackbacks/Pingbacks.

  1. Speed Linking - 27 Feb 2006: ProBlogger Blog Tips - 26. Feb, 2006

    [...] Aaron squashes a WordPress 2.0.1 Posting Bug [...]

  2. einfach persoenlich Sideblog - 27. Feb, 2006

    WordPress 2.0.1 Posting Bug…

    Auf technosailor wird ein Wordpress Posting Bug in Wordpress 2.01 und eine Lösung dafür beschrieben. Dieser Fehler tritt wohl nur bei der Version 2.01 auf. Wer eine solche Installation hat, sollte einmal darauf achten….

  3. Starboykb Blogger » Things I have done today… - 27. Feb, 2006

    [...] I found a interesting articles regarding the bug in Wordpress 2.0.1 listed by Problogger post. You can find fix solution from the link Here if you have problem using your Wordpress 2.0.1. Other than that, I found another great original themes that Brunet did not include. Check it out Here! [...]