From: Rafael Kitover Date: Tue, 8 Feb 2011 15:57:35 +0000 (-0500) Subject: Temporarily monkeypatch DBD::ADO to fix warnings during global destruction X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=772a1a2505d6beea58b2745c5723ef3dbada8884;p=dbsrgits%2FDBIx-Class-Historic.git Temporarily monkeypatch DBD::ADO to fix warnings during global destruction --- diff --git a/lib/DBIx/Class/Storage/DBI/ADO.pm b/lib/DBIx/Class/Storage/DBI/ADO.pm index 773bdd6..98c1941 100644 --- a/lib/DBIx/Class/Storage/DBI/ADO.pm +++ b/lib/DBIx/Class/Storage/DBI/ADO.pm @@ -3,6 +3,9 @@ package DBIx::Class::Storage::DBI::ADO; use base 'DBIx::Class::Storage::DBI'; use mro 'c3'; +use Sub::Name; +use namespace::clean; + =head1 NAME DBIx::Class::Storage::DBI::ADO - Support for L @@ -54,6 +57,27 @@ sub _dbh_get_info { $self->next::method(@_); } +# Monkeypatch out the horrible warnings during global destruction. +# A patch to DBD::ADO has been submitted as well. +# https://rt.cpan.org/Ticket/Display.html?id=65563 +sub _init { + no warnings 'redefine'; + require DBD::ADO; + + if ($DBD::ADO::VERSION <= 2.98) { + my $disconnect = *DBD::ADO::db::disconnect{CODE}; + + *DBD::ADO::db::disconnect = subname 'DBD::ADO::db::disconnect' => sub { + my $warn_handler = $SIG{__WARN__} || sub { warn @_ }; + local $SIG{__WARN__} = sub { + $warn_handler->(@_) + unless $_[0] =~ /Not a Win32::OLE object|uninitialized value/; + }; + $disconnect->(@_); + }; + } +} + # Here I was just experimenting with ADO cursor types, left in as a comment in # case you want to as well. See the DBD::ADO docs. #sub _dbh_sth {