November 2026 · ~9 min read · WordPress, Elementor, Apache/PHP-FPM, MySQL
Same page, same editor action. Only the stored revision history changed.
I was brought in to diagnose and fix a run of production and staging incidents on a high-traffic WordPress marketing site, built with Elementor Pro, running on Apache with PHP 8.3 (PHP-FPM in production, mod_php in staging) over MySQL, with Seraphinite Accelerator and Autoptimize for caching behind Cloudflare, and Wordfence for security. There was no staging-to-production pipeline. Every change was manual, file by file, which raised the cost of being wrong and made disciplined diagnosis worth more than speed. I worked at the server level over SSH and SFTP, with WP-CLI for the database and WordPress internals, and verified front-end behaviour in a real browser.
Problem 1: a 500 on save that was not about memory
The site's heaviest page threw a 500 every single time it was saved in the Elementor editor. Someone had already raised the PHP worker pool and input-variable limits with no effect. Editors could not publish any change to the most important page on the site.
The editor's save is an admin-ajax.php call, and it was dying with "Allowed memory size exhausted." The obvious response is to raise PHP's memory_limit, so I did, from 128 MB to 1 GB, and proved with a controlled allocation test that the new ceiling was genuinely in effect for web requests. The save still failed, now exhausting a full 2 GB.
The signal in that failure
When raising a limit makes the symptom scale up instead of disappear, the resource is not the bottleneck. Something was consuming memory without bound, so any ceiling would be hit eventually.
Rather than keep guessing, I wrote a small sampling profiler in PHP and attached it to a real reproduction of the save from the command line. It used pcntl_async_signals with a one-second SIGALRM timer that dumps debug_backtrace() to a file on each tick, so I could capture the call stack mid-blow-up without a debugger extension. I ran the actual document save under a controlled memory cap, and the deepest stack was unambiguous:
wp_save_post_revision
-> wp_get_post_revisions
-> get_children -> WP_Query
-> update_postmeta_cache
-> wpdb::get_results (loading the full builder payload for EVERY revision)
A one-second SIGALRM tick dumped the call stack while memory was climbing. The cause was the stack, not the size.
The page had accumulated 963 stored revisions, because the revision limit was set to unlimited. On every save, WordPress was loading all 963 revisions and their complete page-builder payloads into memory at once. That is what ballooned past 2 GB. Two things followed once I saw the stack: the memory bump never stood a chance, because the revision load exceeds any reasonable ceiling; and capping the revision limit alone could not bootstrap a fix either, because the save dies before it reaches the step that would prune old revisions. The pile has to be cleared first, by hand.
The fix. Prune the revision history down to the most recent handful with wp_delete_post_revision() (which by construction only ever deletes revisions, never the live page), set a small explicit revision cap in configuration so the history cannot build up again on any page, then re-test the real save under a tight memory cap and confirm in the live editor. Stored revisions went from 963 to 8, memory peak on save from ~1.47 GB and a crash to ~0.21 GB, and the editor save from HTTP 500 to 200.
I verified it the honest way: I opened the page in the real editor, triggered an actual save, watched the admin-ajax save calls return 200, and confirmed the editor cleared its own "unsaved changes" flag, which the builder only does after a save truly succeeds.
The underlying page is genuinely heavy, so the revision cap treats the symptom very well but the page itself deserves slimming. The cap is global now, so every page is protected from the same pile-up, which is the right place to draw the line. The one-line lesson: the fastest wrong answer was "add memory." A ten-line sampling profiler turned a guess into a one-line root cause, and that pointed at a one-command fix.
Problem 2: tracking scripts that disappeared for real visitors but not for me
The HubSpot tracking script, and a small first-party script that persists UTM and gclid values across pages, were present in the page source when I was logged in, and completely absent in an incognito window. If the tracking tag is missing for logged-out users, analytics and ad attribution are silently broken for every real visitor, while looking perfectly fine to whoever is logged in and checking.
"It works when I am logged in" is the classic false comfort. Logged-in users bypass the page cache and see the raw, unoptimised head output; anonymous visitors get the cached, optimised HTML. The two are different documents. I fetched the anonymous page over the server loopback, which gives the exact bytes a visitor receives, and the tracking script was nowhere in it. Instead of stopping at "it was stripped," I followed the caching plugin's own combined and optimised JavaScript bundle and searched inside it. The script was there, combined and deferred behind a "load on interaction" marker (type="o/js-lzl"). It had not been dropped, it had been lazy-loaded, which for a tracking pixel is almost as bad: a visitor who bounces before scrolling or clicking is never counted.
One exclusion rule in the caching plugin, verified on the anonymous cached page after a full purge.
The fix and the decision behind it. A combine-and-lazy-load optimiser is correct for non-critical JavaScript and wrong for a tracking tag that must fire on page load. So the right move is to scope the optimiser with an exclusion, not to switch optimisation off and lose the win everywhere else. I added the tracking host to the plugin's JavaScript exclusion list with a single targeted rule, then confirmed by re-fetching the anonymous page after a full cache purge and checking that the tag's type had reverted to text/javascript across several different page types.
Whether the tag actually fires at runtime still depends on the third-party endpoint being reachable and the visitor not running a tracker blocker, which is outside the site's control. The fix guarantees the tag is delivered eagerly; it cannot guarantee a blocked browser will run it.
Problem 3: a reviews widget that rendered an empty shell
A third-party reviews widget showed its full rating and carousel inside the editor and in the plugin's own settings preview, but rendered "0 reviews" and an empty slider on the live front end. The page embedded the widget through Elementor's "global widget" mechanism, and the referenced global widget had at some point been restored with the wrong shortcode: a look-alike custom shortcode that renders the widget's outer shell but pulls no data, instead of the plugin's real shortcode that holds the rating data.
Comparing the rendered DOM between a working environment and the broken one showed two different CSS class prefixes on the output. That pinned the cause to a shortcode mismatch rather than a data outage or a cache miss, because those would have produced the same markup with no entries, not a different markup entirely. The fix was a byte-safe, in-place string swap of the shortcode inside the widget's stored builder data. Working in place, rather than re-encoding the Elementor JSON, avoids the slash-escaping corruption that re-encoding introduces, and because the widget is global, that one change restored the reviews everywhere it is used.
Copying Elementor global widgets between environments is exactly what corrupts these references in the first place. A self-referential version of the same widget had earlier caused an infinite render loop, so I now treat global widgets as a known fragility and prefer plain shortcode widgets for third-party embeds.
Also handled, in brief
- A self-referential Elementor global widget caused site-wide 503s. The corrupted widget referenced itself, sending the renderer into an infinite loop that fired thousands of revision and autosave lookups per second and saturated MySQL. I isolated it from the slow-query and stack-trace evidence, and added a defensive must-use plugin that neutralises any self-referential global widget on the front end, so the same class of corruption cannot take the site down again.
- Working around the environment, not against it. With no staging-to-production automation, an aggressive bot-challenge mode that also blocked the platform's own loopback health checks (which makes the built-in file editor silently revert PHP changes), and file ownership that blocked some SFTP writes, I handled each on its own terms: server-level edits guarded by a syntax check and a graceful reload, loopback testing with the correct host header, and WP-CLI for anything the UI could not safely do.
The outcome
The heavy page saves again, with memory use on save down from a 2 GB crash to about 210 MB. Tracking fires for anonymous visitors across the whole site. The reviews widget renders its data on every page that uses it. And the site is defended against the recursion class of failure that had been causing the outages in the first place. The thread running through all of it: resist the quick resource-bump reflex, reproduce the failure under controlled conditions, let the evidence name the cause, and then verify the fix the same way a real user would experience it.