SimplePortal
Development => Bugs => Fixed or Bogus Bugs => Topic started by: ???1031 on August 28, 2008, 04:00:02 AM
-
Hope it's a good idea to post this here :x, because it's more a beta test thought ;).
I think i found a small improve for the code ;) (I think you copied it from one of my member color link codes, but its old and had bug in it ;P), yes i look through the code to find bugs 8). (Sorry i can't resist).
In your code stand "SPortal.php":
function sp_loadColors($users = array()) {
global $db_prefix, $scripturl;
if (empty($users))
return false;
$users = !is_array($users) ? array($users) : array_unique($users);
if(empty($color_profile))
$color_profile = array();
else {
foreach($users as $u)
if(isset($color_profile[$u]))
unset($users[$u]);
}
In that way the else part is useless because the $color_profile it's not stored after it goes though the function.
To improve the script a chache the data you could use for example this:
function sp_loadColors($users = array()) {
global $modSettings;
global $color_profile, $db_prefix, $scripturl;
// Can't just look for no users :P.
if (empty($users))
return false;
//New Version? Easier Handling ;D
if(!empty($modSettings['MemberColorLinkInstalled']))
return load_onlineColors($users);
$users = !is_array($users) ? array($users) : array_unique($users);
//First check is it already loaded?
if(empty($color_profile))
$color_profile = array();
else {
foreach($users as $k => $u)
if(isset($color_profile[$u]))
unset($users[$k]);
}
The diffrent now is that the $color_profile is now a global stored variable, and if you load user more than one time it will not be loaded out of the database, because it's allready stored in the $color_profile variable. And this will lower the database loads and speed up the script a little bit ;). (And it's integrate the MemberColorLink, as long it is installed.)
It will return the normal $color_profile after the script is finished and work in the same way as before (as long the $color_profile is not a global loaded *g*)
Only a idea to improve 2.0.3 RC1 =).
It's untestet (But i use it in my ssi member color link) ;)
Bye
DIN1031
-
Thanks for reporting this ???1031. I have moved it to the 'Bugs' board.
BTW, We are at 2.0.4 at the moment. So this is a bug in a released version of the mod. ;)
I'll have a futher look into this when I finish the SP 2.05 SMF 2 Beta version.