Opened 11 months ago

Last modified 6 weeks ago

#208 accepted defect

String counts caching issues

Reported by: dimadin Owned by: markoheijnen
Priority: normal Milestone: 1.0
Component: Cache Version:
Keywords: has-patch Cc:

Description

After numerous reports on WP Polyglots, I've looked into the GlotPress code to see what and where we're caching and when that cache is cleared.

There are two caches that we have and that affect us: active_originals_count_by_project_id which is a number of active strings in a project, and translation_set_status_breakdown, which is per translation set cache that contains counts of each status of string except of untranslated strings.

First cache is cleared when originals are imported into the project and that is fine. Second cache is cleared when new translation is added but there are actions that don't clear cache and I believe this is what is causing problems.

Translation set's cache isn't cleared when single string translation status is changed, when originals are imported, and when translation set is copied from another. Second case is responsible for weird numbers like negative number of untranslated strings. (this probably happens when approved strings become obsolete during import of originals: in that process count of total strings is refreshed while count of untranslated strings is dynamically generated as difference between total strings (from clean cache) and count of translated strings (from old cache), and if there is larger number of translated strings in old cache than new number of total strings, we get negative number)

So I suggest that we clear translation set's cache in functions I linked above.

Thoughts?

Attachments (1)

gp_cache_fix.patch (6.6 KB) - added by dimadin 10 months ago.

Download all attachments as: .zip

Change History (5)

  • Keywords has-patch added

I created a patch. It doesn't just include cache cleaning on missing places, but it also moves all cleaning to hooks. Why? Because that way other tools can benefit too. For example, on wp.org we can have a plugin that will clean language packages when changes are made. Or there can be notification plugin when actions are made etc.

Not tested with object cache enabled.

  • Milestone set to 1.0
  • Component changed from performance to Cache

Will be looking into this after WordSesh?.

  • Owner set to markoheijnen
  • Status changed from new to accepted
Note: See TracTickets for help on using tickets.