You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Doug MacEachern <do...@covalent.net> on 2000/09/26 20:34:42 UTC

RE: PerlAddVar bug

On Thu, 6 Jul 2000, Geoffrey Young wrote:
 
> I guess my expectation is that $r->dir_config('MyVar') and
> $r->dir_config->get('MyVar') should inherit equally, which as far as I can
> tell, they don't.  PerlSetVar or PerlAddVar - it makes no difference.

the problem is related to the Apache::Server->dir_config support.  in the
directive handler, if path was NULL, the var was set/add-ed only to the
server_rec->module_config.  $r->dir_config falls back to the
server_rec->module_config  if the var is not found in
request_rec->per_dir_config, but $r->dir_config->get does not.  the patch
below fixes the problem, works just as PerlSetEnv does.  the key/val is
always added to the per-dir table, and also added to the per-server table
is path == NULL, for use at startup time.

p.s.
i also just committed a change so PerlAddVar is now an ITERATE2 rather
than TAKE 2, so you can say:

PerlAddVar Key val-one val-two val-three

Index: src/modules/perl/perl_config.c
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
retrieving revision 1.102
diff -u -r1.102 perl_config.c
--- src/modules/perl/perl_config.c	2000/09/22 18:52:00	1.102
+++ src/modules/perl/perl_config.c	2000/09/26 18:29:51
@@ -717,17 +717,17 @@
 
 CHAR_P perl_cmd_var(cmd_parms *cmd, void *config, char *key, char *val)
 {
+    perl_dir_config *rec = (perl_dir_config *)config;
     MP_TRACE_d(fprintf(stderr, "perl_cmd_var: '%s' = '%s'\n", key, val));
-    if (cmd->path) {
-        perl_dir_config *rec = (perl_dir_config *) config;
-        if (cmd->info) {
-            table_add(rec->vars, key, val);
-        }
-        else {
-            table_set(rec->vars, key, val);
-        }
+
+    if (cmd->info) {
+        table_add(rec->vars, key, val);
     }
     else {
+        table_set(rec->vars, key, val);
+    }
+
+    if (cmd->path == NULL) {
         dPSRV(cmd->server);
         if (cmd->info) {
             table_add(cls->vars, key, val);