Question
TWiki::Func::getPluginPreferencesFlag doesn't seem to work - it returns zero for everything. The effect of this is that turning on DEBUG or other preferences fails for Plugins whose WhateverPlugin.pm is derived from EmptyPlugin.pm, including
DefaultPlugin. Their debug output does not show up in data/debug.txt.
If you use getPluginPreferencesValue instead in your WhateverPlugin.pm, it works fine.
I think this is because getPluginPreferencesValue uses caller() to get the calling module name and treats that as the plugin to get preference for. getPluginPreferencesFlag is a wrapper around getPluginPreferencesValue, so the caller it sees in this case is TWiki::Func.
sub getPluginPreferencesValue
{
my( $theKey ) = @_;
my $package = caller;
$package =~ s/.*:://; # strip off TWiki::Plugins:: prefix
return TWiki::Prefs::getPreferencesValue( "\U$package\E_$theKey" );
}
...
sub getPluginPreferencesFlag
{
my( $theKey ) = @_;
my $value = getPluginPreferencesValue( $theKey );
return TWiki::Prefs::formatAsFlag($value);
}
Environment
--
AndrewJanke - 18 Feb 2005
Answer
Yes, this is a known problem. There is a patch for it somewhere in the Codev web (search for getpluginpreferencesvalue). Your analysis is correct and suggests you should be able to solve the problem yourself, without recourse to the patch!
--
CrawfordCurrie - 20 Feb 2005
Easy work-around, if that's all it was - just switched to getPreferencesValue(), and my new plugin works fine. Will postpone anything else until patch makes it into official release. Thanks, Crawford.
--
AndrewJanke - 23 Feb 2005