Dom, 2008-06-22 às 00:13 +0200, Michael Scherer escreveu:
Do you have a patch ?
Well, I thought it wouldn't be worth posting because I'm simply
commenting out the 'use fields' directive in both files and replacing
the calls to fields::new($class) for bless {}, $class.
As I said before, I understand this is not a proper fix, only a
work-around. I think there should be a way to implement a proper-OO fix.
Anyway, there the patch goes
daniel
--- XMLElement.pm 2007-05-08 18:41:45.0 -0300
+++ XMLElement.pm.patched 2008-06-22 10:13:34.0 -0300
@@ -1,13 +1,13 @@
package DJabberd::XMLElement;
use strict;
-use fields (
-'ns',# namespace name
-'element', # element name
-'attrs', # hashref of {namespace}attr = value. NOTE: used by Stanza.pm directly.
-'children', # arrayref of child elements of this same type, or scalars for text nodes
-'raw', # in some cases we have the raw xml and we have to create a fake XMLElement object
- # business logic is that as_xml returns the raw stuff if it is exists, children has to be empty -- sky
-);
+#use fields (
+#'ns',# namespace name
+#'element', # element name
+#'attrs', # hashref of {namespace}attr = value. NOTE: used by Stanza.pm directly.
+#'children', # arrayref of child elements of this same type, or scalars for text nodes
+#'raw', # in some cases we have the raw xml and we have to create a fake XMLElement object
+# # business logic is that as_xml returns the raw stuff if it is exists, children has to be empty -- sky
+#);
use DJabberd::Util;
@@ -19,7 +19,7 @@
}
# constructing a new XMLElement:
-my DJabberd::XMLElement $self = fields::new($class);
+my DJabberd::XMLElement $self = bless {}, $class;
($self-{ns},
$self-{element},
$self-{attrs},
@@ -164,7 +164,7 @@
sub clone {
my $self = shift;
-my $clone = fields::new(ref($self));
+my $clone = bless {}, ref($self);
$clone-{ns} = $self-{ns};
$clone-{element} = $self-{element};
$clone-{attrs}= { %{ $self-{attrs} } };
--- Stanza.pm 2006-09-27 17:57:47.0 -0300
+++ Stanza.pm.patched 2008-06-22 10:13:43.0 -0300
@@ -2,24 +2,24 @@
use strict;
use base qw(DJabberd::XMLElement);
use Carp qw(croak);
-use fields (
-'connection', # Store the connection the stanza came in on so we can respond.
-# may be undef, as it's a weakref. if you want to mess with the
-# structure, you can't do so unless you're the owner, so clone
-# it first otherwise.
-'_memo_tojid', # memoized to jid
-'_memo_fromjid', # memoized from jid
-);
+#use fields (
+#'connection', # Store the connection the stanza came in on so we can respond.
+## may be undef, as it's a weakref. if you want to mess with the
+## structure, you can't do so unless you're the owner, so clone
+## it first otherwise.
+#'_memo_tojid', # memoized to jid
+#'_memo_fromjid', # memoized from jid
+#);
sub downbless {
my $class = shift;
if (ref $_[0]) {
my ($self, $conn) = @_;
# 'fields' hackery. this will break in Perl 5.10
-{
-no strict 'refs';
-$self-[0] = \%{$class . ::FIELDS }
-}
+#{
+#no strict 'refs';
+#$self-[0] = \%{$class . ::FIELDS }
+#}
bless $self, $class;
if ($conn) {
$self-{connection} = $conn;