Hello!
Here is another piece of code, which is very common for the current eGW 1.4
code base.
With every page request, the accounts class constructor get’s executed at
least 2 times. When an userselection box get’s displayed too, it get’s
executed 3 times. Everytime the constructor get’s executed, also the
accounts_backend class constructor get’s executed again. If you are using
the ldap accounts backend, you connected now 3 times to the ldap server. But
one connection would have been enough.
How to avoid this?
Add a singleton to the accounts class. The singleton makes sure the the
class get’s instanciated only once. Which means also only 1 ldap connection.
The singleton pattern is already possible with PHP4. But only with PHP5 you
can enforce the usage of the singleton pattern by declaring the construtor
of a class private.
The old way eGW style was to define a global variable.
I’ll commit a patch to SVN which fixes this problem at least for the
accounts class.
Tine 2.0 is using singleton patterns for mostly all classes.
Lars Kneschke
CTO OfficeSpot.Net
Metaways Infosystems GmbH
Pickhuben 2-4, D-20457 Hamburg
eGroupWare Support: http://www.egroupware-support.net
OfficeSpot.Net Collaboration Server: http://cs.officespot.net
our proposal for the next major eGroupWare release: http://www.tine20.org
E-Mail: mailto:l.kneschke@metaways.de
Web: http://www.metaways.de
Tel: +49 (0)40 317031-21
Fax: +49 (0)40 317031-921
Mobile: +49 (0)175 9304324
Metaways Infosystems GmbH - Sitz: D-22967 Tremsbüttel
Handelsregister: Amtsgericht Ahrensburg HRB 4508
Geschäftsführung: Hermann Thaele, Lüder-H.Thaele