Problem with wp_insert_post when modifying the permanent links with the extension ".html"

I am trying to obtain the following permanent link structures for the product and product categories:
https://mm.mtgeeks.com/product-name.html
https://mm.mtgeeks.com/parent-category-name.html
https://mm.mtgeeks.com/parent-category-name/subcategory-name.html

To obtain this, I modified the permanent link using the following filters and actions:
add_filter (& # 39; request & # 39 ;, & # 39; change_requerst_vars_for_product_cat & # 39;);
add_filter (& # 39; term_link & # 39 ;, & # 39; term_link_filter & # 39 ;, 10, 3);
add_filter (& # 39; post_type_link & # 39 ;, & # 39; wpp_remove_slug & # 39 ;, 10, 3);
add_action (& # 39; pre_get_posts & # 39 ;, & # 39; wpp_change_request & # 39;);
add_action (& # 39; create_term & # 39 ;, & # 39; mee_new_product_cat_edit_success & # 39 ;, 10, 2); // fix 404 errors
add_action (& # 39; init & # 39 ;, & # 39; mee_product_category_rewrite_rules & # 39;);
add_action (& # 39; wp_insert_post & # 39 ;, & # 39; mt_woo_new_product_post_save & # 39;); // fix 404 errors
add_action (& # 39; init & # 39 ;, & # 39; mt_woo_product_rewrite_rules & # 39;);

After updating the permanent links of the wordpress administrator, in the frontend I get the necessary structure for the permanent links, but in the backend I only have one problem.

When I try to make changes to the products, Google Chrome displays the following message:
"This page does not work mm.mtgeeks.com currently can not handle this request.
HTTP ERROR 500 "

After debugging in the wordpress kernel, I noticed that the product update process remains blocked in the wp_insert_post function of wp-includes / post.php on line 3962 (do_action (& # 39; wp_insert_post & # 39 ;, $ post_ID, $ post, $ update);)

How can I solve this problem? For what purposes is this line of code used?

I have observed that if this line of code is commented, the update process is working correctly.