Skip Menu |

This queue is for tickets about the Cache-Memcached CPAN distribution.

Report information
The Basics
Id: 92687
Status: new
Priority: 0/
Queue: Cache-Memcached

People
Owner: Nobody in particular
Requestors: victor [...] vsespb.ru
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Wrong behaviour with UTF-8 flag
altrough there is ticket https://rt.cpan.org/Ticket/Display.html?id=28095 related to saving/restoring UTF-8 flag, but there is another problem. current behaviour is broken even if we don't want to preserve UTF-8 flag the following example fails with "data corruption" message ==== use strict; use warnings; use Cache::Memcached; my $memd = Cache::Memcached->new({utf8 => 0, servers => [ '127.0.0.1:11211' ]}); my $s = "\x81"; my $s_u = $s; utf8::upgrade $s_u; die unless $s eq $s_u; $memd->set("XYZ", $s_u); my $s_u2 = $memd->get("XYZ"); die "data corupted" unless $s_u2 eq $s_u; ==== similar code, which use perl "print"/"readline" behaver correctly in same test === use strict; use warnings; my $s = "\x81"; my $s_u = $s; utf8::upgrade $s_u; die unless $s eq $s_u; open my $f, ">", "file.tmp"; binmode $f; print $f $s_u; close $f; open $f, "<", "file.tmp"; my ($s_u2) = <$f>; close $f; die "data corupted" unless $s_u2 eq $s_u; === (no data corrupted error) this bug is due to "use bytes" in code. "use bytes" not only affects things like "length()" but also affect things like string concatenation, making this line work wrong: === my $line = "$cmdname $self->{namespace}$key $flags $exptime $len\r\n$val\r\n"; === you should use something like utf8::downgrade (if you don't want to support perl unicode strings) or preserve utf8 flag if you do. related ticket https://rt.cpan.org/Ticket/Display.html?id=92678