phplist

NOTE:: Before reporting an issue, make sure you are running the latest version, currently 3.3.1


View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015654phplist applicationInternationalization (l18n)public01-12-11 12:4030-05-12 22:21
Reporterduncanc 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version2.10.16 
Target Version4.0.xFixed in Version2.11.7 
Summary0015654: Unnecessary multiple including of language files
DescriptionI installed the APC (Alternative PHP Cache) extension to see what effect on response times it would have and as a side effect found that the language files are included not just once but on every call to the phplist_I18N class get method.
APC shows the number of times each file is included/required and showed these results:

to display the home page once:
included en/home.php 84 times
included en/common.php 38 times

to display the users page once:
included en/users.php 114 times
included en/common.php 39 times

Although phplist 'is fast enough' it seems a good idea reduce the number of times each file is included.
My proposed solution is to load the language file for the page, and the common and frontend language files in the constructor instead of in the get() method. Additionally, to accumulate the files into a single array so simplifying the lookup processing in get().

Attached is a modified languages.php, taken from the 2.10.17 release.
The changes are only to the phplist_I18N class:
1) added instance variable $this->lan, which is set in the constructor and read in the get() method
2) moved the loading of the languages files from the get() method to the constructor, into a single array $this->lan
3) simplified the lookup of the text in the get() method

The lookup logic, initially in the page file then falling through to the common file, then to the front-end file, has been replaced by merging the files into a single array.
The lookup logic of the text, then the lowercased text, then the uppercased text is unchanged.
TagsNo tags attached.
Attached Files? file icon languages.new.php [^] (6,443 bytes) 29-01-12 19:37

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0051437)
duncanc (developer)
29-01-12 19:39

I have added the modified languages.php that I refer to in the original description. When I originally added the issue, adding attachments seemed to be broken.
(0051459)
michiel (manager)
10-02-12 14:26

Hmm, the main issue with this is that each term is looked up differently.

eg, one term in a page may be in lan/[iso]/page.php and the other in lan/[iso]/common.php

I'm redoing the translation system to use the gettext method, and this should be included.
(0051460)
duncanc (developer)
10-02-12 16:32

The current code looks-up a term in the order - the 'page' file, then the 'common' file, and then the 'front-end' file.

My change loads the files in the same order into a single array, so a term should be found from the 'page' file if it is present there, otherwise found from the 'common' file if present there, and finally from the 'front-end' file if present there.
If a term appears in more than one file then the earlier takes precedence.
(0051461)
michiel (manager)
10-02-12 16:40

ah, yes, of course, good point
(0051652)
michiel (manager)
30-05-12 22:21

the language.php file had changed a lot in the meantime, but I've incorporated your changes manually.

http://phplist.svn.sourceforge.net/phplist/?rev=3267&view=rev [^]


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker