Item11123: JQGridPlugin fails on current trunk: Can't call method "i18n"...

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: JQGridPlugin
Branches:
Reported By: PaulHarvey
Waiting For:
Last Change By: MichaelDaum
I get this on a clean pseudo-install checkout of trunk:

| 2011-09-12T01:59:05Z warning | Can't call method "i18n" on an undefined value at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm line 75.
 at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm line 75
   Foswiki::Plugins::JQGridPlugin::GRID::init('Foswiki::Plugins::JQGridPlugin::GRID=HASH(0x47aca98)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm line 84
   Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin('Grid', 'Foswiki=HASH(0x2808480)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin.pm line 94
   Foswiki::Plugins::JQueryPlugin::createPlugin('Grid', 'Foswiki=HASH(0x2808480)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQGridPlugin.pm line 59
   Foswiki::Plugins::JQGridPlugin::handleGrid('Foswiki=HASH(0x2808480)', 'Foswiki::Attrs=HASH(0x2c84020)', 'WebHome', 'Mangroves/Bibliography', 'Foswiki::Meta=HASH(0x3116b80)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Func.pm line 568
   Foswiki::Func::__ANON__('Foswiki=HASH(0x2808480)', 'Foswiki::Attrs=HASH(0x2c84020)', 'Foswiki::Meta=HASH(0x3116b80)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm line 3093
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x2808480)', 'GRID', '\x{a}  query="form.name=\'Mangroves/Bibliography.BibliographyForm...', 'Foswiki::Meta=HASH(0x3116b80)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm line 2969
   Foswiki::_processMacros('Foswiki=HASH(0x2808480)', '<!--\x{a}   * Set NOWYSIWYG = 1\x{a}\x{a}<!--\x{0}verbatim1\x{0}-->\x{a}\x{a}-->\x{a}---+ Bib...', 'CODE(0x2761148)', 'Foswiki::Meta=HASH(0x3116b80)', 16) called at /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm line 2766
   Foswiki::innerExpandMacros('Foswiki=HASH(0x2808480)', 'SCALAR(0x2c831c8)', 'Foswiki::Meta=HASH(0x3116b80)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm line 3275
   Foswiki::expandMacros('Foswiki=HASH(0x2808480)', '<!--\x{a}   * Set NOWYSIWYG = 1\x{a}\x{a}< verbatim >\x{a}%STARTSECTION{"addbib...', 'Foswiki::Meta=HASH(0x3116b80)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Meta.pm line 3122
   Foswiki::Meta::expandMacros('Foswiki::Meta=HASH(0x3116b80)', '<!--\x{a}   * Set NOWYSIWYG = 1\x{a}\x{a}< verbatim>\x{a}%STARTSECTION{"addbib...') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm line 406
   Foswiki::UI::View::_prepare('<!--\x{a}   * Set NOWYSIWYG = 1\x{a}\x{a}< verbatim>\x{a}%STARTSECTION{"addbib...', 'Foswiki::Meta=HASH(0x3116b80)', 0) called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm line 386
   Foswiki::UI::View::view('Foswiki=HASH(0x2808480)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm line 316
   Foswiki::UI::__ANON__() called at /usr/share/perl5/Error.pm line 416
   eval {...} called at /usr/share/perl5/Error.pm line 408
   Error::subs::try('CODE(0x1dabf10)', 'HASH(0x28363b8)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm line 435
   Foswiki::UI::_execute('Foswiki::Request=HASH(0x26decd0)', 'CODE(0x204dc88)', 'view', 1) called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm line 274
   Foswiki::UI::handleRequest('Foswiki::Request=HASH(0x26decd0)') called at /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm line 37
   Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x216ade0)') called at /usr/local/src/github.com/foswiki/core/bin/view line 29.

I don't know why it's not working in this case. {session} seems undef

Quick patch
diff --git a/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm b/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
index 588ca31..154317e 100644
--- a/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
+++ b/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
@@ -72,7 +72,7 @@ sub init {
   return unless $this->SUPER::init();
 
   # open matching localization file if it exists
-  my $langTag = $this->{session}->i18n->language();
+  my $langTag = $Foswiki::Plugins::SESSION->i18n->language();
   my $localeFile = 'i18n/grid.locale-'.$langTag.'.js';
   $localeFile = 'i18n/grid.locale-en.js' 
     unless -f $this->{puburl}.'/'.$localeFile;
@@ -213,7 +213,7 @@ HERE
         push @selectedFields, $fieldName;
       }
     } else {
-      my $form = new Foswiki::Form($this->{session}, $theFormWeb, $theForm);
+      my $form = new Foswiki::Form($Foswiki::Plugins::SESSION, $theFormWeb, $theForm);
       @selectedFields = map {$_->{name}} @{$form->getFields()} if $form;
     }
 
@@ -292,8 +292,8 @@ HERE
 
     push @metadata, 'colModel: ['.join(",\n", @colModels).']';
 
-    my $baseWeb = $this->{session}->{webName};
-    my $baseTopic = $this->{session}->{topicName};
+    my $baseWeb = $Foswiki::Plugins::SESSION->{webName};
+    my $baseTopic = $Foswiki::Plugins::SESSION->{topicName};
     my $gridConnectorUrl;
 
     my ($connectorWeb, $connectorTopic) = Foswiki::Func::normalizeWebTopicName($baseWeb, $theConnector);

Is JQueryPlugin supposed to be creating a {session} key?

-- PaulHarvey - 12 Sep 2011

Not anymore as this hinders caching plugins in memory across sessions. The stack trace above indicates you are using an unreleased JQueryPlugin already. Next JQGridPlugin checkin does contain a fix very similar to yours.

-- MichaelDaum - 12 Sep 2011

Fixed in 2.0

-- MichaelDaum - 12 Sep 2011

ItemTemplate edit

Summary JQGridPlugin fails on current trunk: Can't call method "i18n"...
ReportedBy PaulHarvey
Codebase trunk
SVN Range
AppliesTo Extension
Component JQGridPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
Topic revision: r4 - 12 Sep 2011, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy