diff options
author | lpsolit%gmail.com <> | 2006-06-20 16:39:01 +0200 |
---|---|---|
committer | lpsolit%gmail.com <> | 2006-06-20 16:39:01 +0200 |
commit | 5ffe3d31dde3c11525ff09ce17e4b0d730e5e2fd (patch) | |
tree | 0b9d599b66539790f093991462b0e759d183cf53 | |
parent | 9eb55706632461dac42ab005c0da8e18814135cb (diff) | |
download | bugzilla-5ffe3d31dde3c11525ff09ce17e4b0d730e5e2fd.tar.gz bugzilla-5ffe3d31dde3c11525ff09ce17e4b0d730e5e2fd.tar.xz |
Bug 278017: Eliminate use of deprecated Bugzilla::DB routines (SendSQL, etc.) - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=myk
-rw-r--r-- | Bugzilla.pm | 11 | ||||
-rw-r--r-- | Bugzilla/DB.pm | 141 | ||||
-rw-r--r-- | globals.pl | 1 |
3 files changed, 2 insertions, 151 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm index ea7740151..8c58454ed 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -315,17 +315,6 @@ sub _cleanup { undef $_cgi; undef $_user; - # See bug 192531. If we don't clear the possibly active statement handles, - # then when this is called from the END block, it happens _before_ the - # destructors in Bugzilla::DB have happened. - # See http://rt.perl.org/rt2/Ticket/Display.html?id=17450#38810 - # Without disconnecting explicitly here, noone notices, because DBI::END - # ends up calling DBD::mysql's $drh->disconnect_all, which is a noop. - # This code is evil, but it needs to be done, at least until SendSQL and - # friends can be removed - @Bugzilla::DB::SQLStateStack = (); - undef $Bugzilla::DB::_current_sth; - # When we support transactions, need to ->rollback here $_dbh_main->disconnect if $_dbh_main; $_dbh_shadow->disconnect if $_dbh_shadow && Bugzilla->params->{"shadowdb"}; diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 2b913cef2..87e0bc4b2 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -32,20 +32,8 @@ use strict; use DBI; -# Inherit the DB class from DBI::db and Exporter -# Note that we inherit from Exporter just to allow the old, deprecated -# interface to work. If it gets removed, the Exporter class can be removed -# from this list. -use base qw(Exporter DBI::db); - -%Bugzilla::DB::EXPORT_TAGS = - ( - deprecated => [qw(SendSQL SqlQuote - MoreSQLData FetchSQLData FetchOneColumn - PushGlobalSQLState PopGlobalSQLState) - ], -); -Exporter::export_ok_tags('deprecated'); +# Inherit the DB class from DBI::db. +use base qw(DBI::db); use Bugzilla::Config qw(:DEFAULT :db); use Bugzilla::Constants; @@ -60,89 +48,6 @@ use Bugzilla::DB::Schema; use constant BLOB_TYPE => DBI::SQL_BLOB; ##################################################################### -# Deprecated Functions -##################################################################### - -# All this code is backwards compat fu. As such, its a bit ugly. Note the -# circular dependencies on Bugzilla.pm -# This is old cruft which will be removed, so there's not much use in -# having a separate package for it, or otherwise trying to avoid the circular -# dependency - -# XXX - mod_perl -# These use |our| instead of |my| because they need to be cleared from -# Bugzilla.pm. See bug 192531 for details. -our $_current_sth; -our @SQLStateStack = (); - -my $_fetchahead; - -sub SendSQL { - my ($str) = @_; - - $_current_sth = Bugzilla->dbh->prepare($str); - - $_current_sth->execute; - - # This is really really ugly, but its what we get for not doing - # error checking for 5 years. See bug 189446 and bug 192531 - $_current_sth->{RaiseError} = 0; - - undef $_fetchahead; -} - -# Its much much better to use bound params instead of this -sub SqlQuote { - my ($str) = @_; - - # Backwards compat code - return "''" if not defined $str; - - my $res = Bugzilla->dbh->quote($str); - - trick_taint($res); - - return $res; -} - -sub MoreSQLData { - return 1 if defined $_fetchahead; - - if ($_fetchahead = $_current_sth->fetchrow_arrayref()) { - return 1; - } - return 0; -} - -sub FetchSQLData { - if (defined $_fetchahead) { - my @result = @$_fetchahead; - undef $_fetchahead; - return @result; - } - - return $_current_sth->fetchrow_array; -} - -sub FetchOneColumn { - my @row = FetchSQLData(); - return $row[0]; -} - -sub PushGlobalSQLState { - push @SQLStateStack, $_current_sth; - push @SQLStateStack, $_fetchahead; -} - -sub PopGlobalSQLState { - die ("PopGlobalSQLState: stack underflow") if ( scalar(@SQLStateStack) < 1 ); - $_fetchahead = pop @SQLStateStack; - $_current_sth = pop @SQLStateStack; -} - -# MODERN CODE BELOW - -##################################################################### # Connection Methods ##################################################################### @@ -972,10 +877,6 @@ functionality which is different between databases allowing for easy customization for particular database via inheritance. These methods should be always preffered over hard-coding SQL commands. -Access to the old SendSQL-based database routines are also provided by -importing the C<:deprecated> tag. These routines should not be used in new -code. - =head1 CONSTANTS Subclasses of Bugzilla::DB are required to define certain constants. These @@ -1494,44 +1395,6 @@ with their functions. =back -=head1 DEPRECATED ROUTINES - -Several database routines are deprecated. They should not be used in new code, -and so are not documented. - -=over 4 - -=item * - -SendSQL - -=item * - -SqlQuote - -=item * - -MoreSQLData - -=item * - -FetchSQLData - -=item * - -FetchOneColumn - -=item * - -PushGlobalSQLState - -=item * - -PopGlobalSQLState - -=back - - =head1 SEE ALSO L<DBI> diff --git a/globals.pl b/globals.pl index 6af204666..2654c4a1f 100644 --- a/globals.pl +++ b/globals.pl @@ -31,7 +31,6 @@ use strict; -use Bugzilla::DB qw(:DEFAULT :deprecated); use Bugzilla::Constants; use Bugzilla::Util; # Bring ChmodDataFile in until this is all moved to the module |