Commit dc45eac0c3e08814ce82796dc6bba083578ae41c
1 parent
6ddf052b
KTS-2386
"Add some basic plugin caching to improve performance" Updated. KTS-2358 impacted on the caching array that is required to cache. Thus the singleton() methods are restored to what they were before. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7271 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
15 changed files
with
55 additions
and
85 deletions
lib/actions/actionregistry.inc.php
| @@ -33,12 +33,11 @@ class KTActionRegistry { | @@ -33,12 +33,11 @@ class KTActionRegistry { | ||
| 33 | var $actions = array(); | 33 | var $actions = array(); |
| 34 | 34 | ||
| 35 | static function &getSingleton () { | 35 | static function &getSingleton () { |
| 36 | - static $singleton=null; | ||
| 37 | - if (is_null($singleton)) | 36 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTActionRegistry')) |
| 38 | { | 37 | { |
| 39 | - $singleton = new KTActionRegistry(); | 38 | + $GLOBALS['_KT_PLUGIN']['oKTActionRegistry'] = new KTActionRegistry; |
| 40 | } | 39 | } |
| 41 | - return $singleton; | 40 | + return $GLOBALS['_KT_PLUGIN']['oKTActionRegistry']; |
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | function registerAction($slot, $name, $nsname, $path = '', $sPlugin = null) { | 43 | function registerAction($slot, $name, $nsname, $path = '', $sPlugin = null) { |
lib/authentication/authenticationproviderregistry.inc.php
| @@ -55,12 +55,10 @@ class KTAuthenticationProviderRegistry { | @@ -55,12 +55,10 @@ class KTAuthenticationProviderRegistry { | ||
| 55 | var $_aAuthenticationProviders = array(); | 55 | var $_aAuthenticationProviders = array(); |
| 56 | 56 | ||
| 57 | static function &getSingleton () { | 57 | static function &getSingleton () { |
| 58 | - static $singleton=null; | ||
| 59 | - if (is_null($singleton)) | ||
| 60 | - { | ||
| 61 | - $singleton = new KTAuthenticationProviderRegistry(); | ||
| 62 | - } | ||
| 63 | - return $singleton; | 58 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTAuthenticationProviderRegistry')) { |
| 59 | + $GLOBALS['_KT_PLUGIN']['oKTAuthenticationProviderRegistry'] = new KTAuthenticationProviderRegistry; | ||
| 60 | + } | ||
| 61 | + return $GLOBALS['_KT_PLUGIN']['oKTAuthenticationProviderRegistry']; | ||
| 64 | } | 62 | } |
| 65 | 63 | ||
| 66 | 64 |
lib/authentication/interceptorregistry.inc.php
| @@ -44,12 +44,10 @@ class KTInterceptorRegistry { | @@ -44,12 +44,10 @@ class KTInterceptorRegistry { | ||
| 44 | var $_aInterceptorsInfo = array(); | 44 | var $_aInterceptorsInfo = array(); |
| 45 | 45 | ||
| 46 | static function &getSingleton () { | 46 | static function &getSingleton () { |
| 47 | - static $singleton=null; | ||
| 48 | - if (is_null($singleton)) | ||
| 49 | - { | ||
| 50 | - $singleton = new KTInterceptorRegistry(); | 47 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTInterceptorRegistry')) { |
| 48 | + $GLOBALS['_KT_PLUGIN']['oKTInterceptorRegistry'] = new KTInterceptorRegistry; | ||
| 51 | } | 49 | } |
| 52 | - return $singleton; | 50 | + return $GLOBALS['_KT_PLUGIN']['oKTInterceptorRegistry']; |
| 53 | } | 51 | } |
| 54 | 52 | ||
| 55 | function registerInterceptor($class, $nsname, $path = '', $sPlugin = null) { | 53 | function registerInterceptor($class, $nsname, $path = '', $sPlugin = null) { |
lib/browse/columnregistry.inc.php
| @@ -37,12 +37,10 @@ class KTColumnRegistry { | @@ -37,12 +37,10 @@ class KTColumnRegistry { | ||
| 37 | var $views = array(); // should be in here | 37 | var $views = array(); // should be in here |
| 38 | // {{{ getSingleton | 38 | // {{{ getSingleton |
| 39 | static function &getSingleton () { | 39 | static function &getSingleton () { |
| 40 | - static $singleton = null; | ||
| 41 | - if (is_null($singleton)) | ||
| 42 | - { | ||
| 43 | - $singleton = new KTColumnRegistry; | ||
| 44 | - } | ||
| 45 | - return $singleton; | 40 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTColumnRegistry')) { |
| 41 | + $GLOBALS['_KT_PLUGIN']['oKTColumnRegistry'] =& new KTColumnRegistry; | ||
| 42 | + } | ||
| 43 | + return $GLOBALS['_KT_PLUGIN']['oKTColumnRegistry']; | ||
| 46 | } | 44 | } |
| 47 | // }}} | 45 | // }}} |
| 48 | 46 |
lib/browse/criteriaregistry.php
| @@ -34,12 +34,10 @@ class KTCriteriaRegistry { | @@ -34,12 +34,10 @@ class KTCriteriaRegistry { | ||
| 34 | var $_bGenericRegistered = false; | 34 | var $_bGenericRegistered = false; |
| 35 | 35 | ||
| 36 | static function &getSingleton () { | 36 | static function &getSingleton () { |
| 37 | - static $singleton=null; | ||
| 38 | - if (is_null($singleton)) | ||
| 39 | - { | ||
| 40 | - $singleton = new KTCriteriaRegistry(); | ||
| 41 | - } | ||
| 42 | - return $singleton; | 37 | + if (!KTUtil::arrayGet($GLOBALS['_KT_CRITERIA'], 'oKTCriteriaRegistry')) { |
| 38 | + $GLOBALS['_KT_CRITERIA']['oKTCriteriaRegistry'] = new KTCriteriaRegistry; | ||
| 39 | + } | ||
| 40 | + return $GLOBALS['_KT_CRITERIA']['oKTCriteriaRegistry']; | ||
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | 43 |
lib/dashboard/NotificationRegistry.inc.php
| @@ -35,12 +35,10 @@ class KTNotificationRegistry { | @@ -35,12 +35,10 @@ class KTNotificationRegistry { | ||
| 35 | var $notification_instances = array(); | 35 | var $notification_instances = array(); |
| 36 | 36 | ||
| 37 | static function &getSingleton () { | 37 | static function &getSingleton () { |
| 38 | - static $singleton=null; | ||
| 39 | - if (is_null($singleton)) | ||
| 40 | - { | ||
| 41 | - $singleton = new KTNotificationRegistry(); | 38 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTNotificationRegistry')) { |
| 39 | + $GLOBALS['_KT_PLUGIN']['oKTNotificationRegistry'] = new KTNotificationRegistry; | ||
| 42 | } | 40 | } |
| 43 | - return $singleton; | 41 | + return $GLOBALS['_KT_PLUGIN']['oKTNotificationRegistry']; |
| 44 | } | 42 | } |
| 45 | 43 | ||
| 46 | 44 |
lib/dashboard/dashletregistry.inc.php
| @@ -35,12 +35,10 @@ class KTDashletRegistry { | @@ -35,12 +35,10 @@ class KTDashletRegistry { | ||
| 35 | var $nsnames = array(); | 35 | var $nsnames = array(); |
| 36 | 36 | ||
| 37 | static function &getSingleton () { | 37 | static function &getSingleton () { |
| 38 | - static $singleton=null; | ||
| 39 | - if (is_null($singleton)) | ||
| 40 | - { | ||
| 41 | - $singleton = new KTDashletRegistry(); | 38 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTDashboardRegistry')) { |
| 39 | + $GLOBALS['_KT_PLUGIN']['oKTDashboardRegistry'] = new KTDashletRegistry; | ||
| 42 | } | 40 | } |
| 43 | - return $singleton; | 41 | + return $GLOBALS['_KT_PLUGIN']['oKTDashboardRegistry']; |
| 44 | } | 42 | } |
| 45 | 43 | ||
| 46 | 44 |
lib/i18n/i18nregistry.inc.php
| @@ -38,12 +38,10 @@ class KTi18nRegistry { | @@ -38,12 +38,10 @@ class KTi18nRegistry { | ||
| 38 | var $_aLanguages = array(); | 38 | var $_aLanguages = array(); |
| 39 | 39 | ||
| 40 | static function &getSingleton() { | 40 | static function &getSingleton() { |
| 41 | - static $singleton = null; | ||
| 42 | - if (is_null($singleton)) | ||
| 43 | - { | ||
| 44 | - $singleton = new KTi18nRegistry; | ||
| 45 | - } | ||
| 46 | - return $singleton; | 41 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTi18nRegistry')) { |
| 42 | + $GLOBALS['_KT_PLUGIN']['oKTi18nRegistry'] =& new KTi18nRegistry; | ||
| 43 | + } | ||
| 44 | + return $GLOBALS['_KT_PLUGIN']['oKTi18nRegistry']; | ||
| 47 | } | 45 | } |
| 48 | 46 | ||
| 49 | function registeri18n($sDomain, $sDirectory) { | 47 | function registeri18n($sDomain, $sDirectory) { |
lib/plugins/KTAdminNavigation.php
| @@ -38,12 +38,10 @@ class KTAdminNavigationRegistry { | @@ -38,12 +38,10 @@ class KTAdminNavigationRegistry { | ||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | static function &getSingleton () { | 40 | static function &getSingleton () { |
| 41 | - static $singleton=null; | ||
| 42 | - if (is_null($singleton)) | ||
| 43 | - { | ||
| 44 | - $singleton = new KTAdminNavigationRegistry(); | 41 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTAdminNavigationRegistry')) { |
| 42 | + $GLOBALS['_KT_PLUGIN']['oKTAdminNavigationRegistry'] = new KTAdminNavigationRegistry; | ||
| 45 | } | 43 | } |
| 46 | - return $singleton; | 44 | + return $GLOBALS['_KT_PLUGIN']['oKTAdminNavigationRegistry']; |
| 47 | } | 45 | } |
| 48 | 46 | ||
| 49 | // name is the suburl below admin | 47 | // name is the suburl below admin |
lib/plugins/pageregistry.inc.php
| @@ -33,12 +33,10 @@ class KTPageRegistry { | @@ -33,12 +33,10 @@ class KTPageRegistry { | ||
| 33 | var $aResources = array(); | 33 | var $aResources = array(); |
| 34 | 34 | ||
| 35 | static function &getSingleton () { | 35 | static function &getSingleton () { |
| 36 | - static $singleton=null; | ||
| 37 | - if (is_null($singleton)) | ||
| 38 | - { | ||
| 39 | - $singleton = new KTPageRegistry(); | ||
| 40 | - } | ||
| 41 | - return $singleton; | 36 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTPageRegistry')) { |
| 37 | + $GLOBALS['_KT_PLUGIN']['oKTPageRegistry'] = new KTPageRegistry; | ||
| 38 | + } | ||
| 39 | + return $GLOBALS['_KT_PLUGIN']['oKTPageRegistry']; | ||
| 42 | } | 40 | } |
| 43 | 41 | ||
| 44 | function registerPage($sPath, $sClassName, $sFilename = null) { | 42 | function registerPage($sPath, $sClassName, $sFilename = null) { |
lib/plugins/pluginregistry.inc.php
| @@ -34,12 +34,10 @@ class KTPluginRegistry { | @@ -34,12 +34,10 @@ class KTPluginRegistry { | ||
| 34 | var $_aPlugins = array(); | 34 | var $_aPlugins = array(); |
| 35 | 35 | ||
| 36 | static function &getSingleton() { | 36 | static function &getSingleton() { |
| 37 | - static $singleton = null; | ||
| 38 | - if (is_null($singleton)) | ||
| 39 | - { | ||
| 40 | - $singleton = new KTPluginRegistry; | ||
| 41 | - } | ||
| 42 | - return $singleton; | 37 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTPluginRegistry')) { |
| 38 | + $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry'] = new KTPluginRegistry; | ||
| 39 | + } | ||
| 40 | + return $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry']; | ||
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | function registerPlugin($sClassName, $sNamespace, $sFilename = null) { | 43 | function registerPlugin($sClassName, $sNamespace, $sFilename = null) { |
lib/templating/templating.inc.php
| @@ -122,13 +122,10 @@ class KTTemplating { | @@ -122,13 +122,10 @@ class KTTemplating { | ||
| 122 | 122 | ||
| 123 | // {{{ getSingleton | 123 | // {{{ getSingleton |
| 124 | static function &getSingleton () { | 124 | static function &getSingleton () { |
| 125 | - static $singleton = null; | ||
| 126 | - | ||
| 127 | - if (is_null($singleton)) | ||
| 128 | - { | ||
| 129 | - $singleton = new KTTemplating(); | ||
| 130 | - } | ||
| 131 | - return $singleton; | 125 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTTemplating')) { |
| 126 | + $GLOBALS['_KT_PLUGIN']['oKTTemplating'] = new KTTemplating; | ||
| 127 | + } | ||
| 128 | + return $GLOBALS['_KT_PLUGIN']['oKTTemplating']; | ||
| 132 | } | 129 | } |
| 133 | // }}} | 130 | // }}} |
| 134 | 131 |
lib/triggers/triggerregistry.inc.php
| @@ -33,12 +33,10 @@ class KTTriggerRegistry { | @@ -33,12 +33,10 @@ class KTTriggerRegistry { | ||
| 33 | var $triggers = array(); | 33 | var $triggers = array(); |
| 34 | // {{{ getSingleton | 34 | // {{{ getSingleton |
| 35 | static function &getSingleton () { | 35 | static function &getSingleton () { |
| 36 | - static $singleton=null; | ||
| 37 | - if (is_null($singleton)) | ||
| 38 | - { | ||
| 39 | - $singleton = new KTTriggerRegistry(); | ||
| 40 | - } | ||
| 41 | - return $singleton; | 36 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTTriggerRegistry')) { |
| 37 | + $GLOBALS['_KT_PLUGIN']['oKTTriggerRegistry'] = new KTTriggerRegistry; | ||
| 38 | + } | ||
| 39 | + return $GLOBALS['_KT_PLUGIN']['oKTTriggerRegistry']; | ||
| 42 | } | 40 | } |
| 43 | // }}} | 41 | // }}} |
| 44 | 42 |
lib/widgets/widgetfactory.inc.php
| @@ -39,12 +39,10 @@ class KTWidgetFactory { | @@ -39,12 +39,10 @@ class KTWidgetFactory { | ||
| 39 | var $widgets = array(); | 39 | var $widgets = array(); |
| 40 | 40 | ||
| 41 | static function &getSingleton () { | 41 | static function &getSingleton () { |
| 42 | - static $singleton=null; | ||
| 43 | - if (is_null($singleton)) | ||
| 44 | - { | ||
| 45 | - $singleton = new KTWidgetFactory(); | ||
| 46 | - } | ||
| 47 | - return $singleton; | 42 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTWidgetFactory')) { |
| 43 | + $GLOBALS['_KT_PLUGIN']['oKTWidgetFactory'] = new KTWidgetFactory; | ||
| 44 | + } | ||
| 45 | + return $GLOBALS['_KT_PLUGIN']['oKTWidgetFactory']; | ||
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | function registerWidget($sClassname, $sNamespace, $sFilename = null) { | 48 | function registerWidget($sClassname, $sNamespace, $sFilename = null) { |
lib/workflow/workflowutil.inc.php
| @@ -843,12 +843,10 @@ class KTWorkflowTriggerRegistry { | @@ -843,12 +843,10 @@ class KTWorkflowTriggerRegistry { | ||
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | static function &getSingleton () { | 845 | static function &getSingleton () { |
| 846 | - static $singleton=null; | ||
| 847 | - if (is_null($singleton)) | ||
| 848 | - { | ||
| 849 | - $singleton = new KTWorkflowTriggerRegistry(); | ||
| 850 | - } | ||
| 851 | - return $singleton; | 846 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTWorkflowTriggerRegistry')) { |
| 847 | + $GLOBALS['_KT_PLUGIN']['oKTWorkflowTriggerRegistry'] = new KTWorkflowTriggerRegistry; | ||
| 848 | + } | ||
| 849 | + return $GLOBALS['_KT_PLUGIN']['oKTWorkflowTriggerRegistry']; | ||
| 852 | } | 850 | } |
| 853 | 851 | ||
| 854 | function registerWorkflowTrigger($sNamespace, $sClassname, $sPath) { | 852 | function registerWorkflowTrigger($sNamespace, $sClassname, $sPath) { |