Skip to content
Snippets Groups Projects

Hotline 6.54

Merged Laurent requested to merge hotline_6.54 into WIP
Compare and
+ 334
336
Preferences
Compare changes
Files
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/////////////////////////////////////////////////////////////////////////
@@ -30,14 +30,14 @@ if ($argc == 3 or $argc==4) {
$user = $argv[1];
$passe = $argv[2];
$cron_a_traiter=$argv[3];
if (!$cron_a_traiter)
if (!$cron_a_traiter)
$cron_a_traiter = 'all';
$mode_cron = true;
}
include '_init_frame.php';
// Includes
if ($mode_cron == true)
if ($mode_cron == true)
setVariable('clef_traitements', '0'); // en mode cron : on debloque la base
require_once 'classe_chronometre.php';
require_once 'classe_parseur.php';
@@ -65,7 +65,7 @@ $compteur = [];
$date = dateDuJour(0);
$nb_notices = 0;
$timeout = intval(ini_get("max_execution_time") * 0.75);
if (!$timeout)
if (!$timeout)
$timeout = 25; // Pour le debugger
$timeStart = time();
$chrono->start();
@@ -93,9 +93,9 @@ if ($_REQUEST['reprise'] == 'oui') {
$log->ecrire('<h4>Début du traitement</h4>');
$log->ecrire('Date : ' . date('d-m-Y') . BR);
$log->ecrire('Heure : ' . date('G:i:s') . BR);
$log->ecrire('Mode : '
. (($mode_cron == true) ? 'automatique (cron)' : 'manuel')
. BR);
$log->ecrire('Mode : '
. (($mode_cron == true) ? 'automatique (cron)' : 'manuel')
. BR);
if ($cron_a_traiter > '') {
$txt = ['all' => 'tous types d\'imports',
@@ -120,33 +120,33 @@ if ($_REQUEST['reprise'] == 'oui') {
$transfert = new maj_auto();
$erreur = $transfert->transfertfichiersFtp();
if ($erreur) {
$log->ecrire(BR . BR
$log->ecrire(BR . BR
. '<span class="rouge">' . $erreur . ' : Abandon du traitement !</span><br>');
exit;
}
setVariable('integration_date', $date);
$transfert->supprimerEntetesPergame();
// ----------------------------------------------------------------
// controle si on doit sortir en cas d'import total
// ----------------------------------------------------------------
if ($cron_a_traiter > '' and $cron_a_traiter != 'all') {
$controle = fetchOne("select count(*) from integrations,profil_donnees
Where integrations.profil=profil_donnees.id_profil
and traite='non'
and type_operation=2
$controle = fetchOne("select count(*) from integrations,profil_donnees
Where integrations.profil=profil_donnees.id_profil
and traite='non'
and type_operation=2
and type_fichier=0");
if ($cron_a_traiter == 'inc' and $controle > 0) {
$erreur = 'Il y a un import total à traiter et le cron demande de ne traiter que les imports incrementiels';
$log->ecrire(BR . BR
$log->ecrire(BR . BR
. '<span class="rouge">' . $erreur . ' : Abandon du traitement !</span><br>');
exit;
}
if ($cron_a_traiter == 'tot' and $controle == 0) {
$erreur = 'Il n\'y aucun import total à traiter et le cron demande de ne traiter que les imports totaux';
$log->ecrire(BR . BR
$log->ecrire(BR . BR
. '<span class="rouge">' . $erreur . ' : Abandon du traitement !</span><br>');
exit;
}
@@ -247,7 +247,7 @@ while ($ligne = $sql->fetchNext($resultat)) {
$log->ecrire(BR . '<span class="vert">' . $nb_notices . ' notices ont été traitées.</span>');
$msg = "temps de traitement " . $chrono_fichier->end() . " (" . $chrono_fichier->moyenne($nb_notices, "notices") . ")";
}
$log->ecrire(BR . '<span class="vert">' . $msg . '</span><br>');
$log->ecrire(BR . '<span class="vert">' . $msg . '</span><br>');
break;
}
@@ -422,33 +422,43 @@ if ($phase == 4 and $ecart >= $frequence and $homogene_actif == 1)
$log->ecrire('<span class="vert">Mode de recherche sur les serveurs z39.50 : ' . getLibCodifVariable("Z3950_cache_only", $homogene_cache_only) . '</span>' . BR);
}
$result = $sql->prepareListe("select id_notice,isbn from notices where isbn > '" . $phase_data["isbn"] . "' and qualite < $qualite_homogene and z3950_retry <= $Z3950_retry_level order by isbn");
while ($data = $sql->fetchNext($result))
{
while (true)
{
if (!$mode_cron and ($chrono->tempsPasse() + $ret["timeout"]) > $timeout) sauveContexte();
$ret = $notice->traiteHomogene($data["id_notice"], $data["isbn"], "", "", $homogene_cache_only);
traceHomogene($data["id_notice"], $data["isbn"], "", "");
if ($ret["statut"] != "erreur" and $ret["statut_z3950"] > 0)
try {
while ($data = $sql->fetchNext($result))
{
$phase_data["nb_reconnexions"] = 0;
break;
while (true)
{
if (!$mode_cron and ($chrono->tempsPasse() + $ret["timeout"]) > $timeout) sauveContexte();
$ret = $notice->traiteHomogene($data["id_notice"], $data["isbn"], "", "", $homogene_cache_only);
traceHomogene($data["id_notice"], $data["isbn"], "", "");
if ($ret["statut"] != "erreur" and $ret["statut_z3950"] > 0)
{
$phase_data["nb_reconnexions"] = 0;
break;
}
// Tentatives de reconnexion
$phase_data["nb_reconnexions"]++;
if ($phase_data["nb_reconnexions"] >= $Z3950_max_reconnect)
{
$log->ecrire(BR . '<span class="rouge">Abandon du traitement : maximum de tentatives de reconnexions atteint</span>' . BR);
$fin = true;
break;
}
sleep(5);
}
if ($fin == true) break;
$phase_data["isbn"] = $data["isbn"];
$phase_data["nombre"]++;
}
} catch (PDOException $e) {
$log->ecrire('PDOException'.$e);
$cosmo_path = new CosmoPaths();
$site = '/' . $cosmo_path->getSite() . '/';
$cfgfile = $cosmo_path->getConfigPath();
$cfg=lireConfig($cfgfile);
$sql = new sql($cfg["integration_server"],$cfg["integration_user"],$cfg["integration_pwd"],$cfg["integration_base"]);
// Tentatives de reconnexion
$phase_data["nb_reconnexions"]++;
if ($phase_data["nb_reconnexions"] >= $Z3950_max_reconnect)
{
$log->ecrire(BR . '<span class="rouge">Abandon du traitement : maximum de tentatives de reconnexions atteint</span>' . BR);
$fin = true;
break;
}
sleep(5);
}
if ($fin == true) break;
$phase_data["isbn"] = $data["isbn"];
$phase_data["nombre"]++;
}
afficherRecapHomogene($phase_data, $chrono);
}
// ----------------------------------------------------------------