DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • December 13, 2017, 06:30:31 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Core: Module Prefs  (Read 3075 times)
0 Members and 1 Guest are viewing this topic.
Nightborn
Guest
« on: February 01, 2006, 03:26:45 AM »

As I just have seen a module userprefs table with 95k entries and 80k of them empty, I ponder about the following:

/lib/modules.php

set_module_pref <-why not check if the pref is set to 0 or '' and then delete the line instead of update? would save a lot of place...

get_module_pref <-why not return 0 instead of NULL if  there is no pref set?
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #1 on: February 01, 2006, 03:40:20 AM »

1) Keep the lines there... For god's sake!

If I have a boolean pref with a default value of "true" and it's set to "false" (and you delete the row...) Then it would return the wrongest possible value!
Also: if I check for a pref, which doesn't exist, the core tries to load the default value... (bad, time consuming run through the *_getmoduleinfo() )...

And then it inserts the default value into the database... (If there was already an empty / null / 0 value in the database, we would not have that extra sql call...)

2) Because NULL and 0 are different values. There is a small but existant difference.
Logged

Running for more than three years now:
Nightborn
Guest
« Reply #2 on: February 01, 2006, 03:44:57 AM »

^^ mhm, okay, if you say so. I missed  the default value point.

edit:
yet, I think 0-values shouldn't be stored in the table.... should be some more efficient system... than have to go through 0-values all the time.
« Last Edit: February 01, 2006, 03:50:49 AM by Nightborn » Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #3 on: February 01, 2006, 03:52:45 AM »

There are some core modules which make use if this (at least in their settings).

The get_module_(pref|setting) stuff... It doesn't matter to you if it returns NULL or 0 or ''.

Code:
if (get_module_pref("anypref") === true) {
will *never* evaluate to true. The returned value is always a string. But this usage would be the only case, where you'd need to know whether it's NULL, 0 or false... Wink

Code:
$i = get_module_pref("anypref") * 10;
only works, because PHP just casts to (numeric) string value to its integer representation.

Logged

Running for more than three years now:
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #4 on: February 01, 2006, 03:54:46 AM »

edit:
yet, I think 0-values shouldn't be stored in the table.... should be some more efficient system... than have to go through 0-values all the time.
Then try to explain to me, how you will manage to differ rows, which *need* a 0 value from rows which are not existant, if you removed the "0"-ones... (beside the additional database load, because they would be stored there again...)

The same for empty strings... It might be necessary to have them there!
Logged

Running for more than three years now:
Nightborn
Guest
« Reply #5 on: February 01, 2006, 03:58:36 AM »

That's what I ponder about at the moment. Sorry to have asked such petty things.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
27 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search