Index: openacs-4/packages/acs-tcl/tcl/apm-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-init.tcl,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/acs-tcl/tcl/apm-init.tcl 7 Aug 2017 23:47:59 -0000 1.3 +++ openacs-4/packages/acs-tcl/tcl/apm-init.tcl 2 Sep 2021 17:10:27 -0000 1.3.2.1 @@ -12,6 +12,18 @@ nsv_array set apm_package_info [list] nsv_set apm_properties reload_level 0 +namespace eval apm { + + # Cache the singleton_p property of all packages. + db_foreach get_singleton { + select package_key, singleton_p + from apm_package_types + } { + set ::apm::package_singleton_p($package_key) $singleton_p + } + +} + # Local variables: # mode: tcl # tcl-indent-level: 4 Index: openacs-4/packages/acs-tcl/tcl/apm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.tcl,v diff -u -r1.114.2.32 -r1.114.2.33 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 30 Mar 2021 15:41:18 -0000 1.114.2.32 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 2 Sep 2021 17:10:27 -0000 1.114.2.33 @@ -349,7 +349,6 @@ return [nsv_get apm_package_url_resolution $package_key] } - ad_proc -private apm_package_load_libraries_order { package_key } { @@ -358,6 +357,23 @@ return [nsv_get apm_package_load_libraries_order $package_key] } +ad_proc -private apm_package_singleton_p { + package_key +} { + @return boolean telling whether a package is a singleton or not +} { + if {[info exists ::apm::package_singleton_p($package_key)]} { + return $::apm::package_singleton_p($package_key) + } else { + # Fallback for code executed when the cache has not been + # populated, or for new packages before restart. + return [db_string check_singleton { + select singleton_p from apm_package_types + where package_key = :package_key + } -default f] + } +} + ad_proc -public apm_version_loaded_p { version_id } { Returns 1 if a version of a package has been loaded and initialized, or 0 otherwise. Index: openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl,v diff -u -r1.26.2.3 -r1.26.2.4 --- openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 5 Jan 2021 17:10:17 -0000 1.26.2.3 +++ openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 2 Sep 2021 17:10:27 -0000 1.26.2.4 @@ -261,11 +261,7 @@ # packages. # if {$value eq ""} { - if {[db_string check_singleton { - select 1 from apm_package_types - where package_key = :package_key - and singleton_p = 't' - } -default 0]} { + if {[apm_package_singleton_p $package_key]} { set value [parameter::get \ -localize=$localize_p \ -boolean=$boolean_p \