0

I've been having this weird issue on a site for a few weeks now, tried everything I found by searching but still not being able to find a clue of the issue.

Whenever I add some items to the Menu (Appearance > Menus), a few items become empty. And then gets removed when I click the Save button again. Similarly, if I edit any posts, the same thing happens with the menu items.

Here's what I've tried so far,

  1. Increased max_execution_time, max_input_vars, max_input_time, memory_limit, post_max_size, upload_max_filesize, max_file_uploads in PHP.ini. I set those to very high numbers but still no luck
  2. Then I tried copying the site to another hosting and on my localhost, but no luck. Did #1 on all the environments.
  3. Changed the theme to default 2021 and deactivated all plugins, still no luck
  4. Checked the database, wp_posts table has 4.6k rows with size of total 10.8MB, with overheads of about 300KB. So, I tried changing the storage engine of that table to innoDB from MyISAM but the problem is still happening.

Is there anyone who faced similar condition? What could be the issue?

2
  • Verify your php.ini changes in phpinfo() or on the site health page and check the error logs on server and in console. – birgire Mar 5 at 18:07
  • phpinfo() returns correct settings and nothing appears in error logs – Abdul Awal Uzzal Mar 6 at 4:15
0

i got the same problems several times ago, and it's caused by file permission in linux.

for make sure about the problems, would you like to show us about the errors by adding below code in your wp-config.php

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );

be better if you give web console message to when you clicked the save button.

0

Does your site use object cache?

I think this may relate to cache issue on your site.

You can also debug what happens in your site by adding the debug code in core wordpress.

Add to Menu button calls wp_update_nav_menu_item function in wp-includes/nav-menu.php.

You can place a debug code at the begin of the function to see what happens:

function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array() ) {
    error_log(
        json_encode(
            array(
                'method'          => __METHOD__,
                'menu_id'         => $menu_id,
                'menu_item_db_id' => $menu_item_db_id,
                'menu_item_data'  => $menu_item_data,
            )
        )
    );

Save Menu button calls wp_update_nav_menu_object function in wp-includes/nav-menu.php.

Debug code:

function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) {
    error_log(
        json_encode(
            array(
                '__METHOD__ ' => __METHOD__,
                'menu_id'     => $menu_id,
                'menu_data'   => $menu_data,
            )
        )
    );

Then compare the menu_id value to the id stores in your database.

// Query to get menu_id:
select * from wp_terms where term_id = `menu_id_value`;

// Query to get menu_items: 
select id, post_name from wp_posts where post_type = 'nav_menu_item';

If there is a cache issue, these values are different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.