Tags:
create new tag
, view all tags

Bug: Call to TWiki::Func::getPluginPreferencesFlag returns wrong value

When a plugin calls TWiki::Func::getPluginPerferencesFlag( "DEBUG" ) it will allways return 0 regardless of whether * Set DEBUG = 1 is set in the NewPlugin page.

Test case

Set DEBUG = 1 in NewPlugin page.

in NewPlugin::initPlugin have
$debug = TWiki::Func::getPluginPreferencesFlag( "DEBUG" );
TWiki::Func::writeDebug( "- TWiki::Plugins::${pluginName}::initPlugin(DEBUG: $debug )" );

do some action in TWiki

in data/debug.txt should see
21 Jun 2005 - 10:39 - TWiki::Plugins::SecurePubPlugin::initPlugin(DEBUG: 1 )
actually see
21 Jun 2005 - 10:39 - TWiki::Plugins::SecurePubPlugin::initPlugin(DEBUG: 0 )

Environment

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, AlbumOfSnapsPlugin, CommentPlugin, DatabasePlugin, DirectedGraphPlugin, EFetchPlugin, EditTablePlugin, EmbedBibPlugin, InterwikiPlugin, MathModePlugin, RenderListPlugin, SessionPlugin, SlideShowPlugin, SmiliesPlugin, SpreadSheetPlugin, TablePlugin
Server OS: Debian Linux, kernel 2.6.6
Web server: Apache 2.0.54
Perl version: 5.8.4
Client OS:  
Web Browser: Mozillia

-- CharlesDupont - 21 Jun 2005

Impact and Available Solutions

Follow up

Fix record

A fix that works for me

--- lib/TWiki/Func.pm   2005-06-21 11:03:57.000000000 -0500
+++ lib/TWiki/Func.pm   2005-06-21 11:10:31.000000000 -0500
@@ -407,8 +407,9 @@
 sub getPluginPreferencesFlag
 {
     my( $theKey ) = @_;
-    my $value = getPluginPreferencesValue( $theKey );
-    return TWiki::Prefs::formatAsFlag($value);
+    my $package = caller;
+    $package =~ s/.*:://; # strip off TWiki::Plugins:: prefix
+    return TWiki::Prefs::getPreferencesFlag( "\U$package\E_$theKey" );
 }

 # =========================

-- CharlesDupont - 21 Jun 2005

Discussion

See also GetPluginPreferencesFlagDoesNotWork, GetPluginPreferencesValueBroken, and GetPluginPreferencesFlagDoesNotWorkInMyPlugin

-- CrawfordCurrie - 22 Jun 2005

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2005-06-24 - CharlesDupont
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.