Commit 0ee9bf80 authored by Francois Marier's avatar Francois Marier
Browse files

Cache result of auth_get_enabled_auth_plugins

This will now be called more than once on the homepage and it
involves a query and one function call per auth plugin so we
should avoid running it more than once per page.

Suggested by Richard on https://reviews.mahara.org/934



Change-Id: I875196a65e7f20bba3f5195da7f18c1dcb4b58ab
Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent 5691e321
...@@ -1123,6 +1123,11 @@ EOF; ...@@ -1123,6 +1123,11 @@ EOF;
*/ */
function auth_get_enabled_auth_plugins() { function auth_get_enabled_auth_plugins() {
static $cached_plugins = null;
if ($cached_plugins !== null) {
return $cached_plugins;
}
$sql = 'SELECT $sql = 'SELECT
DISTINCT(authname) DISTINCT(authname)
FROM FROM
...@@ -1145,7 +1150,8 @@ function auth_get_enabled_auth_plugins() { ...@@ -1145,7 +1150,8 @@ function auth_get_enabled_auth_plugins() {
} }
} }
return $usableplugins; $cached_plugins = $usableplugins;
return $cached_plugins;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment