While building a WooCommerce test suite, one test ended on a WordPress “critical error” page. It has not happened again, and I still do not know why it happened. This post is about what I did with an error I could not reproduce: I added a way to catch it next time, got that wrong at first, checked the fix, and left the cause marked as unknown instead of choosing an explanation.
The project is described in the WooCommerce case study, and the full write-up is in docs/CASE_STUDY.md (opens in a new tab).
Read this first. The project is a sample pilot on a disposable WordPress Playground store (SQLite), not client work and not production. The cause of the critical error is unknown. I have not classified it as a product defect, an environment limitation or a test fault, because I have no evidence for any of them.
1. What I saw
CHK-02 is the guest checkout scenario. During development of the suite it ended on a WordPress “critical error” page. There was no PHP error logging at that point, so I did not know what had been thrown.
2. What I did not do
I did not add retries. The suite runs with retries 0 on purpose, so a failure is reported, not retried away. My reasoning is that a retry would have turned an unexplained failure into a green run and left nothing to investigate.
I did not mark CHK-02 test.fail() either, because there was nothing reproducible to
mark. And I did not call it a bug. The project classifies a problem as a product defect, an
environment limitation or a test fault, and only a product defect is called a defect.
3. The debug switch
What I could do was make the next occurrence diagnosable. I added a switch to the test-only plugin,
PILOT_DEBUG=1, that does two things:
- It redirects PHP's error log to
/wp-content/uploads/pilot-debug.log. The file is served over HTTP, because the Playground filesystem is not otherwise reachable. - It adds a shutdown handler that records fatal errors.
It is off by default and never set in CI.
4. My mistake in the first version
My first version redefined the WP_DEBUG constants that Playground already defines. That
printed warnings into responses and broke the REST helper's admin login. The failure that followed
was caused by my debug switch, not by the store. That was my mistake.
I replaced it with ini_set plus the shutdown handler. I am including the mistake
because a diagnostic that changes the thing it observes is easy to write, and a reader checking my
work should know to look for it.
5. Checking the checker
A log that stays empty proves nothing unless you know it can fill. I raised a deliberate fatal error
(an undefined function in a throwaway plugin, since deleted and never committed). The log received
both PHP's own Fatal error entry and the handler's [FATAL …] line. With that, an
empty log in the other runs can be read as “no fatal”, not as “a broken logger”.
6. What happened next
- CHK-02 passed in all 6 local runs I recorded afterwards: 5 with the log switched on and 1 without.
- CHK-02 passed in CI run 46607455020, and all four recorded CI runs passed every test.
- No PHP fatal was logged in the 5 runs with logging on.
The log did record one error, a different one. Each time the WooCommerce Orders list in wp-admin
opens, SQLite cannot parse a parenthesised UNION ALL in the month-filter dropdown query,
and a non-fatal database error is logged. The page still renders, the order list is correct and
ADM-01 passes. I classified it as an environment limitation (SQLite instead of MySQL), not a product
defect.
7. Where it stands, and what this does not show
Cause unknown; not reproduced. If it happens again, the next step is already written
down: start the store with PILOT_DEBUG=1 and read the log.
- It is not explained. Passing local and CI runs do not show that the error is gone, and I do not claim that.
- The cause could be anywhere. A product defect, the environment and a test fault are all still possible.
- The passing runs are a small sample. All recorded CI runs were on one day and on one runner type.
- A disposable store, not production. WordPress Playground on SQLite, Cash on Delivery only, no online payment gateway tested.
- No WooCommerce product defect was found in this project.
What you can take from this: when you cannot reproduce a failure, add a way to catch it, test that the catcher works, and write the cause down as unknown rather than guessing.