r4 - 24 Jun 2005 - 18:05:43 - CharlesDupontYou are here: TWiki >  Codev Web > ChangeProposal > BugReport > GetPluginPreferencesFlagReturnError
Tags:
, create new tag

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 | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo