cross is now running Foswiki 2.1.3 Beta 1. Please open a task for any issues.

Item14024: JQueryPlugin (v6.32) might not initialise correctly with current JSON (v2.90) / JSON-XS (v3.02) modules w/o allow_nonref.

Priority: Urgent
Current State: Closed
Released In: 2.1.1
Target Release: patch
Applies To: Extension
Component: JQueryPlugin, ModPerlEngineContrib
Branches: Release02x01 master Item14033 Item13897
Reported By: MarkusUeberall
Waiting For:
Last Change By: JanKrueger
Without allow_nonref, JQueryPlugin v6.32 might not initialise correctly with v2.90 JSON-XS v3.02 when using mod_perl (used to work with an older version) :
  • [System.InstalledPlugins] JQueryPlugin: (disabled) Plugin module did not return true. See errors below.
  • [configure] pdf screenshot (the error message is misleading, everything is in place!)
| 2016-03-13T00:22:08+01:00 warning | hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/ line 154.
 at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/ line 154.
        JSON::to_json(HASH(0x7fa4fd6aaae8), HASH(0x7fa4fd6b0be8)) called at /var/www/apps/foswiki/lib/Foswiki/Plugins/JQueryPlugin/ line 98
        Foswiki::Plugins::JQueryPlugin::FOSWIKI::init(Foswiki::Plugins::JQueryPlugin::FOSWIKI=HASH(0x7fa4fd69f648)) called at /var/www/apps/foswiki/lib/Foswiki/Plugins/JQueryPlugin/ line 151
        Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin("Foswiki") called at /var/www/apps/foswiki/lib/Foswiki/Plugins/JQueryPlugin/ line 120
        Foswiki::Plugins::JQueryPlugin::Plugins::init() called at /var/www/apps/foswiki/lib/Foswiki/Plugins/ line 68
        Foswiki::Plugins::JQueryPlugin::initPlugin("WebHome", "Main", "guest", "System") called at /var/www/apps/foswiki/lib/Foswiki/ line 254
        Foswiki::Plugin::__ANON__() called at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/ line 421
        eval {...} called at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/ line 413
        Error::subs::try(CODE(0x7fa4fd578a30), HASH(0x7fa4fd57ba00)) called at /var/www/apps/foswiki/lib/Foswiki/ line 271
        Foswiki::Plugin::registerHandlers(Foswiki::Plugin=HASH(0x7fa4fc6e8350), Foswiki::Plugins=HASH(0x7fa4fc008f88)) called at /var/www/apps/foswiki/lib/Foswiki/ line 307
        Foswiki::Plugins::enable(Foswiki::Plugins=HASH(0x7fa4fc008f88)) called at /var/www/apps/foswiki/lib/ line 2286
        Foswiki::new("Foswiki", undef, Foswiki::Request=HASH(0x7fa4fc004760), HASH(0x56297fb430d0)) called at /var/www/apps/foswiki/lib/Foswiki/ line 365
        Foswiki::UI::__ANON__() called at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/ line 421

The following patch seems to fix this:
--- lib/Foswiki/Plugins/JQueryPlugin/     2016-01-10 19:12:50.000000000 +0100
+++ lib/Foswiki/Plugins/JQueryPlugin/ 2016-03-15 21:01:58.392793582 +0100
@@ -98,5 +98,5 @@
     my $text =
         "<script class='\$zone \$id foswikiPreferences' type='text/json'>"
-      . JSON::to_json( \%prefs, { pretty => 1 } )
+      . JSON::to_json( \%prefs, { pretty => 1, allow_nonref => 1 } )
       . "</script>";

Although the underlying problem might lie elsewhere, the above should make this plugin "more robust".
(NB the same also applies to JsonRpcContrib which effectively breaks configure at least for my installation, see Item14025)

Given that JSON v2.90 has been released a while ago already, the above warning must have been a side effect of updating multiple Perl modules two days ago (using cpan-outdated -p | cpanm --notest)...

-- MarkusUeberall - 15 Mar 2016

When you enable allow_nonref, could you please have a look at the page source and see what it actually produced?

I can't repro the problem. Why would \%prefs not be a hash reference?

-- MichaelDaum - 17 Mar 2016

I thought that the allow_nonref was referring to the contents of \%prefs, not (only) the hash reference itself. I've attached the captured contents of txt\%prefs, txt$text for Main/WebHome with the applied patch. Other than adding a line to do so now, I've never touched the plugin code and it used to work before... very strange.

-- MarkusUeberall - 17 Mar 2016

NB the above error message is also mentioned in (CPAN) bug report #109026, linked to JSON-XS. I have to check whether the problem vanishes when switching to JSON-PP (though I'm not aware of switching the backend during the last upgrade) (it turned out that JSON-XS had been updated to v3.02).

Update: Heureka! Removing JSON-XS v3.02 (using cpanm --notest App::pmuninstall; pm-uninstall -f JSON::XS) fixed all my problems (including the one mentioned in Item14025).
If the use of JSON-XS is not deemed "exotic" (frankly, I've never paid attention to the backend in use, just relied on all dependencies being taken care of by cpanm), should we open another task item specifically linked to JSON-XS and/or blacklist the aforementioned version after retests?

-- MarkusUeberall - 17 Mar 2016

No we desperately need more speed (see this benchmark) ... while also being error-free of course. If adding allow_nonref fixes it, so be it.

I was thinking more the opposite: as I do not experience above error does it still use JSON:PP instead of JSON::XS also being installed? I might miss a few extra seconds speed here.

-- MichaelDaum - 18 Mar 2016

Update: I just found out that switching from mod_perl to fcgid also fixed the above (when using JSON::XS 3.02).

-- MarkusUeberall - 21 Mar 2016

We've decided in the release meeting to include a workaround, which has just been merged and will be released in 2.1.1 and 2.2.0.

-- JanKrueger - 4 Apr 2016
Topic attachments
I Attachment Action Size Date Who Comment
20160316_configure_JQueryPlugin_unpatched.pdfpdf 20160316_configure_JQueryPlugin_unpatched.pdf manage 97 K 16 Mar 2016 - 10:19 MarkusUeberall view of the broken configure interface (the error message is misleading, everything is in place!)
JQueryPlugin_FOSWIKI_pm.dump.txttxt JQueryPlugin_FOSWIKI_pm.dump.txt manage 872 bytes 17 Mar 2016 - 13:56 MarkusUeberall The contents of \%prefs as seen by Data::Dumper
JQueryPlugin_FOSWIKI_pm.txttxt JQueryPlugin_FOSWIKI_pm.txt manage 736 bytes 17 Mar 2016 - 14:04 MarkusUeberall sample $text contents w/ applied patch when looking at Main
Topic revision: r13 - 11 Aug 2016, JanKrueger - This page was cached on 20 Jan 2017 - 05:10.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License