[drupal-devel] Getting rid of global variables

neil at civicspacelabs.org neil at civicspacelabs.org
Fri Sep 30 17:35:41 UTC 2005


On Fri, Sep 30, 2005 at 02:19:51PM +0200, Karoly Negyesi wrote:
> Hi!
> 
> global variables are hard to debug and error prone. Let's make it explicit:
> 
> drupal_set($module, $key, $value = NULL, $force = FALSE) {
>   static $storage;
>   if ($value || $force) {
>     $storage[$module][$key] = $value;
>   }
>   return $storage[$module][$key];
> }
> 
> drupal_get($module, $key) {
>   return drupal_set($module, $key);
> }

How about drupal_(set|get)_global(). And drupal_(set|get)_object() can
be used to get statically cached objects (nodes, terms, users,
vocabularies, etc) from the db.

-Neil



More information about the drupal-devel mailing list