From ef57cde3da8b2798dfd97970706e9c81573aa6c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jun 2022 13:25:42 +0200 Subject: [PATCH] Debug v16 (module_name missing in list, pb in searching duplicate cron) --- htdocs/core/modules/DolibarrModules.class.php | 9 ++++--- htdocs/cron/list.php | 25 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 80ed0b345ba..627a13a7844 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1452,8 +1452,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Search if cron entry already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; - $sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; - if ($class) { + //$sql .= " WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."'"; + $sql .= " WHERE label = '".$this->db->escape($label)."'"; + /*if ($class) { $sql .= " AND classesname = '".$this->db->escape($class)."'"; } if ($objectname) { @@ -1467,7 +1468,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } if ($parameters) { $sql .= " AND params = '".$this->db->escape($parameters)."'"; - } + }*/ $sql .= " AND entity = ".((int) $entity); // Must be exact entity $now = dol_now(); @@ -1516,7 +1517,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $sql .= "'".$this->db->escape($priority)."', "; } if (is_int($status)) { - $sql .= "'".$this->db->escape($status)."', "; + $sql .= ((int) $status).", "; } $sql .= $entity.","; $sql .= "'".$this->db->escape($test)."'"; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index e93434f725a..40fe27d3404 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -283,12 +283,8 @@ if (is_array($filter) && count($filter) > 0) { $sql .= " AND ".$key." LIKE '%".$db->escape($value)."%'"; } } -$sqlwhere = array(); if (!empty($search_module_name)) { - $sqlwhere[] = "(t.module_name = '".$db->escape($search_module_name)."')"; -} -if (count($sqlwhere) > 0) { - $sql .= " WHERE ".implode(' AND ', $sqlwhere); + $sql .= natural_search("t.module_name", $search_module_name); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -435,6 +431,7 @@ print ''; print ''; print ''; print ' '; +print ''; print ' '; print ' '; //print ' '; @@ -457,6 +454,7 @@ print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "t.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("CronLabel", $_SERVER["PHP_SELF"], "t.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Prority", $_SERVER["PHP_SELF"], "t.priority", "", $param, '', $sortfield, $sortorder); +print_liste_field_titre("CronModule", $_SERVER["PHP_SELF"], "t.module_name", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("CronType", '', '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("CronFrequency", '', "", "", $param, '', $sortfield, $sortorder); //print_liste_field_titre("CronDtStart", $_SERVER["PHP_SELF"], "t.datestart", "", $param, 'align="center"', $sortfield, $sortorder); @@ -500,6 +498,7 @@ if ($num > 0) { $object->lastresult = $obj->lastresult; $object->datestart = $db->jdate($obj->datestart); $object->dateend = $db->jdate($obj->dateend); + $object->module_name = $obj->module_name; $datelastrun = $db->jdate($obj->datelastrun); $datelastresult = $db->jdate($obj->datelastresult); @@ -524,9 +523,15 @@ if ($num > 0) { // Priority print ''; - print $object->priority; + print dol_escape_htmltag($object->priority); print ''; + // Module + print ''; + print dol_escape_htmltag($object->module_name); + print ''; + + // Class/Method print ''; if ($obj->jobtype == 'method') { $text = $langs->trans("CronClass"); @@ -576,12 +581,12 @@ if ($num > 0) { print ''; if (!empty($obj->nbrun)) { - print $obj->nbrun; + print dol_escape_htmltag($obj->nbrun); } else { print '0'; } if (!empty($obj->maxrun)) { - print ' / '.$obj->maxrun.''; + print ' / '.dol_escape_htmltag($obj->maxrun).''; } print ''; @@ -606,9 +611,9 @@ if ($num > 0) { print ''; if ($obj->lastresult != '') { if (empty($obj->lastresult)) { - print $obj->lastresult; + print $obj->lastresult; // Print '0' } else { - print ''.dol_trunc($obj->lastresult).''; + print ''.dol_escape_htmltag(dol_trunc($obj->lastresult)).''; } } print '';