SMF Development > Applied or Declined Requests
Something like loadMemberData() but which RETURNS the data
Yoshi:
Hi!
Sorry if this has been asked before, I'm horrible with searching ::)
Anyway, this has been bothering me for a while now.
SMF has a couple of functions, loadmembercontext and loadmemberdata which does what they say. Though they could have improvements.
For one and the only thing I'm going to talk about, the current features of these functions are WAY too complex.
You have to call then and find a way of grabbing the variables from some variable.
I'd rather, and that's my opinion, see a way of having the function return the data instead. This way, SMF doesn't have to carry all that data in $context or something if it's only used once, plus you can just catch it and done.
What do you guys think?
Arantor:
Except that it's actually faster to store it in a global variable rather than passing it back and forth, which is why it doesn't.
You do know that loadMemberData actually returns a meaningful value in itself, though, right?
Yoshi:
--- Quote from: Arantor on May 03, 2012, 07:06:00 PM ---Except that it's actually faster to store it in a global variable rather than passing it back and forth, which is why it doesn't.
--- End quote ---
That's possible, but maybe build a parameter that returns the data, too, AND putting it in a global variable then. Again, this is just my opinion and I'm fine with it when you disregard this.
--- Quote ---You do know that loadMemberData actually returns a meaningful value in itself, though, right?
--- End quote ---
Nope, never really investigated what and how it returns something but I know it doesn't return the member data, lol.
Arantor:
--- Quote ---That's possible, but maybe build a parameter that returns the data, too, AND putting it in a global variable then. Again, this is just my opinion and I'm fine with it when you disregard this.
--- End quote ---
Yay, let's make it even more complicated. Most people who call it don't understand what the significance of all three existing parameters is, for example, that in most cases it makes extra queries for data you won't need.
I can see why you think it's a good idea, but it really isn't. Apart from the fact you lose the extra data that the current return value is, you end up pushing a lot more data around than you would now, which would be slower and faster.
Why would you return a big, massive array by value (which requires all sorts of memory allocation) when you can just call it from the one place it already is and not cause any more performance issues with it? You wouldn't, basically.
--- Quote ---Nope, never really investigated what and how it returns something but I know it doesn't return the member data, lol.
--- End quote ---
It returns the list of member details it was able to load. So you can push in a list of members and get a list of members that actually exist. Plenty of times that's been useful.
Yoshi:
--- Quote from: Arantor on May 03, 2012, 08:39:00 PM ---
--- Quote ---That's possible, but maybe build a parameter that returns the data, too, AND putting it in a global variable then. Again, this is just my opinion and I'm fine with it when you disregard this.
--- End quote ---
Yay, let's make it even more complicated. Most people who call it don't understand what the significance of all three existing parameters is, for example, that in most cases it makes extra queries for data you won't need.
--- End quote ---
Uh, I was just throwing ideas up there. Nevermind me :P
--- Quote ---I can see why you think it's a good idea, but it really isn't. Apart from the fact you lose the extra data that the current return value is, you end up pushing a lot more data around than you would now, which would be slower and faster.
--- End quote ---
Right, slower and faster.
Anyway, I guess this may indeed be a performance issue now that I think about it, playing with big arrays.
--- Quote ---Why would you return a big, massive array by value (which requires all sorts of memory allocation) when you can just call it from the one place it already is and not cause any more performance issues with it? You wouldn't, basically.
--- End quote ---
Well, I don't know for the heck of life what place it is put in. It isn't even mentioned in the function database AFAICR.
--- Quote ---
--- Quote ---Nope, never really investigated what and how it returns something but I know it doesn't return the member data, lol.
--- End quote ---
It returns the list of member details it was able to load. So you can push in a list of members and get a list of members that actually exist. Plenty of times that's been useful.
--- End quote ---
Oh, that's good to know. I just skipped over the var_dump and found that it didn't include the data I wanted so yeah, lol.
Navigation
[0] Message Index
[#] Next page
Go to full version