jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

wp_cache_post_edit() on menu items calls after Save of menu, is that right?

Open DrLightman opened this issue 7 years ago • 1 comments

Getting this PHP stacktrace (I have xdebug installed) after hitting Save on a menu, after removing some menu items from it.

( ! ) Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/myuser/domains/mysite.it/wp-includes/load.php on line 939
Call Stack
#	Time	Memory		Function	Location
1	0.0011	574904		{main}( )	.../nav-menus.php:0
2	1.5977	26711952	wp_nav_menu_update_menu_items( )	.../nav-menus.php:368
3	77.6695	26811416	wp_delete_post( )	.../nav-menu.php:1046
4	77.7827	26817568	do_action( )	.../post.php:2414
5	77.7827	26818984	call_user_func_array:{/var/www/html/myuser/domains/mysite.it/wp-includes/plugin.php:524} ( )	.../plugin.php:524
6	77.7827	26819016	wp_cache_post_edit( )	.../plugin.php:524
7	77.7828	26819336	wp_cache_post_change( )	.../wp-cache-phase2.php:1117
8	97.3421	26824528	get_permalink( )	.../wp-cache-phase2.php:1248
9	97.3422	26826768	get_option( )	.../link-template.php:150
10	97.3422	26826952	wp_load_alloptions( )	.../option.php:78
11	97.3422	26826952	wp_installing( )	.../option.php:177

So I wondered if does it make sense to call wp_cache_post_edit() on a post of type 'nav_menu_item'.

note: line numbers of wp-cache-phase2.php may not correspond to 1.4.9 coz of some mods and comments I made, the lines are:

what is said to be 1117:

		wp_cache_post_change( $post_id ); // from inside function wp_cache_post_edit($post_id) {

what is said to be 1248:

						$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( $post_id ) ) );

I didn't inspected the code further, I don't know exactly why my installation went into an axecution timeout, it never does. And I don't inspected further how WPSC handles post of 'nav_menu_item' type.

FYI, the menu items I removed were two static external links like bla1.org and bla2.org, so they shouldn't impact on local cache either way.

DrLightman avatar Mar 18 '17 21:03 DrLightman

This was unintentional, but at least any change to a menu will be apparent immediately on the site as the cache is deleted.

The plugin doesn't differentiate between post types so since the regular post type actions are called when those posts are edited the plugin will jump into action.

The plugin should possibly have an infrastructure for handling post types more gracefully.

donnchawp avatar Jul 12 '17 16:07 donnchawp