[interchange] Only apply GDBM filters if they are not already installed
David Christensen <[email protected]>
| Newsgroups | gmane.comp.web.interchange.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 0c31ea3287df97c8fedbf23ad71244e4ebe019c7 Author: David Christensen <[email protected]> Date: Thu Aug 30 20:01:28 2012 -0500 Only apply GDBM filters if they are not already installed In certain circumstances, using the same GDBM-based file in multiple catalogs with GDBM_ENABLE_UTF8=1 set was causing the GDBM filters to be installed multiple times on the same handle, which was resulting in encoding/decoding errors. Vend::Table::GDBM will now only install the filters if they do not exist on this handle, which should preserve existing behavior plus account for these corner-cases. lib/Vend/Table/GDBM.pm | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) --- diff --git a/lib/Vend/Table/GDBM.pm b/lib/Vend/Table/GDBM.pm index fb82dbb..559f904 100644 --- a/lib/Vend/Table/GDBM.pm +++ b/lib/Vend/Table/GDBM.pm @@ -150,10 +150,10 @@ sub apply_utf8_filters { my $out_filter = sub { $_ = encode('utf-8', $_) }; my $in_filter = sub { $_ = decode('utf-8', $_) }; - $handle->filter_store_key($out_filter); - $handle->filter_store_value($out_filter); - $handle->filter_fetch_key($in_filter); - $handle->filter_fetch_value($in_filter); + $handle->filter_store_key($out_filter) unless $handle->filter_store_key(); + $handle->filter_store_value($out_filter) unless $handle->filter_store_value(); + $handle->filter_fetch_key($in_filter) unless $handle->filter_fetch_key(); + $handle->filter_fetch_value($in_filter) unless $handle->filter_fetch_value(); return $handle; }