## Debug a WP install: how to find which functions write post updates during a process (a woocommerce checkout in my case)

Question

I hope this question is not too broad or not the right format. But the subject at hand is one of the vaguest: debugging.

For the TLDR crowd out there, the actual question is in bold in the ‘What I am missing’ section 🙂

# Context:

I have to debug a weird occurrence on a large woocommerce WP site that I have not built, and that uses around 40-ish plugins, most of which are woocommerce add-ons.

I cannot go the plugin deactivation route because (1) the site is a production site and we cannot mess with active plugins for too long (2) the bug is impossible to reproduce reliably for tests as we do not understand what triggers it yet and (3) we need to work on the live install to log the bug, which means that at this point, we have to sit and wait…

# The bug:

In rare occurrences of an order completion (we do not know the trigger yet), a woocommerce product (not the same, rather random) is renamed ‘Cart’ (that is, its post_title is modified) somewhere during the checkout process, where multiple plugins have a say (most notably one that generates a tracking number, but also an abandoned cart recovery plugin, payment gateways, product variations plugins etc…)

# What I have working for me right now:

• The error logs (which show nothing because no error is thrown)
• A debugging log filled by a function I hooked to ‘post_updated’ and that will log some data (post id, before title, after title, date modified) when a title changes and the post type is ‘product’

# What I am missing:

So my little logging function is very useful to record ALL occurrences of a product title change during save/update.

BUT, this is where my question(s) arises:

• If I log a backtrace, I get functions.php, which is where I declared my little debugging function
• I want to know more about what functions are modifying the post data during checkout : are there hooks or known methods for climbing up the responsibility chain in a PHP app like WordPress?
• There are so many hooks around the wp_post_update process, but most only give away similar info (generic $post_before, generic $post_after, \$post_id…) -> is there a particular one that I am missing, that would allow a more significant trace of events between the moment a checkout starts and the moment it ends?

I apologize if the question is not really SE format, of if it’s too broad a scope but narrow a context? But consider it is more about DEBUGGING methods and ways to get information from wp hooks than it is about a woocommerce bug 🙂

0
2 years 2019-11-22T09:36:02-05:00 0 Answers 73 views 0