Prepare PHP v8 - mktime() and gmmktime() are no more allowed

This commit is contained in:
Laurent Destailleur 2020-02-19 11:59:27 +01:00
parent ac16857501
commit 1dd5ba093d
7 changed files with 12 additions and 11 deletions

View File

@ -66,8 +66,9 @@ $obj = new Facture($db);
$obj->ref = 'ABCDE';
$obj->socid = 4; // Put id of third party (rowid in llx_societe table)
$obj->date = mktime();
$obj->note = 'A comment';
$obj->date = dol_now();
$obj->note_public = 'A public comment';
$obj->note_private = 'A private comment';
$obj->cond_reglement_id = 1;
$line1=new FactureLigne($db);

View File

@ -66,8 +66,9 @@ $com = new Commande($db);
$com->ref = 'ABCDE';
$com->socid = 4; // Put id of third party (rowid in llx_societe table)
$com->date_commande = mktime();
$com->note = 'A comment';
$com->date = dol_now();
$com->note_public = 'A public comment';
$com->note_private = 'A private comment';
$com->source = 1;
$com->remise_percent = 0;

View File

@ -407,7 +407,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++)
print "<td>".dol_print_date(dol_mktime(12,0,0,$mois,1,2000),"%B")."</td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
$casenow = dol_print_date(mktime(),"%Y-%m");
$casenow = dol_print_date(dol_now(),"%Y-%m");
$case = dol_print_date(dol_mktime(1,1,1,$mois,1,$annee),"%Y-%m");
$caseprev = dol_print_date(dol_mktime(1,1,1,$mois,1,$annee-1),"%Y-%m");

View File

@ -1397,7 +1397,8 @@ class Ldap
//Parse flags to text
$retval = array();
while (list($flag, $val) = each($flags)) {
//while (list($flag, $val) = each($flags)) {
foreach ($flags as $flag => $val) {
if ($uacf >= $val) {
$uacf -= $val;
$retval[$val] = $flag;

View File

@ -2102,8 +2102,6 @@ function dol_now($mode = 'gmt')
{
$ret = 0;
// Note that gmmktime and mktime return same value (GMT) when used without parameters
//if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead
if ($mode == 'gmt') $ret = time(); // Time for now at greenwich.
elseif ($mode == 'tzserver') // Time for now with PHP server timezone added
{
@ -2119,7 +2117,7 @@ function dol_now($mode = 'gmt')
}*/
elseif ($mode == 'tzuser') // Time for now with user timezone added
{
//print 'time: '.time().'-'.mktime().'-'.gmmktime();
//print 'time: '.time();
$offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60;
$offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60;
$ret = (int) (dol_now('gmt') + ($offsettz + $offsetdst));

View File

@ -1486,7 +1486,7 @@ class ExpenseReport extends CommonObject
{
// phpcs:enable
$error = 0;
$this->date_cancel = $this->db->idate(gmmktime());
$this->date_cancel = $this->db->idate(dol_now());
if ($this->fk_statut != self::STATUS_CANCELED)
{
$this->db->begin();

View File

@ -353,7 +353,7 @@ if (empty($reshook))
$desc .= '<br>';
$desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')';
$timearray = dol_getdate(mktime());
$timearray = dol_getdate(dol_now());
$date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
if ($product_type == Product::TYPE_PRODUCT) {