Closed (outdated)
Project:
Drupal core
Version:
6.x-dev
Component:
locale.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 May 2011 at 11:28 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
damien tournoud commentedThis function caches two things in the DB: strings less then 75 characters and non-translated strings. I'm not completely sure what you are trying to fix here.
Comment #2
teefax commentedOK, let me describe what I'm seeing here (I'm the server admin trying to make the site faster):
- Drupal 6.20 / 6.x
- Cacheing happens with memcache.module
- Site is set to 'de' language by default and there are quite some things which are not translated in the DB
On first page load:
- all existing translations are loaded, including the untranslated strings (locale.module line 360)
SQL: SELECT s.source, t.translation, t.language FROM locales_source s LEFT JOIN locales_target t ON s.lid = t.lid AND t.language = 'de' WHERE s.textgroup = 'default' AND s.version = '6.20' AND LENGTH(s.source) < 75so untranslated strings come in with translation==NULL.
This whole result set is correctly cached (in memcache and $locale_t).
- then
locale()is asked for a string which is not translated. the$locale_tstatic variable is checked, and since the DB returned NULL, the isset in locale.module line 371 evals to true, so the DB is queried again for the string.- The translation is found(
if ($translation) {== true in line 375) but the translation value is still NULL.-
TRUEis saved for the translation in the static$locale_tvariable. But the change is not pushed through to the cache layer.- the
locale()function returns the untranslated string.On the next page load, the
$locale_tstatic variable is filled from the cache layer (no DB hit) -- but the cache layer does not contain theTRUEfor the untranslated string.When
locale()is asked for the same untranslated string as above, it has to hit the database again. And again.The patch stores the
TRUEvalue in the cache layer, so that on the next page load, thelocale()call for the untranslated string does not hit the DB.This removes some 100 DB calls on some of our pages (which have quite a bit of untranslated strings, yes).
I have not found out if updating a translation will invalidate the cache automatically -- otherwise there might be some work needed there, too)
(attached newer patch is in better format and against 6.x-dev)
Comment #3
damien tournoud commentedNo, they are transformed into TRUE before being saved.
Comment #4
teefax commentedHello,
you're right, I missed that transformation -- but: without my patch there were still many invocations of
on every page load (same page, multiple reloads).
I will take a deeper look on what is happening on monday and will get back to you with what I find.
Comment #5
teefax commentedHello,
so, I had some time to look into why I'm seeing less queries with my patch applied -- the strings which were queried on each page load were all longer than 75 characters and so they were not loaded in the initial
.
So the translations for strings longer than 75 characters are loaded on each page load.
My patch caches the result of those queries, too -- so with my patch applied, the translations for those strings are cached when the DB is queried anyway.