Duplicate GUIDs by default #49

merged 1 commit into from Feb 10, 2014


None yet

2 participants


All Safe-Redirect-Manager posts have matching GUIDs. I assume this is because the post type doesn't support 'title'.

Aside from the philosophical ramifications of non-unique "unique IDs", this is problematic for my team because we use the RAMP content deployment plugin in our publishing workflow. RAMP relies on post GUIDs to determine whether a post exists on both staging and production. Posts with duplicate GUIDs are extremely problematic.

I've worked around the problem for now by generating a unique-ish GUID (using timestamp + author ID) in the filter_post_type_link function:

public function filter_post_type_link( $permalink, $post ) {
    if ( $this->redirect_post_type != $post->post_type )
        return $permalink;

    // Handle initial GUID generation
    if ('' == $post->post_name) 
      return home_url('safe-redirect-rule-' . gmmktime() . '-' . $post->post_author);

    // We can't do anything to provide a permalink 
    // for regex enabled redirects.
    if ( get_post_meta( $post->ID, $this->meta_key_enable_redirect_from_regex, true ) )
        return $permalink;

    // We can't do anything if there is a wildcard in the redirect from
    $redirect_from = get_post_meta( $post->ID, $this->meta_key_redirect_from, true );
    if ( false !== strpos( $redirect_from, '*' ) )
        return $permalink;

    return home_url( $redirect_from );

Thanks for the report! Up for submitting a PR with a more permanent solution?


Done. I was over-complicating it in my quick workaround. The default permalink and subsequent unique GUID are generated before the post_type_link filter is hit, but it was being set to empty string when "Redirect From" was blank (e.g. during initial auto-draft).

@danielbachhuber danielbachhuber added this to the 1.7.2 milestone Feb 10, 2014
@danielbachhuber danielbachhuber merged commit dcce66f into master Feb 10, 2014
@danielbachhuber danielbachhuber deleted the use-default-49 branch Feb 10, 2014

Thanks again, @danblaker

@danielbachhuber danielbachhuber added a commit that referenced this pull request Feb 10, 2014
@danielbachhuber danielbachhuber Props for #49 101b6da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment