Thanks Dami.
Tim.
On Tue, Apr 25, 2006 at 11:20:27AM +0200, Dami Laurent (PJ) wrote:
> Hi,
>
> Connect_cached has a hidden side-effect (documented in code, but not in
> doc) :
>
> # XXX modifies callers data!
>
> This is annoying when the caller uses Readonly : then connect_cached
> throws an exception. So I propose the simple patch below.
>
> Best regards, L. Dami
>
> --- DBI.pm Tue Apr 25 10:59:55 2006
> +++ DBI_connect_cached_ok.pm Tue Apr 25 11:07:00 2006
> @@ -524,11 +524,12 @@
> # For library code using connect_cached() with mod_perl
> # we redirect those calls to Apache::DBI::connect() as well
> my ($class, $dsn, $user, $pass, $attr) = @_;
> - # XXX modifies callers data!
> - ($attr ||= {})->{dbi_connect_method} =
> +
> + my %clone_attr = $attr ? %$attr : (); # don't want to modify
> caller's data
> + $clone_attr{dbi_connect_method} =
> ($DBI::connect_via eq "Apache::DBI::connect")
> ? 'Apache::DBI::connect' : 'connect_cached';
> - return $class->connect($dsn, $user, $pass, $attr);
> + return $class->connect($dsn, $user, $pass, \%clone_attr);
> }
>
> sub connect {
>
>
>