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
Without
allow_nonref
,
JQueryPlugin v6.32 might not initialise correctly with
JSON.pm 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] 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/JSON.pm line 154.
at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/JSON.pm line 154.
JSON::to_json(HASH(0x7fa4fd6aaae8), HASH(0x7fa4fd6b0be8)) called at /var/www/apps/foswiki/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm line 98
Foswiki::Plugins::JQueryPlugin::FOSWIKI::init(Foswiki::Plugins::JQueryPlugin::FOSWIKI=HASH(0x7fa4fd69f648)) called at /var/www/apps/foswiki/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm line 151
Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin("Foswiki") called at /var/www/apps/foswiki/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm line 120
Foswiki::Plugins::JQueryPlugin::Plugins::init() called at /var/www/apps/foswiki/lib/Foswiki/Plugins/JQueryPlugin.pm line 68
Foswiki::Plugins::JQueryPlugin::initPlugin("WebHome", "Main", "guest", "System") called at /var/www/apps/foswiki/lib/Foswiki/Plugin.pm line 254
Foswiki::Plugin::__ANON__() called at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/Error.pm line 421
eval {...} called at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/Error.pm line 413
Error::subs::try(CODE(0x7fa4fd578a30), HASH(0x7fa4fd57ba00)) called at /var/www/apps/foswiki/lib/Foswiki/Plugin.pm line 271
Foswiki::Plugin::registerHandlers(Foswiki::Plugin=HASH(0x7fa4fc6e8350), Foswiki::Plugins=HASH(0x7fa4fc008f88)) called at /var/www/apps/foswiki/lib/Foswiki/Plugins.pm line 307
Foswiki::Plugins::enable(Foswiki::Plugins=HASH(0x7fa4fc008f88)) called at /var/www/apps/foswiki/lib/Foswiki.pm line 2286
Foswiki::new("Foswiki", undef, Foswiki::Request=HASH(0x7fa4fc004760), HASH(0x56297fb430d0)) called at /var/www/apps/foswiki/lib/Foswiki/UI.pm line 365
Foswiki::UI::__ANON__() called at /var/www/.plenv/versions/5.22.1-ithreads-shrplib/lib/perl5/site_perl/5.22.1/Error.pm line 421
[...]
The following patch seems to fix this:
--- lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm.org 2016-01-10 19:12:50.000000000 +0100
+++ lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm 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
\%prefs,
$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