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:
id='error'>
1 <input name="referredby" type="hidden" id="referredby" value="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% [?]



[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.
[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.
[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.
[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.
[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.
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.
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.
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.
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.
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.
Which version are you running, Stacie?
Which version are you running, Stacie?
Which version are you running, Stacie?
Which version are you running, Stacie?
Which version are you running, Stacie?
I tried that on wp 2.02 and still face the same problem. Any other soloution
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?
I tried that on wp 2.02 and still face the same problem. Any other soloution
I tried that on wp 2.02 and still face the same problem. Any other soloution
I tried that on wp 2.02 and still face the same problem. Any other soloution
I tried that on wp 2.02 and still face the same problem. Any other soloution
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?
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?
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?
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?
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.
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.
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.
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.
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.