Item14198: PublishPlugin fails in Foswiki 2.1.2 while trying to render zones
Priority: Normal
Current State: Closed
Released In: 2.1.3
Target Release: n/a
When the publish script is called (via rest) is appears to be proceeding correctly and generating publishing report, however when it processings a topic to publish, the following (sample) error is generated:
ERROR: Web.Topic not published: Can't locate object method "_renderZones" via package "Foswiki" at /path/to/foswiki/lib/Foswiki/Plugins/PublishPlugin/PageAssembler.pm line 107. at /path/to/foswiki/lib/Foswiki/Plugins/PublishPlugin/PageAssembler.pm line 107. Foswiki::Plugins::PublishPlugin::PageAssembler::_foswiki1x1(Foswiki::Plugins::PublishPlugin::Publisher=HASH(0x49174d0), "\x{a}\x{a}\x{a}
The relevant code in
PageAssembler.pm
is this:
90 sub _foswiki1x1 {
91 my $publisher = shift;
92 my $tmpl = shift;
93
94 # nasty kludge. backup zone content for plugins which only call
95 # addToZone during plugin initialization. _renderZones deletes
96 # the zone content and subsequent published topics will be missing
97 # that content
97 my $this = $Foswiki::Plugins::SESSION;
99 my %zones;
100 while ( my ( $zoneName, $zone ) = each %{ $this->{_zones} } ) {
101 $zones{$zoneName} = {};
102
103 $zones{$zoneName}{$_} = $zone->{$_}
104 foreach grep { /^JQUERYPLUGIN::/ } keys %$zone;
105 }
106
107 my $result = $Foswiki::Plugins::SESSION->_renderZones($tmpl);
108
109 $this->{_zones}{$_} = $zones{$_} for keys %zones;
110
111 return $result;
112}
--
LynnwoodBrown - 11 Oct 2016
It seems
PublishPlugin needs to be updated for Foswiki 2.1 - this is what I've got so far, which doesn't account for "unicode core" yet:
diff --git a/lib/Foswiki/Plugins/PublishPlugin/BackEnd/file.pm b/lib/Foswiki/Plugins/PublishPlugin/BackEnd/file.pm
index 86f0652..5089527 100644
--- a/lib/Foswiki/Plugins/PublishPlugin/BackEnd/file.pm
+++ b/lib/Foswiki/Plugins/PublishPlugin/BackEnd/file.pm
@@ -31,7 +31,7 @@ sub new {
my $class = shift;
my $this = $class->SUPER::new(@_);
- my $oldmask = umask( oct(777) - $Foswiki::cfg{RCS}{dirPermission} );
+ my $oldmask = umask( oct(777) - ($Foswiki::cfg{RCS}{dirPermission}||$Foswiki::cfg{Store}{dirPermission}) );
$this->{params}->{outfile} ||= 'file';
if ( -e "$this->{path}/$this->{params}->{outfile}" ) {
@@ -67,7 +67,7 @@ sub param_schema {
sub addDirectory {
my ( $this, $name ) = @_;
- my $oldmask = umask( oct(777) - $Foswiki::cfg{RCS}{dirPermission} );
+ my $oldmask = umask( oct(777) - ($Foswiki::cfg{RCS}{dirPermission}||$Foswiki::cfg{Store}{dirPermission}) );
eval { File::Path::mkpath("$this->{path}$this->{params}->{outfile}/$name") };
$this->{logger}->logError($@) if $@;
umask($oldmask);
diff --git a/lib/Foswiki/Plugins/PublishPlugin/PageAssembler.pm b/lib/Foswiki/Plugins/PublishPlugin/PageAssembler.pm
index 37caca0..424c8cc 100644
--- a/lib/Foswiki/Plugins/PublishPlugin/PageAssembler.pm
+++ b/lib/Foswiki/Plugins/PublishPlugin/PageAssembler.pm
@@ -104,7 +104,14 @@ sub _foswiki1x1 {
foreach grep { /^JQUERYPLUGIN::/ } keys %$zone;
}
- my $result = $Foswiki::Plugins::SESSION->_renderZones($tmpl);
+ my $result;
+ if ( $Foswiki::Plugins::SESSION->can("_renderZones") ) {
+ # Foswiki 1.1 up to 2.0
+ $result = $Foswiki::Plugins::SESSION->_renderZones($tmpl);
+ } else {
+ # Foswiki 2.1 and later
+ $result = $Foswiki::Plugins::SESSION->zones()->_renderZones($tmpl);
+ }
$this->{_zones}{$_} = $zones{$_} for keys %zones;
--
FlorianSchlichting - 11 Oct 2016
Then
PublishPlugin bails out on some topics with the following error:
*** ERROR: Main.AdminGroup not published: Can't locate object method "userinfo" via package "URI::_generic" at /usr/share/perl5/URI/WithBase.pm line 52.
This is related to
Item13444, I believe, and probably fixed by the following:
diff --git a/lib/Foswiki/Net.pm b/lib/Foswiki/Net.pm
index d7c426f..2c0b9d3 100644
--- a/lib/Foswiki/Net.pm
+++ b/lib/Foswiki/Net.pm
@@ -212,7 +212,7 @@ sub getExternalResource {
$uri->scheme( $puri->scheme() );
$uri->host( $puri->host() );
$uri->port( $puri->port() );
- if ( $puri->userinfo() ) {
+ if ( $puri->can("userinfo") && defined $puri->userinfo() ) {
require MIME::Base64;
my $base64 =
MIME::Base64::encode_base64( $puri->userinfo(), '' );
@@ -220,7 +220,7 @@ sub getExternalResource {
}
}
- if ( $uri->userinfo() ) {
+ if ( $uri->can("userinfo") && defined $uri->userinfo() ) {
require MIME::Base64;
my $base64 = MIME::Base64::encode_base64( $uri->userinfo(), '' );
$req .= "Authorization: Basic $base64\r\n";
@@ -308,7 +308,7 @@ sub _GETUsingLWP {
my $user;
my $pass;
( $user, $pass ) = split( ':', $uri->userinfo(), 2 )
- if ( $uri->userinfo() );
+ if ( $uri->can("userinfo") && defined $uri->userinfo() );
my $ua = new Foswiki::Net::UserCredAgent( $user, $pass );
$ua->proxy( [ 'http', 'https' ], $puri->as_string() ) if $puri;
my $response = $ua->request($request);
--
FlorianSchlichting - 11 Oct 2016
Next I see
Wide character in print at /path/to/lib/Foswiki/Plugins/PublishPlugin/BackEnd/file.pm line 87 (#1)
and if it can be fixed by changing
PublishPlugin to use the standard plugin API for writing files...
--
FlorianSchlichting - 11 Oct 2016
Note that it's not good practice to mix extension fixes and core fixes into the same task. We can't close this task until both the core and the extension are both released. When I release 2.1.3, this will get closed automatically. I'll mark it for 2.1.3, so it gets picked up in the release notes.
--
GeorgeClark - 02 Dec 2016
Item14249 created to cover the core changes.
--
GeorgeClark - 07 Dec 2016
Calling zones()->_renderZones - barf. I don't fully understand
DiabJerius' patch here, but Florian's proposed fix looks OK - at least until someone revisits the zone rendering code
--
Main.CrawfordCurrie - 15 Feb 2017 - 11:37
LynnwoodBrown checked in this fix - looks OK to me, so closing this task.
--
Main.CrawfordCurrie - 18 Apr 2017 - 09:28