Automattic / Automattic/wp-super-cache

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

Open
#931 1 comment 0 reactions 0 assignees View on GitHub
[Plugin] Super Cache enhancement
Dominant language
PHP
Stars
436
Forks
130
Avg merge
15h 11m
Merged PRs (30d)
10

Description

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:
```php
wp_cache_post_change( $post_id ); // from inside function wp_cache_post_edit($post_id) {
```

what is said to be 1248:
```php
$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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce saving a WordPress menu after removing external-link items, then trace nav-menus.php:368 through wp-includes/nav-menu.php:1046 and wp_cache_post_edit() in wp-cache-phase2.php. Inspect the calls to wp_cache_post_change(), get_permalink(), and wp_load_alloptions() around the reported lines; done means the timeout path and expected handling of nav_menu_item are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.