Branch: Tag:

2007-10-05

2007-10-05 07:34:07 by Martin Jonsson <marty@roxen.com>

Bugfix to address instability of the ProviderChoice variable: don't use ::query() as it will fall back to the default value as soon as the provider module is unloaded. Instead, only use the default value if the variable's string value is unset.

Rev: server/etc/modules/Variable.pmod/module.pmod:1.99

1: - // $Id: module.pmod,v 1.98 2007/01/22 13:16:29 grubba Exp $ + // $Id: module.pmod,v 1.99 2007/10/05 07:34:07 marty Exp $      #include <module.h>   #include <roxen.h>
1394:    static string provides;    static string default_id;    static string local_id = ""; +  static int isset;       int low_set(RoxenModule to)    {
1423:    if (stringp(to)) {    local_id = to;    to = transform_from_form(to); +  isset = 1;    }    return ::set(to);    }       RoxenModule query()    { -  RoxenModule res = ::query(); +  RoxenModule res = changed_values[_id];    if (!res) {    if (local_id != "") {    // The module might have been reloaded.    // Try locating it again.    res = transform_from_form(local_id);    if (res) low_set(res); -  +  } else if(!isset) { +  res = default_value(); +  if(res) { +  set(res);    }    } -  +  }    return res;    }   
1468:    if (default_id) {    return transform_from_form(default_id);    } else { -  array(RoxenModule) providers = get_choice_list(); +  array(RoxenModule) providers = conf->get_providers(provides);    if (sizeof(providers)) {    return providers[0];    }