diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-10-28 10:59:10 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-10-28 10:59:10 +0000 |
commit | 853b9448de06328fe2bc2c7be7dcee3d9cc25902 (patch) | |
tree | 6467b918ce49675947574de2232d6f6afaa44552 | |
parent | 27ac22034eec297e5000938c7c349480a448a680 (diff) | |
download | elgg-853b9448de06328fe2bc2c7be7dcee3d9cc25902.tar.gz elgg-853b9448de06328fe2bc2c7be7dcee3d9cc25902.tar.bz2 |
Flags to prevent queries being run multiple times.
git-svn-id: https://code.elgg.org/elgg/trunk@2325 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/access.php | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php index 44693c3ea..ff7cfe477 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -53,7 +53,7 @@ function get_access_array($user_id = 0, $site_id = 0, $flush = false) {
global $CONFIG;
- static $access_array; + static $access_array, $acm, $ac; // Caches. $ac* flag whether we have executed a query previously, and stop it being run again if no data is returned. if (!isset($access_array) || (!isset($init_finished)) || (!$init_finished))
$access_array = array();
@@ -73,19 +73,29 @@ $tmp_access_array = array(2);
if (isloggedin())
$tmp_access_array[] = 1;
-
- if ($collections = get_data($query)) {
- foreach($collections as $collection)
- if (!empty($collection->access_collection_id)) $tmp_access_array[] = $collection->access_collection_id;
- }
-
+ + if (!$ac) + {
+ if ($collections = get_data($query)) {
+ foreach($collections as $collection)
+ if (!empty($collection->access_collection_id)) $tmp_access_array[] = $collection->access_collection_id;
+ } + } +
+ $ac = true; // We don't want to run this query again +
$query = "select ag.id from {$CONFIG->dbprefix}access_collections ag ";
$query .= " where ag.owner_guid = {$user_id} and (ag.site_guid = {$site_id} or ag.site_guid = 0)";
-
- if ($collections = get_data($query)) {
- foreach($collections as $collection)
- if (!empty($collection->id)) $tmp_access_array[] = $collection->id;
- }
+ + if (!$acm) + {
+ if ($collections = get_data($query)) {
+ foreach($collections as $collection)
+ if (!empty($collection->id)) $tmp_access_array[] = $collection->id;
+ } + } + + $acm = true; // We don't want to run this query again
global $is_admin;
|