Commit 8a7bf857 authored by Bastien Le Querrec's avatar Bastien Le Querrec

log more information

parent 3185234b
......@@ -1379,6 +1379,7 @@ class Admin extends Controller
public function banque_update($f3, $filename, $testing=true)
{
$log = new \Log('/banque_update.log');
$log->write('Processing recurrent donations (testing: ' . ($testing ? 'true' : 'false') . ')');
$separator = ";";
$datas = array();
......@@ -1472,7 +1473,8 @@ class Admin extends Controller
if ($user and !$testing) {
$db->query("INSERT INTO identifiers(user_id, identifier) VALUES ('".$user['id']."', '".$identifier."')");
$email = $user['email'];
} else {
} elseif (!$testing) {
$log->write('Cannot find user for transaction id ' . $identifier . ', creating it...');
// No user, let's try to create the user
$email = '';
$pseudo = '';
......@@ -1485,15 +1487,13 @@ class Admin extends Controller
}
//! hash seems to identify one email at one time
$hash = hash('sha256', date("%Y-%m-%d %H:%i:%d").$email);
if (!$testing) {
$log->write('Insert user: email "'.$email.'" pseudo "'.$pseudo.'" identifier "'.$identifier.'"');
try {
$f3->get('container')['command_handler']->handle(new UserCreateCommand($email, $hash, $pseudo, 0, 0));
} catch (InvalidEmailException $e) { // \Exception
$log->write("exception: ".$e);
throw $e;
}
};
$log->write('Insert user: email "'.$email.'" pseudo "'.$pseudo.'" identifier "'.$identifier.'"');
try {
$f3->get('container')['command_handler']->handle(new UserCreateCommand($email, $hash, $pseudo, 0, 0));
} catch (InvalidEmailException $e) { // \Exception
$log->write("exception: ".$e);
throw $e;
}
}
} else {
$email = $result->fetch(\PDO::FETCH_ASSOC);
......@@ -1572,8 +1572,6 @@ class Admin extends Controller
'".$user['id']."',
'".$cumul."',
'".$identifier."')";
}
if (!$testing) {
$db->query($query);
// On met alors à jour le cumul et le total de l'utilisateur concerné
$result = $db->query("UPDATE users
......@@ -1593,6 +1591,7 @@ class Admin extends Controller
$datas['update'] = $update; //! recurrent transactions remisées just added
$datas['comptabilise'] = $comptabilise; //! recurrent transactions remisées already added
$datas['sans_cumul'] = $sans_cumul; //! empty
$log->write('Processing recurrent donation finished.');
return $datas;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment