Download & Extend

Performance improvements

Project:OG User Roles
Version:5.x-3.3
Component:Code
Category:feature request
Priority:normal
Assigned:SomebodySysop
Status:closed (won't fix)

Issue Summary

Do not clear the cache every page load!
At the moment every page load the cache is cleared if you use 'og_user_roles_clear_cache_value' which is almost neccesary in all installs. This patch only cleares the cache when somethings has changed.

Do not load the user in your init hook()!
The organic groups module does a user_load on the current user in init. There for the data of the current user is already loaded.

Do not reload the roles if no group nid was found!
When we do not have a organic group we do not need to update the roles.

AttachmentSize
og_user_roles_performance.patch3.89 KB

Comments

#1

Assigned to:Anonymous» SomebodySysop

Thank you very much for the contribution. I do wish to improve the performance of this module. Because this involves modification of the core OGUR functions, I'm sure you understand that I have to proceed with extreme caution.

I'm trying to follow your code changes and I think I understand most of it. I am not really clear on this section:

<?php
+
+   
// We add this to a global so we can always keep track of which roles where added.
+    if (!isset($og_user_roles_added[$user->uid])) {
+     
$og_user_roles_added[$user->uid] = array();
+    }
+   
$og_user_roles_added[$user->uid] = array_merge($og_user_roles_added[$user->uid], $ogroles);
+   
$og_user_roles_added[$user->uid] = array_unique($og_user_roles_added[$user->uid]);
?>

Could you please elaborate just a bit on what's going on here? Am I correct in my assumption that you don't really care what the roles are, you are just looking for some indication that they've changed?

Also, are you currently using the module with these new changes?

#2

Well I think it is a nice addition (and needed for the patch in hook_init) to be able to see what roles have been added to a user. So this is a global variable (could be a static function get/set too if you think thats prettier) which holds all the uid's and which roles have been added to that uid.

I needed the module for a client of ours but noticed the cache being cleared alot. This was quite intensive so I wrote this patch to work around and the writes / clears to the cache lowered down alot.

#3

Status:needs review» closed (won't fix)

After the rise of the rewritten OGUR 4.x for Drupal 6, in which many unrelated features of OGUR were removed, and nearing a release of Drupal 7, I'm closing down old issues.

nobody click here