google-code-export / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
2 stars 1 forks source link

Always Flushing Rewrite Rules #540

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was debugging some slow SQL queries and spotted that CCTM always seems to 
flush the rewrite rules on each page load. 
While the SQL isn't particularly slow, it seems inefficient.
Can we just flush_rules() on saving CCTM options?

Selecting rewritings
----------------------

CCTM->register_custom_post_types

WP_Rewrite->flush_ruleswp-content/plugins/custom-content-type-manager/includes/C
CTM.php (2475)

WP_Rewrite->wp_rewrite_ruleswp-includes/rewrite.php (1906)

get_optionwp-includes/rewrite.php (1635)

Fires off a SELECT query
Next we see an INSERT query

CTM->register_custom_post_types

WP_Rewrite->flush_ruleswp-content/plugins/custom-content-type-manager/includes/C
CTM.php (2475)

WP_Rewrite->wp_rewrite_ruleswp-includes/rewrite.php (1906)

update_optionwp-includes/rewrite.php (1639)

add_optionwp-includes/option.php (235)

@Everett I can send you queries / screenshots direct if required.

Do we need to do this on each page load?

Original issue reported on code.google.com by kb6...@gmail.com on 6 Feb 2014 at 5:31

GoogleCodeExporter commented 9 years ago
Queries and screenshots are welcome -- I've yet to get a bug report that had 
too much info. 

WP's url handling is pretty primitive, so you have to define the rules for each 
request, otherwise WP struggles to find much of anything (at least that's how 
it's been historically).  You can disable that behavior by going to the CCTM 
--> Global Settings menu and unchecking the option to flush rewrite rules.  
Perhaps things have changed so the flushing needs to occur only when options 
are saved? 

Original comment by ever...@fireproofsocks.com on 6 Feb 2014 at 5:38

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
See also Issue #50.  
https://codex.wordpress.org/Function_Reference/flush_rewrite_rules

Original comment by ever...@fireproofsocks.com on 12 Feb 2014 at 10:51

GoogleCodeExporter commented 9 years ago
I'll get you a screenshot when I fire that particular project up again.

Original comment by kb6...@gmail.com on 13 Feb 2014 at 5:58

GoogleCodeExporter commented 9 years ago
Ok -- I have moved the rewrite over to the function that fires when a post type 
def is saved -- that should be compatible with the functionality described in 
the wp codex, but I'd love to see exactly what you've done to test this so I 
can verify the new functionality.  

Original comment by ever...@fireproofsocks.com on 13 Feb 2014 at 5:59