mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
Fix: Better error management
This commit is contained in:
@@ -34,12 +34,12 @@ $path=preg_replace('@[\\\/]+$@','',$path).'/';
|
|||||||
|
|
||||||
// Test if batch mode
|
// Test if batch mode
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||||
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($argv[1]) || ! $argv[1]) {
|
if (! isset($argv[1]) || ! $argv[1]) {
|
||||||
print "Usage: mailing-send.php ID_MAILING\n";
|
print "Usage: ".$script_file." ID_MAILING\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$id=$argv[1];
|
$id=$argv[1];
|
||||||
@@ -69,7 +69,7 @@ if ($resql)
|
|||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
dol_syslog("mailing-send: mailing ".$id);
|
dol_syslog("mailing ".$id);
|
||||||
|
|
||||||
$id = $obj->rowid;
|
$id = $obj->rowid;
|
||||||
$subject = $obj->sujet;
|
$subject = $obj->sujet;
|
||||||
@@ -84,6 +84,10 @@ if ($resql)
|
|||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_syslog("Error emailing with id ".$id." not found",LOG_ERR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +106,7 @@ if ($resql)
|
|||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
dol_syslog("mailing-send: nb of targets = ".$num, LOG_DEBUG);
|
dol_syslog("nb of targets = ".$num, LOG_DEBUG);
|
||||||
|
|
||||||
// Positionne date debut envoi
|
// Positionne date debut envoi
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=SYSDATE() WHERE rowid=".$id;
|
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=SYSDATE() WHERE rowid=".$id;
|
||||||
@@ -172,7 +176,7 @@ if ($resql)
|
|||||||
// Mail successful
|
// Mail successful
|
||||||
$nbok++;
|
$nbok++;
|
||||||
|
|
||||||
dol_syslog("mailing-send: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
|
dol_syslog("ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
|
||||||
|
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
||||||
$sql.=" SET statut=1, date_envoi=SYSDATE() WHERE rowid=".$obj->rowid;
|
$sql.=" SET statut=1, date_envoi=SYSDATE() WHERE rowid=".$obj->rowid;
|
||||||
@@ -187,7 +191,7 @@ if ($resql)
|
|||||||
// Mail failed
|
// Mail failed
|
||||||
$nbko++;
|
$nbko++;
|
||||||
|
|
||||||
dol_syslog("mailing-send: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
|
dol_syslog("error for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
|
||||||
|
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
||||||
$sql.=" SET statut=-1, date_envoi=SYSDATE() WHERE rowid=".$obj->rowid;
|
$sql.=" SET statut=-1, date_envoi=SYSDATE() WHERE rowid=".$obj->rowid;
|
||||||
@@ -207,7 +211,7 @@ if ($resql)
|
|||||||
if (! $nbko) $statut=3;
|
if (! $nbko) $statut=3;
|
||||||
|
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id;
|
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id;
|
||||||
dol_syslog("mailing-send: update global status sql=".$sql, LOG_DEBUG);
|
dol_syslog("update global status sql=".$sql, LOG_DEBUG);
|
||||||
$resql2=$db->query($sql);
|
$resql2=$db->query($sql);
|
||||||
if (! $resql2)
|
if (! $resql2)
|
||||||
{
|
{
|
||||||
@@ -216,7 +220,6 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog($db->error());
|
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user