Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Empty txp_lang items cause load_lang_event to fail
Playing with Textpacks, installed a bunch of languages on a test site (all of them, in fact), and noticed that the correct Textpack would not load for a few languages. (I am using load_lang_event()
to load the Textpack.) The problem is that an empty (no name) item in txp_lang causes load_lang_event()
to think that the language is not installed, so it defaults to en-gb.
A possible safeguard would be to patch load_lang_event()
:
$HeadURL: https://textpattern.googlecode.com/svn/releases/4.3.0/source/textpattern/lib/txplib_misc.php $
$LastChangedRevision: 3437 $
...
259 $installed = safe_field('name', 'txp_lang',"lang='".doSlash($lang)."' AND name != '' limit 1");
Code is topiary
Offline
#2 2011-01-16 22:24:38
- Themroc
- Plugin Author
- From: Germany
- Registered: 2011-01-02
- Posts: 23
Re: Empty txp_lang items cause load_lang_event to fail
Another one would be:
$installed = safe_field(‘lastmod’, ‘txp_lang’, “lang=’”.doSlash($lang).”’ limit 1”);
History teaches us that history teaches us nothing. — Voltaire
Offline
Re: Empty txp_lang items cause load_lang_event to fail
Yes, from the small sample of blank entries I have, that would work. As would
$installed = safe_field(‘id’, ‘txp_lang’, “lang=’”.doSlash($lang).”’ limit 1”);
or
$installed = safe_field(‘lang’, ‘txp_lang’, “lang=’”.doSlash($lang).”’ limit 1”);
Code is topiary
Offline
Re: Empty txp_lang items cause load_lang_event to fail
Thanks Jeff. This now is issue 99. I have commited change set 3472 as a first barrier for such data to enter the app. Please try and report back.
We’ll need to apply further measures on the RPC server to avoid the introduction of invalid language data in the first place.
Offline
#5 2011-01-17 07:57:45
- Themroc
- Plugin Author
- From: Germany
- Registered: 2011-01-02
- Posts: 23
Re: Empty txp_lang items cause load_lang_event to fail
Patch to skip the bad records before they enter the db:
diff -Naurb -x '*~' txp-4.x-r3471/textpattern/include/txp_prefs.php txp/textpattern/include/txp_prefs.php --- txp-4.x-r3471/textpattern/include/txp_prefs.php 2011-01-17 08:18:40.000000000 +0100 +++ txp/textpattern/include/txp_prefs.php 2011-01-10 11:32:31.000000000 +0100 @@ -933,6 +933,8 @@ $lang_struct = unserialize($response); function install_lang_key(&$value, $key) { + if (empty($value['name'])) + { $value['ok'] = 1; return; } extract(gpsa(array('lang_code','updating'))); $exists = safe_field('name','txp_lang',"name='".doSlash($value['name'])."' AND lang='".doSlash($lang_code)."'"); $q = "name='".doSlash($value['name'])."', event='".doSlash($value['event'])."', data='".doSlash($value['data'])."', lastmod='".doSlash(strftime('%Y%m%d%H%M%S',$value['uLastmod']))."'";
History teaches us that history teaches us nothing. — Voltaire
Offline
Re: Empty txp_lang items cause load_lang_event to fail
wet wrote:
I have commited change set 3472 as a first barrier for such data to enter the app. Please try and report back.
Thanks Robert — that fixes the issue for the three cases I have to test. (They are, BTW, de-de, bs-ba, and fa-ir.)
select * from txp_lang where name = ''
3367 de-de 2010-11-14 00:36:08
7442 bs-ba common 2008-05-21 17:03:06
13942 fa-ir tag 2010-08-24 02:57:02
Code is topiary
Offline