Skip to content

Pattern Translations: Clear runtime caches after each locale - #784

Merged
obenland merged 1 commit into
trunkfrom
fix/translation-import-memory
Oct 5, 2026
Merged

obenland merged 1 commit into
trunkfrom
fix/translation-import-memory

Conversation

@obenland

@obenland obenland commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

pattern_import_translations_to_directory has a handful of chunks that fail on every run with Allowed memory size of 536870912 bytes exhausted in object-cache.php. The failures follow specific patterns as chunk boundaries shift, and several die allocating 2.5MB, which is a hash table resize of the runtime cache. So the cache is outgrowing the limit while one pattern is being processed across all locales, before the per-pattern cleanup ever runs.

  • Clear the runtime caches after each locale instead of after each pattern.
  • Use wp_cache_flush_runtime() instead of resetting object cache internals. This also fixes the Creation of dynamic property WPORG_Object_Cache::$memcache_debug deprecation notice on every run.
  • Log each pattern ID via error_log() when running in cron. Cavalcade doesn't capture WP_CLI::log() output, so there's currently no way to tell which pattern a failing chunk dies on.

Not verified against a live run. If a chunk still fails, the new log line names the pattern.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated background translation imports to record pattern details in server logs and manage runtime memory and cache state differently.
    • No user-facing changes are noted.

Some patterns exhaust the 512M memory limit while being processed across
all locales, so the chunks containing them fail on every run. Clear the
runtime caches after each locale rather than after each pattern.

Use wp_cache_flush_runtime() rather than resetting object cache internals,
which also avoids the deprecation notice for the removed `memcache_debug`
property. Log each pattern ID when running in cron, as WP_CLI::log()
output isn't captured by Cavalcade.
Copilot AI balanced review requested due to automatic review settings October 5, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4bf8c1a7-b2bd-43df-b42c-c9dc891ef8b5
📥 Commits

Reviewing files that changed from the base of the PR and between f16599c and f728d98.

📒 Files selected for processing (1)
  • public_html/wp-content/plugins/pattern-translations/includes/cron.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The cron translation import now logs each pattern ID and name. It clears memory-heavy variables after each locale and uses wp_cache_flush_runtime() during cleanup.

Changes

Translation import cron

Layer / File(s) Summary
Cron logging and memory cleanup
public_html/wp-content/plugins/pattern-translations/includes/cron.php
The cron import logs the current pattern ID and name. It clears memory-heavy variables after each locale and calls wp_cache_flush_runtime() during cleanup.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f728d

No actionable merge-blocking issue is established by the reviewed changes.

Architecture Summary

Architecture risk: 🔵 Low · up to f728d

The change affects 1 system.

Changed systems: public_html

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — public_html (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in public_html/wp-content/plugins/pattern-translations/includes/cron.php: When running in cron, the import logs the current pattern ID and name to the server error log.
  • observed — Modified behavior in public_html/wp-content/plugins/pattern-translations/includes/cron.php: Memory-heavy variables are now cleared after each locale instead of once after all locales for each pattern.
  • observed — Modified behavior in public_html/wp-content/plugins/pattern-translations/includes/cron.php: clear_memory_heavy_variables() no longer declares $wp_object_cache or manually resets its cache and tracking arrays; it flushes the runtime cache after clearing $wpdb->queries.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: clearing runtime caches after each locale.
Description check ✅ Passed The description explains the problem, the changes, and the reason for them. It notes that the change was not verified in a live run. It does not include issue references, contributor credits, or numbe…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@obenland
obenland merged commit 21252e9 into trunk Oct 5, 2026
5 checks passed
@obenland
obenland deleted the fix/translation-import-memory branch October 5, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants