WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 8 months ago

Last modified 8 months ago

#15943 closed defect (bug) (worksforme)

Custom Post Type not set after customizing permalinks.

Reported by: sterlo Owned by: sterlo
Milestone: Priority: normal
Severity: normal Version: 3.0.3
Component: Multisite Keywords: reporter-feedback
Focuses: Cc:

Description

Developing a plugin,

It sets a custom post type on init:

      register_post_type(
        'staff_listing',
        array(
          'labels' => array(
            'name' => 'Staff Listings',
            'add_new_item' => 'Add a Staff Member',
            'new_item' => 'Staff Member',
            'add_new' => 'Add a Staff Member',
            'singular_name' => 'Staff Member'
          ),  
          'public' => true,
          'publicly_queryable' => true,
          'show_in_nav_menus'  => false,
          'exclude_from_search' => false,
          'show_ui' => true, 
          'hierarchical' => false,
          'rewrite' => array(
            'slug' => 'staff',
            'with_front' => false
          ),  
          'query_var' => 'staff', 
          'supports' => array(
            'title',
            'editor',
            'thumbnail',
            'comments',
            'revisions'
          )   
        )   
      ); 

If I add a staff member called "john doe" and then go to that on the front end - I expect to see this in $wp_query->query_vars:

[staff] => john-doe
[post_type] => staff_listing
[category_name] =>
[name] => john-doe
[is_404] =>
[queried_object_id] => ###

(I replaced the ID with ### since it changes from one install to the other)

That works on a standard WordPress 3.0.3 install.

But does not work on a WordPress 3.0.3 MU install.

The MU install gives me this:

[name] => john-doe
[post_type] => 
[category_name] => staff
[is_404] => 1
[is_singular] => 
[queried_object_id] => 0

Both the permalinks on the MU and standard setup are set as follows:

/%category%/%postname%/

If I change the permalink structure on the MU site to the default structure - the problem goes away.

The new URL is: ?staff=john-doe and it sets the following:

[staff] => john-doe
[post_type] => staff_listing
[name] => john-doe
[category_name] =>
[is_404] =>
[queried_object_id] => ###

Attachments (8)

assumedbase (1.9 KB) - added by sterlo 3 years ago.
This is the assumed "default" values. One can obtain these values by clicking "default" and saving more than once.
1stcustomsave (11.4 KB) - added by sterlo 3 years ago.
These are the results of the first save if you change your custom permalink structure to: "/%category%/%postname%/"
2ndcustomsave (14.9 KB) - added by sterlo 3 years ago.
These are the results of the second save - if you keep your custom permalink structure as "/%category%/%postname%/" and don't touch anything else. Just hit save.
backtodefault (3.0 KB) - added by sterlo 3 years ago.
These are the results if you then select default again and hit save.
base-vs-1stcustomsave.diff (11.9 KB) - added by sterlo 3 years ago.
These are the differences between objects after you save for the first time.
1stcustomsave-vs-2ndcustomsave.diff (10.3 KB) - added by sterlo 3 years ago.
These are the differences between objects after the second save (not changing values or options).
backtodefault-vs-base.diff (3.0 KB) - added by sterlo 3 years ago.
These are the differences between objects if you set it back to default.
2ndcustomsave-vs-backtodefault.diff (15.3 KB) - added by sterlo 3 years ago.
These are the differences between objects after you set it back to default from the second custom permalink object.

Download all attachments as: .zip

Change History (30)

comment:1 sterlo3 years ago

Another thing to note:

That both the MU and the standard install both have the same page/category set up.

Instead of having a page called /staff/ I have a category.

This means that when I go to /staff/ it works (this is true for BOTH of them).

It only gets weird when I do /staff/john-doe/ on MU.

Version 0, edited 3 years ago by sterlo (next)

comment:2 sterlo3 years ago

Another thing to note...

Local Wordpress is using Apache.

Remote WordPress MultiSite is using NGINX.

comment:3 sterlo3 years ago

  • Cc sterling.hamilton+wordpress@… added
  • Component changed from General to Multisite
  • Summary changed from Custom Post Type not being set on MU with Custom Permalinks to Custom Post Type not being set on WPMS with Custom Permalinks
  • Version set to 3.0.3

comment:4 follow-up: scribu3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

trac is for resolving bugs in the development version of WP (currently 3.1-beta).

You should ask for help in the support forums:

http://wordpress.org/support/

Only after you're sure it's a bug in WP, still reproducible in the latest beta, should you open a ticket.

comment:5 in reply to: ↑ 4 sterlo3 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Replying to scribu:

trac is for resolving bugs in the development version of WP (currently 3.1-beta).

You should ask for help in the support forums:

http://wordpress.org/support/

Only after you're sure it's a bug in WP, still reproducible in the latest beta, should you open a ticket.

This is a bug. I've had it tested by other developers. They all experience the same thing.

I believe this meets the requirements of posting a bug ticket:
http://codex.wordpress.org/Reporting_Bugs#Before_You_Report_a_Bug

If you'd like to contest whether or not it is indeed a bug - please look into the matter yourself.

I will be providing an Apples to Apples test shortly.

comment:6 scribu3 years ago

  • Milestone set to Awaiting Review

comment:7 jameslafferty3 years ago

I've been able to reproduce this bug in beta.

Steps to reproduce:

  1. Install latest trunk of WordPress via svn.
  2. Enable multisite.
  3. Enable a custom permalink structure (I used day and name: /%year%/%monthnum%/%day%/%postname%/).
  4. Add the "Products" custom post-type from the codex example to the top of twentyten/functions.php
  5. Create a new Product.
  6. When you go click View Post, you get a 404.
  7. Note that I was able to reproduce only the first time I visited the post immediately after creating it.
  8. Also note that this seems to be an issue of how the permalink is set up in the admin UI when the post is first created. The url I first visited (on my local machine) that returned the 404 was http://wp-beta.loc/2010/12/22/foo/. Subsequently, the view page link pointed to http://wp-beta.loc/acme_product/foo/.

comment:8 nacin3 years ago

  • Milestone changed from Awaiting Review to Future Release

Possibly related? #14011, #15360.

Not a regression. Punting.

comment:9 sterlo3 years ago

I've done a test between wordpress.org/latest.zip standard setup and multisite setup.

What I've found is it's NOT exclusive to the multisite setup.

I will post steps shortly on how to reproduce the problem consistently in both setups.

comment:10 sterlo3 years ago

Disclaimer: This is pretty verbose, sorry about that. It also includes a link to a gist that has a test plugin in it. Feel free to use your own code so we have more than one kind of testing.

My testing produced this really lame 'solution'. I was able to get this to work locally on apache2 for MS 3.0.3 and Standard (from wordpress.org/latest.zip) AND 3.1-beta2-17056 (standard setup)

Steps to reproduce:

  1. Install a new site (MS or not - does not matter).
  2. Install this plugin (it's one file): https://gist.github.com/751946
  3. Add a new 'product'
  4. After publishing the product - click the view post button:
    http://wordpress-test.local/?acme_product=test-product
    You should see this as output for $wp_query (post_type is set):
    WP_Query Object
    (
        [query_vars] => Array
            (
                [acme_product] => test-product
                [post_type] => acme_product
                [name] => test-product
                [error] => 
                [m] => 0
                [p] => 0
                [post_parent] => 
                [subpost] => 
                [subpost_id] => 
                [attachment] => 
                [attachment_id] => 0
                [static] => 
                [pagename] => 
                [page_id] => 0
                [second] => 
                [minute] => 
                [hour] => 
                [day] => 0
                [monthnum] => 0
                [year] => 0
                [w] => 0
                [category_name] => 
                [tag] => 
                [cat] => 
                [tag_id] => 
                [author_name] => 
                [feed] => 
                [tb] => 
                [paged] => 0
                [comments_popup] => 
                [meta_key] => 
                [meta_value] => 
                [preview] => 
                [s] => 
                [sentence] => 
                [fields] => 
                [category__in] => Array
                    (
                    )
    
                [category__not_in] => Array
                    (
                    )
    
                [category__and] => Array
                    (
                    )
    
                [post__in] => Array
                    (
                    )
    
                [post__not_in] => Array
                    (
                    )
    
                [tag__in] => Array
                    (
                    )
    
                [tag__not_in] => Array
                    (
                    )
    
                [tag__and] => Array
                    (
                    )
    
                [tag_slug__in] => Array
                    (
                    )
    
                [tag_slug__and] => Array
                    (
                    )
    
                [ignore_sticky_posts] => 
                [suppress_filters] => 
                [cache_results] => 1
                [update_post_term_cache] => 1
                [update_post_meta_cache] => 1
                [posts_per_page] => 10
                [nopaging] => 
                [comments_per_page] => 50
                [no_found_rows] => 
                [order] => DESC
                [orderby] => wp_posts.post_date DESC
            )
    
        [tax_query] => WP_Tax_Query Object
            (
                [queries] => Array
                    (
                    )
    
                [relation] => AND
            )
    
        [post_count] => 1
        [current_post] => -1
        [in_the_loop] => 
        [comment_count] => 0
        [current_comment] => -1
        [found_posts] => 0
        [max_num_pages] => 0
        [max_num_comment_pages] => 0
        [is_single] => 1
        [is_preview] => 
        [is_page] => 
        [is_archive] => 
        [is_date] => 
        [is_year] => 
        [is_month] => 
        [is_day] => 
        [is_time] => 
        [is_author] => 
        [is_category] => 
        [is_tag] => 
        [is_tax] => 
        [is_search] => 
        [is_feed] => 
        [is_comment_feed] => 
        [is_trackback] => 
        [is_home] => 
        [is_404] => 
        [is_comments_popup] => 
        [is_paged] => 
        [is_admin] => 
        [is_attachment] => 
        [is_singular] => 1
        [is_robots] => 
        [is_posts_page] => 
        [is_post_type_archive] => 
        [query] => Array
            (
                [acme_product] => test-product
                [post_type] => acme_product
                [name] => test-product
            )
    
        [request] =>  SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_name = 'test-product' AND wp_posts.post_type = 'acme_product'  ORDER BY wp_posts.post_date DESC 
        [posts] => Array
            (
                [0] => stdClass Object
                    (
                        [ID] => 4
                        [post_author] => 1
                        [post_date] => 2010-12-22 19:15:02
                        [post_date_gmt] => 2010-12-22 19:15:02
                        [post_content] => Test content.
                        [post_title] => Test Product
                        [post_excerpt] => 
                        [post_status] => publish
                        [comment_status] => open
                        [ping_status] => open
                        [post_password] => 
                        [post_name] => test-product
                        [to_ping] => 
                        [pinged] => 
                        [post_modified] => 2010-12-22 19:15:02
                        [post_modified_gmt] => 2010-12-22 19:15:02
                        [post_content_filtered] => 
                        [post_parent] => 0
                        [guid] => http://wordpress-test.local/?post_type=acme_product&p=4
                        [menu_order] => 0
                        [post_type] => acme_product
                        [post_mime_type] => 
                        [comment_count] => 0
                        [ancestors] => Array
                            (
                            )
    
                        [filter] => raw
                    )
    
            )
    
        [post] => stdClass Object
            (
                [ID] => 4
                [post_author] => 1
                [post_date] => 2010-12-22 19:15:02
                [post_date_gmt] => 2010-12-22 19:15:02
                [post_content] => Test content.
                [post_title] => Test Product
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => open
                [ping_status] => open
                [post_password] => 
                [post_name] => test-product
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2010-12-22 19:15:02
                [post_modified_gmt] => 2010-12-22 19:15:02
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => http://wordpress-test.local/?post_type=acme_product&p=4
                [menu_order] => 0
                [post_type] => acme_product
                [post_mime_type] => 
                [comment_count] => 0
                [ancestors] => Array
                    (
                    )
    
                [filter] => raw
            )
    
    )
    
  5. Now go turn on custom permalinks, '/%category%/%postname%/', hit save.
  6. Then it asks to do this: Add to your .htaccess file:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
  7. Then I view the post at:
    http://wordpress-test.local/acme_product/test-product/
  8. You should now see this as output for $wp_query (post_type is not set):
    WP_Query Object
    (
        [query_vars] => Array
            (
                [page] => 0
                [name] => test-product
                [category_name] => acme_product
                [error] => 
                [m] => 0
                [p] => 0
                [post_parent] => 
                [subpost] => 
                [subpost_id] => 
                [attachment] => 
                [attachment_id] => 0
                [static] => 
                [pagename] => 
                [page_id] => 0
                [second] => 
                [minute] => 
                [hour] => 
                [day] => 0
                [monthnum] => 0
                [year] => 0
                [w] => 0
                [tag] => 
                [cat] => 
                [tag_id] => 
                [author_name] => 
                [feed] => 
                [tb] => 
                [paged] => 0
                [comments_popup] => 
                [meta_key] => 
                [meta_value] => 
                [preview] => 
                [s] => 
                [sentence] => 
                [fields] => 
                [category__in] => Array
                    (
                    )
    
                [category__not_in] => Array
                    (
                    )
    
                [category__and] => Array
                    (
                    )
    
                [post__in] => Array
                    (
                    )
    
                [post__not_in] => Array
                    (
                    )
    
                [tag__in] => Array
                    (
                    )
    
                [tag__not_in] => Array
                    (
                    )
    
                [tag__and] => Array
                    (
                    )
    
                [tag_slug__in] => Array
                    (
                    )
    
                [tag_slug__and] => Array
                    (
                    )
    
                [ignore_sticky_posts] => 
                [suppress_filters] => 
                [cache_results] => 1
                [update_post_term_cache] => 1
                [update_post_meta_cache] => 1
                [post_type] => 
                [posts_per_page] => 10
                [nopaging] => 
                [comments_per_page] => 50
                [no_found_rows] => 
                [order] => DESC
                [orderby] => wp_posts.post_date DESC
            )
    
        [tax_query] => WP_Tax_Query Object
            (
                [queries] => Array
                    (
                        [0] => Array
                            (
                                [taxonomy] => category
                                [terms] => Array
                                    (
                                        [0] => acme_product
                                    )
    
                                [include_children] => 1
                                [field] => slug
                                [operator] => IN
                            )
    
                    )
    
                [relation] => AND
            )
    
        [post_count] => 0
        [current_post] => -1
        [in_the_loop] => 
        [comment_count] => 0
        [current_comment] => -1
        [found_posts] => 0
        [max_num_pages] => 0
        [max_num_comment_pages] => 0
        [is_single] => 
        [is_preview] => 
        [is_page] => 
        [is_archive] => 
        [is_date] => 
        [is_year] => 
        [is_month] => 
        [is_day] => 
        [is_time] => 
        [is_author] => 
        [is_category] => 
        [is_tag] => 
        [is_tax] => 
        [is_search] => 
        [is_feed] => 
        [is_comment_feed] => 
        [is_trackback] => 
        [is_home] => 
        [is_404] => 1
        [is_comments_popup] => 
        [is_paged] => 
        [is_admin] => 
        [is_attachment] => 
        [is_singular] => 
        [is_robots] => 
        [is_posts_page] => 
        [is_post_type_archive] => 
        [query] => Array
            (
                [page] => 
                [name] => test-product
                [category_name] => acme_product
            )
    
        [request] =>  SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_name = 'test-product' AND 0 = 1 AND wp_posts.post_type = 'post' GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC 
        [posts] => Array
            (
            )
    
    )
    
    You should notice that it's not longer setting the post_type and is is_404 = 1.
  9. Now go BACK to the permalink page...don't change anything...just hit save again. Then view then refresh the post and you should see this from $wp_query (post_type is set):
    WP_Query Object
    (
        [query_vars] => Array
            (
                [page] => 0
                [acme_product] => test-product
                [post_type] => acme_product
                [name] => test-product
                [error] => 
                [m] => 0
                [p] => 0
                [post_parent] => 
                [subpost] => 
                [subpost_id] => 
                [attachment] => 
                [attachment_id] => 0
                [static] => 
                [pagename] => 
                [page_id] => 0
                [second] => 
                [minute] => 
                [hour] => 
                [day] => 0
                [monthnum] => 0
                [year] => 0
                [w] => 0
                [category_name] => 
                [tag] => 
                [cat] => 
                [tag_id] => 
                [author_name] => 
                [feed] => 
                [tb] => 
                [paged] => 0
                [comments_popup] => 
                [meta_key] => 
                [meta_value] => 
                [preview] => 
                [s] => 
                [sentence] => 
                [fields] => 
                [category__in] => Array
                    (
                    )
    
                [category__not_in] => Array
                    (
                    )
    
                [category__and] => Array
                    (
                    )
    
                [post__in] => Array
                    (
                    )
    
                [post__not_in] => Array
                    (
                    )
    
                [tag__in] => Array
                    (
                    )
    
                [tag__not_in] => Array
                    (
                    )
    
                [tag__and] => Array
                    (
                    )
    
                [tag_slug__in] => Array
                    (
                    )
    
                [tag_slug__and] => Array
                    (
                    )
    
                [ignore_sticky_posts] => 
                [suppress_filters] => 
                [cache_results] => 1
                [update_post_term_cache] => 1
                [update_post_meta_cache] => 1
                [posts_per_page] => 10
                [nopaging] => 
                [comments_per_page] => 50
                [no_found_rows] => 
                [order] => DESC
                [orderby] => wp_posts.post_date DESC
            )
    
        [tax_query] => WP_Tax_Query Object
            (
                [queries] => Array
                    (
                    )
    
                [relation] => AND
            )
    
        [post_count] => 1
        [current_post] => -1
        [in_the_loop] => 
        [comment_count] => 0
        [current_comment] => -1
        [found_posts] => 0
        [max_num_pages] => 0
        [max_num_comment_pages] => 0
        [is_single] => 1
        [is_preview] => 
        [is_page] => 
        [is_archive] => 
        [is_date] => 
        [is_year] => 
        [is_month] => 
        [is_day] => 
        [is_time] => 
        [is_author] => 
        [is_category] => 
        [is_tag] => 
        [is_tax] => 
        [is_search] => 
        [is_feed] => 
        [is_comment_feed] => 
        [is_trackback] => 
        [is_home] => 
        [is_404] => 
        [is_comments_popup] => 
        [is_paged] => 
        [is_admin] => 
        [is_attachment] => 
        [is_singular] => 1
        [is_robots] => 
        [is_posts_page] => 
        [is_post_type_archive] => 
        [query] => Array
            (
                [page] => 
                [acme_product] => test-product
                [post_type] => acme_product
                [name] => test-product
            )
    
        [request] =>  SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_name = 'test-product' AND wp_posts.post_type = 'acme_product'  ORDER BY wp_posts.post_date DESC 
        [posts] => Array
            (
                [0] => stdClass Object
                    (
                        [ID] => 4
                        [post_author] => 1
                        [post_date] => 2010-12-22 19:15:02
                        [post_date_gmt] => 2010-12-22 19:15:02
                        [post_content] => Test content.
                        [post_title] => Test Product
                        [post_excerpt] => 
                        [post_status] => publish
                        [comment_status] => open
                        [ping_status] => open
                        [post_password] => 
                        [post_name] => test-product
                        [to_ping] => 
                        [pinged] => 
                        [post_modified] => 2010-12-22 19:15:02
                        [post_modified_gmt] => 2010-12-22 19:15:02
                        [post_content_filtered] => 
                        [post_parent] => 0
                        [guid] => http://wordpress-test.local/?post_type=acme_product&p=4
                        [menu_order] => 0
                        [post_type] => acme_product
                        [post_mime_type] => 
                        [comment_count] => 0
                        [ancestors] => Array
                            (
                            )
    
                        [filter] => raw
                    )
    
            )
    
        [post] => stdClass Object
            (
                [ID] => 4
                [post_author] => 1
                [post_date] => 2010-12-22 19:15:02
                [post_date_gmt] => 2010-12-22 19:15:02
                [post_content] => Test content.
                [post_title] => Test Product
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => open
                [ping_status] => open
                [post_password] => 
                [post_name] => test-product
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2010-12-22 19:15:02
                [post_modified_gmt] => 2010-12-22 19:15:02
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => http://wordpress-test.local/?post_type=acme_product&p=4
                [menu_order] => 0
                [post_type] => acme_product
                [post_mime_type] => 
                [comment_count] => 0
                [ancestors] => Array
                    (
                    )
    
                [filter] => raw
            )
    
        [queried_object] => stdClass Object
            (
                [ID] => 4
                [post_author] => 1
                [post_date] => 2010-12-22 19:15:02
                [post_date_gmt] => 2010-12-22 19:15:02
                [post_content] => Test content.
                [post_title] => Test Product
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => open
                [ping_status] => open
                [post_password] => 
                [post_name] => test-product
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2010-12-22 19:15:02
                [post_modified_gmt] => 2010-12-22 19:15:02
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => http://wordpress-test.local/?post_type=acme_product&p=4
                [menu_order] => 0
                [post_type] => acme_product
                [post_mime_type] => 
                [comment_count] => 0
                [ancestors] => Array
                    (
                    )
    
                [filter] => raw
            )
    
        [queried_object_id] => 4
    )
    


Now I should mention that all of my sites in production (3.0.3 from latest.zip) have custom permalinks...

So by my testing - the fix for them is to just re-save all their custom structures on the permalink screen.

Testing that theory didn't seem work for me in production. But locally I did it 3 times and it did exactly what I expected.

If I did: ?staff=test-member it works as expected.

After changing the permalinks to '/%category%/%postname%/' it still presents the same problem.

URL would be: /staff/test-member/

But this works of course: /staff/test-member/?staff=test-member

Could someone else do some testing on their end and see what they come up with?

comment:11 sterlo3 years ago

Unsetting then resetting permalinks locally puts the install into the same problem I have in production.

comment:12 sterlo3 years ago

Well this is fun...

Doing that got me thinking...

  1. Remove the .htaccess file
  2. Refresh /acme_product/test-product/
    Result: "Not Found"
  3. Add exact .htaccess file back
    Result: post_type not set and is_404 = 1
  4. Set permalinks to '/%category%/%postname%/' and hit save
    Result: post_type is now set and is_404 = 0
  5. Set permalinks back to 'default' then set back to '/%category%/%postname%/' then refresh /acme_product/test-product/
    Result: post_type not set and is_404 = 1
  6. ???
  7. Profit!!!!

comment:13 scribu3 years ago

You should have posted the WP_Query outputs as attachments.

Anyway, thanks for the detailed steps.

comment:14 sterlo3 years ago

  • Summary changed from Custom Post Type not being set on WPMS with Custom Permalinks to Custom Post Type not set after customizing permalinks.

comment:15 westi3 years ago

  • Cc westi added

%category% rooted permalink structures are evil :-(

They like to match everything else.

Maybe we need to put the CPT rewrite rules earlier?

sterlo3 years ago

This is the assumed "default" values. One can obtain these values by clicking "default" and saving more than once.

sterlo3 years ago

These are the results of the first save if you change your custom permalink structure to: "/%category%/%postname%/"

sterlo3 years ago

These are the results of the second save - if you keep your custom permalink structure as "/%category%/%postname%/" and don't touch anything else. Just hit save.

sterlo3 years ago

These are the results if you then select default again and hit save.

sterlo3 years ago

These are the differences between objects after you save for the first time.

sterlo3 years ago

These are the differences between objects after the second save (not changing values or options).

sterlo3 years ago

These are the differences between objects if you set it back to default.

sterlo3 years ago

These are the differences between objects after you set it back to default from the second custom permalink object.

comment:16 sterlo3 years ago

I've attached some of my findings.

The first set of attachments are just the objects in their entirety.

The second set of attachments are the diff files between them.

I'm making some assumptions here.

  1. When you start off - a fresh wordpress install - the WP_Rewrite object is at it's smallest.
    So this would be the assumedbase file.

So if you save multiple times (with the default value selected) or ... install a fresh WordPress install and then view the WP_Rewrite object - they should be the same.

The first time you select your custom post type it does some notable things:

  1. It sets "permalink_structure"
  2. It sets "rules"
  3. It sets "extra_rules_top"
  4. It sets "extra_permastructs"
  5. It appends to "rewritecode", "rewritereplace", "queryreplace", and it sets:
    220 +    [date_structure] => /%year%/%monthnum%/%day%
    221 +    [search_structure] => search/%search%
    222 +    [author_structure] => /author/%author%
    223 +    [page_structure] => %pagename%
    

The SECOND time you save (without selecting any other options on the page - just keeping the radio button "as is" and the input value "as is".

You get the object in 2ndcustomsave.

This has some interesting bits in it...

  1. This time it added my custom post type and taxonomy to "rules"...
  2. It also did the same for "extra_rules_top"...
  3. It also added structures to "extra_permastructs"..
  4. It did additional appends to "rewritecode", "rewritereplace", "queryreplace".

Now after this (in my testing) it did not alter the object any further - regardless of multiple saves with the same values.

But if I set it back to "default" - you get the object inside of "backtodefault".

The differences between these are the following:

  1. "rules" is now empty
  2. "extra_rules_top" is now empty
  3. It unsets a few flags and then:
    264 -    [date_structure] => /%year%/%monthnum%/%day%
    265 -    [search_structure] => search/%search%
    266 -    [author_structure] => /author/%author%
    267 -    [page_structure] => %pagename%
    

Things to note:

  • "extra_permastructs" still has the custom post type and the taxonomies.

Finally

If you save again - you go back to the first object set that we had initially.

It removes custom post types, taxonomies, rewrite codes, etc.

Obviously - something is messed up here. I think it goes beyond "detecting" the page in the WP_Query object, this has to do with the saving processes for WP_Rewrite.

I will look into this more and hopefully find something.

comment:17 sterlo3 years ago

  • Severity changed from normal to critical

Changing priority.

I feel that this is going to impede other aspects of WordPress.

At the very least, custom post types, taxonomies, core WordPress functionality having to do with custom permalinks.

comment:18 sterlo3 years ago

The plugin that I'm using to produce these results is here:

https://github.com/grok/Staff-Listings

comment:19 sterlo3 years ago

  • Keywords dev-feedback added

comment:20 sterlo3 years ago

  • Owner set to sterlo
  • Status changed from reopened to accepted

comment:21 jeremyfelt8 months ago

  • Keywords reporter-feedback added; dev-feedback removed
  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Severity changed from critical to normal
  • Status changed from accepted to closed

This ticket has extremely detailed information on the issue if it does come up again, but it is all based on 3.0.3 MU. All is most likely good, feel free to open again.

comment:22 nacin8 months ago

This also may have been fixed in something like [24060].

Note: See TracTickets for help on using tickets.