Forums

Failure Storing Permalink Slug (2 posts)

  1. JustinRBriggs
    Member
    Posted 3 months ago #

    Hello,

    I'm having a problem with the permalink slug being stored when publishing. Once you type in a title and tab off, it often fails creating the permalink and returns the ugly parameter URL instead, with no option of editing. Sometimes clicking "Save As Draft" fixes it by forcing it to try again, but sometimes that results in the post just falling back into All Posts as a draft.

    I think I know what may be causing, but I'm stuck on a solution.

    When you type in a title, then tab off it, that's when the bug is occurring. At this moment, two AJAX calls are made, one after another to /blog/wp-admin/admin-ajax.php. On our Stage and Production boxes, the latency on this script becomes rather large while it's looking up the id and creating slug. When this fails, it's not saving the slug into the DB.

    I think this hang up is causing the issue.

    The closest hack I've come up with to solve this is to add this code (it's really hacky).

    +++ wp-admin/includes/post.php       (working copy)

     function get_sample_permalink($id, $title = null, $name = null) {
    -           $post = &get_post($id);
    +          // Try looking for the post by its id 10 times before giving up.
    +          for ($i = 1; $i <= 11; $i++) {
    +                      $post = &get_post($id);
    +                      if ( $post->ID ) break;
    +                      // Sleep for 0.25 seconds
    +                      usleep (250000);
    +          }
    +
                if ( !$post->ID )
                            return array('', '');

    This stopped the problem on QA, but not in stage, so it's not a complete hack.

    It appears the communication between my desktop and the WordPress Admin UI is faster than the communication between the WordPress instance and its database. In most environments, the WP and DB are on the same host, so WP <-> DB communication is very fast, but our setup is making this communication slower. This isn't as much of a concern on the frontend, since we'll be caching, but it's making post publish fail once out of ever 5 attempts.

    Any thoughts on a code solution to the problem?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 months ago #

    Do not edit core files. Have you tried:

    - deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the Twenty Eleven theme to rule out any theme-specific problems.

    - resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

    - re-uploading the wp-admin and wp-includes folders from a fresh download of WordPress.

    - repairing your database?

Reply

You must log in to post.

About this Topic