<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
I don't believe you fully understood me.<div><br class="webkit-block-placeholder"></div><div>First off, variable_get does NOT retrieve from the database. if you look in the code it ONLY retrieves from that $conf variable that variable_set stores the variable in when it sets to the database. If, as you suggest David, it really should retrieve from the database then it is not working as defined.</div><div><br class="webkit-block-placeholder"></div><div><div>function variable_get($name, $default) {</div><div> global $conf;</div><div><br class="webkit-block-placeholder"></div><div> return isset($conf[$name]) ? $conf[$name] : $default;</div><div>}</div><div><br class="webkit-block-placeholder"></div></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>Second, according to the comments in the settings.php, you can initially override any variables stored in the database in the settings.php file by setting the same variable that variable_get and variable_set uses:</div><div><br></div><div><div>/**</div><div> * Variable overrides:</div><div> *</div><div> * To override specific entries in the 'variable' table for this site,</div><div> * set them here. You usually don't need to use this feature. This is</div><div> * useful in a configuration file for a vhost or directory, rather than</div><div> * the default settings.php. Any configuration setting from the 'variable'</div><div> * table can be given a new value.</div><div> *</div><div> * Remove the leading hash signs to enable.</div><div> *</div><div>/# <b style="font-size: 14px; "><span class="Apple-style-span" style="text-decoration: underline;">$conf</span></b> = array(</div><div># 'site_name' => 'My Drupal site',</div><div># 'theme_default' => 'minnelli',</div><div># 'anonymous' => 'Visitor',</div><div># );</div><div><br class="webkit-block-placeholder"></div><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><br class="Apple-interchange-newline"><br class="webkit-block-placeholder"></div><div>Scott Matthews</div><div>Senior Developer</div><div>(w) 617-227-1855 x164</div><div>(m) 617-710-8430</div><div>(f) 617-224-5388</div><div><a href="mailto:smatthews@optaros.com">smatthews@optaros.com</a></div><div><br class="webkit-block-placeholder"></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline"></span></span> </div><br><div><div>On Jan 29, 2008, at 11:04 AM, Metzler, David wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"> <!--[if !mso]> <style> st1\:*{behavior:url(#default#ieooui) } </style> <![endif]--> <div class="Section1"><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy">I think you’re confusing two completely independent constructs. <o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy">Variable_get and variable_set are used to store system wide settings that should persist in the database. They are never (to my knowledge) instantiated as PHP variables. The caching structure is meant to reduce the number of database hits involved in loading variables, and should not generally be accessed directly. Multiple calls to variable_get should leverage the cached variables as appropriate. <o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy">The variables in settings.php can be used, you can define your own global variables there, but if you want them to persist between page loads you need to do that yourself. IN your hooks you can reference these variables after defining them as globals, but be careful with namespace collisions. I usually create a global variable that has the same name as my module and store everying inside it (as an associative array). <o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy">Finally session variables can be used and will persist in the database for the duration of a session. <o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><br> Hope that clarifies things. It sounds like drupal is behaving as designed here. <o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy">Dave<o:p></o:p></span></font></p><p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><o:p> </o:p></span></font></p> <div> <div class="MsoNormal" align="center" style="text-align:center"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> <hr size="2" width="100%" align="center" tabindex="-1"> </span></font></div><p class="MsoNormal"><b><font size="2" face="Tahoma"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">From:</span></font></b><font size="2" face="Tahoma"><span style="font-size:10.0pt;font-family:Tahoma"> support-bounces@drupal.org [<a href="mailto:support-bounces@drupal.org">mailto:support-bounces@drupal.org</a>] <b><span style="font-weight:bold">On Behalf Of </span></b>Scott Matthews<br> <b><span style="font-weight:bold">Sent:</span></b> Tuesday, January 29, 2008 7:37 AM<br> <b><span style="font-weight:bold">To:</span></b> <st1:personname w:st="on"><a href="mailto:support@drupal.org">support@drupal.org</a></st1:personname><br> <b><span style="font-weight:bold">Cc:</span></b> Ron Trevarrow<br> <b><span style="font-weight:bold">Subject:</span></b> [support] Issues with initializing Variables on startup..</span></font><o:p></o:p></p> </div><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12.0pt"><o:p> </o:p></span></font></p><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12.0pt">I found what Appears to be a bug (or two) with initializing variables in Drupal.<o:p></o:p></span></font></p> <div><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12.0pt"><o:p> </o:p></span></font></p> </div> <div><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12.0pt">It is suggested that you can uncomment and set initial variable values in settings.php with the $conf array. In doing so, and not seeing my variables set when retrieving using variable_get, I discovered that conf_init(), when called to initialize the configure file path, it sets $conf to a string. I know that since it initializes settings.php within the context it conceptually SHOULD reset it to a variable, but it doesn't. I proved this by changing the variable array name in settings.php, variable_get, variable_set, variable_init and conf_init to $config_vars and the values I initialized in settings.php were reflected when my application later retrieved them using variable_get.<o:p></o:p></span></font></p> </div> <div><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12.0pt"><o:p> </o:p></span></font></p> </div> <div><p class="MsoNormal" style="margin-bottom:12.0pt"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">This bug is currently hindering the flexibility of an application that I'm writing that will be deployed to different environments. I initially tried to set the variables in the 'variable' table of the Database in order to retrieve them with variable_get but that method only accesses the cached variables in $conf (or in my case, $config_vars. Is this on purpose? I see that variable_set will not only set the cached variable but will also set into the database. This seems to be a bug as well to me. Can someone clarify this for me?<o:p></o:p></span></font></p> <div><span style="orphans: 2;text-align:auto;widows: 2;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px;-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0;word-spacing:0px"><span style="orphans: 2;widows: 2;-webkit-border-horizontal-spacing: 0px;-webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;word-spacing:0px"> <div><p class="MsoNormal" style="margin-bottom:12.0pt"><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black"><span style="orphans: 2;widows: 2;-webkit-border-horizontal-spacing: 0px;-webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;word-spacing:0px"><o:p> </o:p></span></span></font></p> </div> <div><p class="MsoNormal"><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black">Scott Matthews<o:p></o:p></span></font></p> </div> <div><p class="MsoNormal"><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black"><o:p> </o:p></span></font></p> </div><p class="MsoNormal"><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black"></span><br> <br> <br> </font><o:p></o:p></p> </span></span></div><p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12.0pt"><o:p> </o:p></span></font></p> </div> </div> </o:smarttagtype><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--<span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">[ Drupal support list | <a href="http://lists.drupal.org">http://lists.drupal.org</a>/ ]</div> </blockquote></div><br></div></body></html>