Fix warning.

Reduce memory need for getmin/max on large graphs.
This commit is contained in:
Laurent Destailleur 2021-07-08 11:13:15 +02:00
parent 2acbdc2c80
commit 16ee47b12c
3 changed files with 26 additions and 24 deletions

View File

@ -85,7 +85,7 @@ class box_scheduled_jobs extends ModeleBoxes
$resultarray = array();
$result = 0;
$sql = "SELECT t.rowid, t.datelastrun, t.datenextrun,";
$sql = "SELECT t.rowid, t.datelastrun, t.datenextrun, t.datestart,";
$sql .= " t.label, t.status, t.test, t.lastresult";
$sql .= " FROM " . MAIN_DB_PREFIX . "cronjob as t";
$sql .= " WHERE status <> ".$cronstatic::STATUS_DISABLED;

View File

@ -596,7 +596,7 @@ class DolGraph
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Get max value
* Get max value among all values of all series
*
* @return int Max value
*/
@ -607,25 +607,26 @@ class DolGraph
return 0;
}
$k = 0;
$vals = array();
$max = null;
$nblines = count($this->data);
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
$nbseries = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
for ($j = 0; $j < $nblines; $j++) {
for ($i = 0; $i < $nbvalues; $i++) {
$vals[$k] = $this->data[$j][$i + 1];
$k++;
foreach($this->data as $x) { // Loop on each x
for ($i = 0; $i < $nbseries; $i++) { // Loop on each serie
if (is_null($max)) {
$max = $x[$i + 1]; // $i+1 because the index 0 is the legend
} elseif ($max < $x[$i + 1]) {
$max = $x[$i + 1];
}
}
}
rsort($vals);
return $vals[0];
return $max;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return min value of all data
* Return min value of all values of all series
*
* @return int Min value of all data
*/
@ -636,20 +637,21 @@ class DolGraph
return 0;
}
$k = 0;
$vals = array();
$min = null;
$nblines = count($this->data);
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
$nbseries = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
for ($j = 0; $j < $nblines; $j++) {
for ($i = 0; $i < $nbvalues; $i++) {
$vals[$k] = $this->data[$j][$i + 1];
$k++;
foreach($this->data as $x) { // Loop on each x
for ($i = 0; $i < $nbseries; $i++) { // Loop on each serie
if (is_null($min)) {
$min = $x[$i + 1]; // $i+1 because the index 0 is the legend
} elseif ($min > $x[$i + 1]) {
$min = $x[$i + 1];
}
}
}
sort($vals);
return $vals[0];
return $min;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View File

@ -1854,7 +1854,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $conf->browser->layout != 'phone') {
$qs = dol_escape_htmltag($_SERVER["QUERY_STRING"]);
if (is_array($_POST)) {
if (isset($_POST) && is_array($_POST)) {
foreach ($_POST as $key => $value) {
if ($key !== 'action' && $key !== 'password' && !is_array($value)) {
$qs .= '&'.$key.'='.urlencode($value);