I no longer can delete or update terms on my site.
When I try to delete a term, I get thousands (!) of lines of the same error message:
[15-Mar-2024 10:03:08 UTC] PHP Notice: Trying to get property 'post_type' of non-object in /var/www/domain.tld/wp-content/plugins/sitepress-multilingual-cms/classes/taxonomy-term-translation/class-wpml-term-actions.php on line 180
until the site bails out with a memory exhaustion error:
[15-Mar-2024 10:12:37 UTC] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /var/www/domain.tld/wp-includes/functions.php on line 7111
[15-Mar-2024 10:12:37 UTC] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /var/www/domain.tld/wp-includes/functions.php on line 625
I tried to delete a term because updating programmatically isn't possible anymore either. When I try to `wp_update_term` an existing term, I get a WP_Error saying
{"errors":{"duplicate_term_slug":["The slug “eag-groupes-fr” is already in use by another term."]},"error_data":[]}
Could you please share a screenshot from WPML > Settings of the Posts and pages synchronization section (I've shared an example here). It's the taxonomy settings I'm interested in.
Also, can you confirm how and where you are deleting terms, of which taxonomy?
I've been trying to see how the notice could get triggered, but it's not obvious why.
The code that produces the notice is run when a term has been disconnected from a post it was assigned to. If you delete a term then that will involve that term being disconnected from posts it is assigned to, which will trigger the code that produces the notice.
But the notice occurs because there is no post.
Could I take a look at your site so I can see a concrete example of a term that is to be deleted, and I can see all the permutations of assignments and translations before attempting that?
Let me mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.
Please point me to a particular term to test with.
EDIT: Actually, before you do that, you could just try the two actions indicated in the screenshot from the page at WPML > Support > Troubleshooting (apply to the different post types the terms might be assigned to).
Actually, the site is much more broken that hat. I have e.g. terms in 3 languages that all show 223 connected posts, but when we click on the count, we get 0 posts.
There is something really broken here with the site that I wanted to debug by deleting a term, when I discovered that too wasn't working. Same with the programmatic update that is failing, probably for the same reasons.
I'll try the troubleshooting page options and will let you know.
I can see a problem that if I click on the count (220) for the adults term of the age group taxonomy (to see the event posts that have the term assigned) it shows zero results, and via Query Monitor I can see why the query is returning zero results.
It includes a condition that ( 0 = 1 ) which clearly cannot ever be true.
But I can't see how that condition gets added very easily on your site.
Would it be okay to take a copy of your site to install locally, where I can more easily investigate and determine why that happens?