Item10458: virtual hosts config incompatible with new logger api
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
In
VirtualHost::find()
newly created vhost objects create config settings
{DebugFileName|WarningFileName|LogFileName|...}
which forces Foswiki to fallback to a backwards compatibility logger instead
of any other logger being configured.
Problem is that any use of
$Foswiki::cfg{SomeDir} = $Foswiki::cfg{SomeOtherDir} . "/stuff";
will freeze the value of
SomeOtherDir
to
SomeDir
before the vhost obj is run.
There are a lot of plugins that have default settings of that kind, even the core does, e.g. the page cache managers,
PublishPlugin,
RtfContrib, maybe more.
Here's a patch that at least partially mitigates the problem.
--- lib/Foswiki/Contrib/VirtualHostingContrib/VirtualHost.pm (revision 10974)
+++ lib/Foswiki/Contrib/VirtualHostingContrib/VirtualHost.pm (working copy)
@@ -40,10 +40,13 @@
Htpasswd => {
FileName => "$DataDir/.htpasswd",
},
- ConfigurationLogName => "$DataDir/configurationlog.txt",
- DebugFileName => "$DataDir/debug%DATE%.txt",
- WarningFileName => "$DataDir/warn%DATE%.txt",
- LogFileName => "$DataDir/log%DATE%.txt",
+ Log => {
+ Dir => $WorkingDir."/logs",
+ },
+ Cache => {
+ RootDir => $WorkingDir."/cache",
+ DBFile => $WorkingDir."/cache/foswiki_db",
+ },
RCS => {
WorkAreaDir => "$WorkingDir/work_areas",
},
Most probably any fancy variable assignment in
LocalSite.cfg
can't be dealt with by default. Instead this has to be set correctly in
VirtualHost.cfg
to match the vhost.
Probably needs some more docu.
--
MichaelDaum - 08 Mar 2011
Hello, Michael.
If the change you are proposing makes
VirtualHostingContrib play well with The
rest of Foswiki, I'm all for it.
But I don't quite understand why the use of
$DataDir
above would cause
anything, since the strings are double-quoted and that $DataDir is interpolated
right away upon the evaluation of those strings; we are not actually
referencing any other configuration in %Foswiki::cfg. Any pointers to
documentation that explains the problem in a little more detail?
Another issue is that I would like to stay compatible with Foswiki 1.0.x.
--
AntonioTerceiro - 11 Mar 2011
Since 1.1.x Foswiki's logger api was introduced allowing to plug in a custom logger, e.g. one that stores its records into an sql database for later analysis. For backwards compatibility Foswiki will drop back to a CompatibilityLogger
as soon as it sees a {LogFileName}
in the config. That's what is biting us here: it is not possible to run a custom logger as long as there's a
{LogFileName}
in the configuration unfortunately. Similarly, all other log files have been moved and renamed from
data/..
to
working/logs/...
which of course is an improvement as the
data/...
directory isn't polluted anymore by log files.
Taking care of compatibility to 1.0.x in
VirtualHostingContrib is a good point. So basically this means that the code has to check the version of the engine and then go one or the other way setting up the configuration obj.
--
MichaelDaum - 11 Mar 2011
ok, thanks for the explanation. Please go ahead: keep the existing logic for Foswiki 1.0.x and use the new logic you propose for Foswiki 1.1.x+.
--
AntonioTerceiro - 11 Mar 2011