Skip to content
Extraits de code Groupes Projets
Valider a20d1bb2 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

!get now finishes statements, commit and disconnect from the db

parent e9a2521e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -8,11 +8,11 @@ use lib "$FindBin::Bin/lib/"; ...@@ -8,11 +8,11 @@ use lib "$FindBin::Bin/lib/";
use utils::print; use utils::print;
use utils::db; use utils::db;
our $dbh;
our $irc; our $irc;
our $log; our $log;
my $last_req; my $last_req;
my $dbh;
my $sth; my $sth;
sub exec { sub exec {
...@@ -30,7 +30,14 @@ sub exec { ...@@ -30,7 +30,14 @@ sub exec {
my @words = ($msg =~ /(?:^| )([^#\s]+)/g); my @words = ($msg =~ /(?:^| )([^#\s]+)/g);
if (not defined $last_req or $msg ne $last_req) { if (not defined $last_req or $msg ne $last_req) {
my $dbh = utils::db::get_new_session; # we close a previous session if needed
if ($dbh) {
$sth->finish if $sth->{'Active'};
$dbh->commit;
$dbh->disconnect;
}
$dbh = utils::db::get_new_session;
my @words_param; my @words_param;
foreach (@words) { foreach (@words) {
...@@ -129,7 +136,7 @@ sub exec { ...@@ -129,7 +136,7 @@ sub exec {
# this is specific to the mysql driver # this is specific to the mysql driver
$rows = $sth->rows; $rows = $sth->rows;
my $sth2 = utils::db::get_new_session()->prepare("select tag my $sth2 = utils::db::main_session()->prepare("select tag
from playbot_tags from playbot_tags
where id = ? where id = ?
"); ");
...@@ -157,7 +164,7 @@ sub exec { ...@@ -157,7 +164,7 @@ sub exec {
$irc->yield(privmsg => $chan => $irc_msg); $irc->yield(privmsg => $chan => $irc_msg);
# we save the get like a post # we save the get like a post
$sth2 = utils::db::get_new_session()->prepare_cached(' $sth2 = utils::db::main_session()->prepare_cached('
INSERT INTO playbot_chan (content, chan, sender_irc) INSERT INTO playbot_chan (content, chan, sender_irc)
VALUES (?,?,?)'); VALUES (?,?,?)');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth2); $log->error("Couldn't prepare querie; aborting") unless (defined $sth2);
......
...@@ -21,7 +21,6 @@ sub setConf { ...@@ -21,7 +21,6 @@ sub setConf {
$commands::fav::dbh = $dbhNew; $commands::fav::dbh = $dbhNew;
$commands::tag::dbh = $dbhNew; $commands::tag::dbh = $dbhNew;
$commands::get::dbh = $dbhNew;
$commands::later::dbh = $dbhNew; $commands::later::dbh = $dbhNew;
$utils::id::dbh = $dbhNew; $utils::id::dbh = $dbhNew;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter