Tags:
create new tag
, view all tags

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

TWiki version: TWikiRelease01Sep2004
TWiki plugins: DefaultPlugin, SpreadSheetPlugin, CommentPlugin, DefaultPlugin, EditTablePlugin, EmptyPlugin, InterwikiPlugin, MathModePlugin, PerlDocPlugin, RenderListPlugin, SlideShowPlugin, SmiliesPlugin, SpreadSheetPlugin, TablePlugin
Server OS: RedHat Enterprise Linux 3.0, kernel 2.4.21-20.EL.BZ131027.hotfixhugemem
Web server: Apache 1.3.29
Perl version: 5.6.1
Client OS: MS Windows XP
Web Browser: Mozilla Firefox 1.0
Categories: Plugins

-- 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

 
Topic revision: r4 - 2005-02-23 - AndrewJanke
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.