Support » Fixing WordPress » 404 after save or publish a post

  • Hello everybody

    After uprading to 2.01 I get everytime a 404 when I wrote a post an press ” save” or “publish” or “save and continue editing”. Does anybody experience the same and how to solve this ?

Viewing 15 replies - 16 through 30 (of 79 total)
  • The problem is caused by a query done by the url_to_postid function call in the ‘if’ statement on line 212 of wp-admin\edit-form-advanced.php when the ‘save and continue editing’ operation is performed.

    Since I’m not a mySQL expert by any stretch, I’m not sure what’s wrong with the query.

    I’m with others here and having this site crippling issue. If I can’t post, then I’ll be abandoning WordPress.

    It’s not site crippling by any means – the post mechanism still works fine, it just returns your browser to a non-existent page.

    In your case, perhaps the post is saved. I’ve been trying to follow your sleuthing and it seems like good work, though I know squat so let the buyer beware.

    I do know, that the post on one of my setups is not saved. I don’t use “save and continue”. I have a local setup, and two on hosting services and only one of them refuses to save or publish, depending on which button I click. Type a few extra characters in the post and … no go. Not consistently on the one host that is giving trouble as I was able to get it to take one larger post.

    There are slightly different versions of Apache, PHP, and MySQL involved, I can dig them up if someone thinks it will help, though only minor version numbers.

    rdsmes, perhaps your on the right track, do keep it up, just thought I would chime back in.

    I’m certainly in no position to say that there aren’t multiple problems. I can only speak to the one I’m seeing that I’ve detailed above. And in my case, the posts are actually getting posted, but the browser is redirected to never-never land. That is, in my case, pretty much just an annoyance more than a real ‘problem’.

    But since what I’m seeing does seem to be some sort of misconstructed mySQL query, or at least something that is causing the database to throw up an error in complaint, that doesn’t mean that the same or a similar problem can’t or won’t crop up in other usage scenarios. I happened to figure out that I could force the one problem to occur by doing the ‘save-and-continue’, and chose to go down that road since it was very reproducible. And now I’m not sure how much further to go, since I don’t know that much about the WP inner workings with mySQL, and would hesitate to make many changes in that area since it is the heart and soul of the code.

    Luckily, I’ve been doing most of the hacking on a local machine, not the machine my site is hosted on.

    When looking at Apache, PHP, and MySQL versions, don’t forget to include the Zend Optimizer as well. My hosting company uses Zend, and I have seen it do funny things to parts of the older WP code.

    rdsmes, it most certainly is site crippling for me as no posts go through. After I click “Publish” it goes immediately to the actual site (outside of /wp-admin/) and gives a 404 error.

    As it happens to me, when I hit ‘publish’, I too am returned to the ‘site’ and get a 404 error since the browser is attempting to access a page that doesn’t exist (because the redirection URL is garbage). But if I click on ‘home’ or go to my site’s home page, I find that the offending post did indeed get published, even though it didn’t “feel” like it did.

    Ok, here’s the deal on my 404 problem, to the best of my knowledge, for any of the developer types that might want to look into this issue:

    I’ve been able to reproduce the problem reliably by starting a new post, then using the ‘save and continue editing’ button. When the page is being generated to send back to my browser, here’s what happens:

    1) in edit-form-advanced.php, when generating the ‘referredby’ value, the url_to_postid function is called.

    2) toward the end of the function, the url_to_postid function generates a new WP_Query object.

    3) the WP_Query object calls its get_posts() function.

    4) After much ado, the get_posts function generates the first mySQL query through a call to $wpdb->get_results() That query IS SUCCESSFUL.

    5) However, further down in the get_posts function, the resulting $this->posts array is passed to the update_post_caches function.

    6) In the update_post_caches function, the $posts array is found to be non-empty. For the next mySQL query, the $post_id_array is ‘imploded’ to form the $post_id_list. But the resulting $post_id_list IS EMPTY. When this empty $post_id_list is passed as the parameter for the IN() section of the next mySQL query (comment “Get post-meta info”), mySQL complains (most likely) about the IN parameters being empty. This causes the wpdb object to print_error, and the output of that print error finds its way all the way back to the beginning of this story, in the ‘referredby’ field of the page sent back to the browser, and ultimately into the redirection URL on a ‘save’ or ‘publish’ operation. That garbage in the URL causes the 404.

    This is turning into one of those things that needs a post to the wp-testers list….

    If anybody has the guts to try a quick patch / workaround for this problem – for those running maybe a local test server or something like that, you could give this a try:

    Edit file wp-includes\functions.php. On line 1413, in the update_post_caches routine, you’ll see:

    $post_id_list = implode(',', $post_id_array);

    Add a check after that line, so that it looks like this:

    $post_id_list = implode(',', $post_id_array);

    if (empty ($post_id_list))

    I’ve run that patch on my test machine now, and it seems to have cleared up the 404 problem that I was able to reproduce on demand by using the ‘save and continue’ button. I’m sure, for the developers out there, that THIS IS NOT the preferred solution. But it may get you up and running.

    It’s up to you if you’d like to give it a shot. I can’t guarantee that there won’t be ill effects, but the fix just really detects a condition that was causing a query to fail anyway.

    I’ve done about all I can do to pin this one down. I’ll play with this patch for a while and see how it goes.

    Like I said in the other thread, I don’t visit this site that much, so I wasn’t sure how to submit bug reports, and I don’t see a link anywhere.

    I cured my problem about the 404 when clicking publish or edit by disableing the pingomatic feature. Go to options then writing and it is at the bottom of page. Afte this I have not seen the 404 error, I have tested about 25 times.
    Go here to view my blog.

    May I request a this be made a sticky until the problem is fixed?

    I have been getting this with the last 2.0 and 2.0.1 … was just being patient waiting for a stable version.

    It is a problem. I have numerous students and others using the latest veresion and it has been a problem for all of them.

    rdsmes –

    bug reports to – be sure you look through the current listings to make sure it’s not already there….

    vkaryl –

    Thanks for the pointer. It looks like a ticket is already open on this subject – #2498, “faulty “referredby” in write post page” – and a patch has been suggested in the same area of code where I placed mine.

    Since it’s already in the bug tracking mechanism, but there is no official resolution or fix for the problem, I’m not sure what options users have at this point other than to try a patch of some sort.

Viewing 15 replies - 16 through 30 (of 79 total)
  • The topic ‘404 after save or publish a post’ is closed to new replies.