Skip to content

Commit

Permalink
Merge branch 'develop' into fix-phpstan-no-langs
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Oct 3, 2024
2 parents ae542c7 + e426c94 commit 44f7572
Show file tree
Hide file tree
Showing 32 changed files with 169 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup MariaDB
uses: ankane/setup-mariadb@v1
uses: frederic34/setup-mariadb@v1
with:
# mariadb-version: ${{ matrix.mariadb-version }}
database: travis # Specify your database name
Expand Down
1 change: 1 addition & 0 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ return [
'htdocs/compta/bank/various_payment/info.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/compta/bank/various_payment/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty'],
'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/cashcontrol/cashcontrol_list.php' => ['PhanTypeMismatchProperty'],
'htdocs/compta/cashcontrol/class/cashcontrol.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/compta/charges/index.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/compta/clients.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
Expand Down
24 changes: 13 additions & 11 deletions htdocs/admin/system/database.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2004-2014 Laurent Destailleur <[email protected]>
* Copyright (C) 2004 Sebastien Di Cintio <[email protected]>
* Copyright (C) 2004 Benoit Mortier <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2004-2014 Laurent Destailleur <[email protected]>
* Copyright (C) 2004 Sebastien Di Cintio <[email protected]>
* Copyright (C) 2004 Benoit Mortier <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,19 +42,19 @@
*/

if ($action == 'convertutf8unicode') { // Test on permission already done.
$sql = "ALTER DATABASE ".$db->sanitize($table[0])." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
$sql = "ALTER DATABASE ".$db->sanitize($db->database_name)." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
$db->query($sql);
}
if ($action == 'convertutf8mb4unicode') { // Test on permission already done.
$sql = "ALTER DATABASE ".$db->sanitize($table[0])." CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
$sql = "ALTER DATABASE CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
$db->query($sql);
}
if ($action == 'convertutf8general') { // Test on permission already done.
$sql = "ALTER DATABASE ".$db->sanitize($table[0])." CHARACTER SET utf8 COLLATE utf8_general_ci";
$sql = "ALTER DATABASE ".$db->sanitize($db->database_name)." CHARACTER SET utf8 COLLATE utf8_general_ci";
$db->query($sql);
}
if ($action == 'convertutf8mb4general') { // Test on permission already done.
$sql = "ALTER DATABASE ".$db->sanitize($table[0])." CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci";
$sql = "ALTER DATABASE ".$db->sanitize($db->database_name)." CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci";
$db->query($sql);
}

Expand Down Expand Up @@ -90,9 +91,10 @@
print '<tr class="oddeven"><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>';
$defaultcollation = $db->getDefaultCollationDatabase();
print dolPrintHTML($defaultcollation);
global $dolibarr_main_db_collation;
if ($db->type == 'mysqli') {
if ($defaultcollation != $dolibarr_main_db_collation) {
print img_warning('The database default value of collation '.$defaultcollation.' differs from conf setup '.$dolibarr_main_db_collation);
if ($defaultcollation != $conf->db->dolibarr_main_db_collation) {
print img_warning('The database default value of collation '.$defaultcollation.' differs from conf setup '.$conf->db->dolibarr_main_db_collation);
}
$tooltipexample = "<br>SHOW VARIABLES LIKE 'collation_database' (cached)<br>You can avoid cache effect with:<br>SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '".$db->escape($conf->db->name)."'";
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetValue", $tooltipexample.'<br>'.$langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "<br>SHOW COLLATION")));
Expand Down
5 changes: 3 additions & 2 deletions htdocs/admin/system/dbtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Copyright (C) 2004 Sebastien Di Cintio <[email protected]>
* Copyright (C) 2004 Benoit Mortier <[email protected]>
* Copyright (C) 2005-2012 Regis Houssin <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -63,7 +64,7 @@
}

$sql = "ALTER TABLE ".$db->sanitize($table)." MODIFY ".$db->sanitize($row[0])." ".$row[1]." COLLATE ".$db->sanitize($collation); // We must not sanitize the $row[1]
$reslq2 = $db->query($sql);
$resql2 = $db->query($sql);
if (!$resql2) {
setEventMessages($db->lasterror(), null, 'warnings');
}
Expand Down
15 changes: 8 additions & 7 deletions htdocs/compta/cashcontrol/cashcontrol_card.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <[email protected]>
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2004-2013 Laurent Destailleur <[email protected]>
* Copyright (C) 2005-2009 Regis Houssin <[email protected]>
* Copyright (C) 2013 Charles-Fr BENKE <[email protected]>
* Copyright (C) 2015 Jean-François Ferry <[email protected]>
* Copyright (C) 2016 Marcos García <[email protected]>
* Copyright (C) 2018 Andreu Bisquerra <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -162,15 +163,15 @@
}
$error = 0;
foreach ($arrayofpaymentmode as $key => $val) {
$object->$key = price2num(GETPOST($key.'_amount', 'alpha'));
$object->$key = (float) price2num(GETPOST($key.'_amount', 'alpha'));
}

if (!$error) {
$object->day_close = GETPOSTINT('closeday');
$object->month_close = GETPOSTINT('closemonth');
$object->year_close = GETPOSTINT('closeyear');

$object->opening = price2num(GETPOST('opening', 'alpha'));
$object->opening = (float) price2num(GETPOST('opening', 'alpha'));
$object->posmodule = GETPOST('posmodule', 'alpha');
$object->posnumber = GETPOST('posnumber', 'alpha');

Expand Down Expand Up @@ -206,9 +207,9 @@
$object->year_close = GETPOST('closeyear', 'int');
*/

$object->cash = price2num(GETPOST('cash_amount', 'alpha'));
$object->card = price2num(GETPOST('card_amount', 'alpha'));
$object->cheque = price2num(GETPOST('cheque_amount', 'alpha'));
$object->cash = (float) price2num(GETPOST('cash_amount', 'alpha'));
$object->card = (float) price2num(GETPOST('card_amount', 'alpha'));
$object->cheque = (float) price2num(GETPOST('cheque_amount', 'alpha'));

$result = $object->update($user);

Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/cashcontrol/cashcontrol_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,10 @@

$object->posmodule = $obj->posmodule;
$object->cash = $obj->cash;
$object->cheque = $obj->cheque;
$object->card = $obj->card;
$object->opening = $obj->opening;
$object->year_close = $obj->year_close;
$object->cheque = $obj->cheque;

// Output Kanban
$selected = -1;
Expand Down
53 changes: 52 additions & 1 deletion htdocs/compta/cashcontrol/class/cashcontrol.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,75 @@ class CashControl extends CommonObject
* @var int Object Id
*/
public $id;

/**
* @var string Label
*/
public $label;

/**
* @var float Amount at opening
*/
public $opening;

/**
* @var int Status
*/
public $status;

/**
* @var int Year close
*/
public $year_close;

/**
* @var int Month close
*/
public $month_close;

/**
* @var int Day close
*/
public $day_close;

/**
* @var string posmodule
*/
public $posmodule;

/**
* @var string posnumber
*/
public $posnumber;

/**
* @var float Cash amount
*/
public $cash;

/**
* @var float cheque amount
*/
public $cheque;

/**
* @var float Card amountS
*/
public $card;

/**
* @var int User ID create
*/
public $fk_user_creat;

/**
* @var int|string $date_valid
* @var int|'' $date_valid
*/
public $date_valid;

/**
* @var int User ID
*/
public $fk_user_valid;


Expand Down
2 changes: 1 addition & 1 deletion htdocs/contact/class/contact.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ public function fetch($id, $user = null, $ref_ext = '', $email = '', $loadalsoro
* @param string $email Email
* @param string $ref_alias Name alias (TODO Not yet implemented)
* @param int $socid Filter on thirdparty id
* @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found.
* @return int ID of contact if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found.
*/
public function findNearest($id = 0, $lastname = '', $firstname = '', $ref_ext = '', $email = '', $ref_alias = '', $socid = 0)
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contact/document.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2014-2024 Alexandre Spangaro <[email protected]>
* Copyright (C) 2015-2021 Frederic France <[email protected]>
* Copyright (C) 2015-2024 Frédéric France <[email protected]>
* Copyright (C) 2017 Regis Houssin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/actions_linkedfiles.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
}
}


// Delete file/link
if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissiontoadd)) {
$urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1);
Expand Down Expand Up @@ -254,13 +253,14 @@
if ($filenamefrom && $filenameto) {
$srcpath = $upload_dir.'/'.$filenamefrom;
$destpath = $upload_dir.'/'.$filenameto;
/* disabled. Too many bugs. All files of an object must remain into directory of object. link with event should be done in llx_ecm_files with column agenda_id.
if ($modulepart == "ticket" && !dol_is_file($srcpath)) {
$srcbis = $conf->agenda->dir_output.'/'.GETPOST('section_dir').$filenamefrom;
if (dol_is_file($srcbis)) {
$srcpath = $srcbis;
$destpath = $conf->agenda->dir_output.'/'.GETPOST('section_dir').$filenameto;
}
}
}*/

$reshook = $hookmanager->initHooks(array('actionlinkedfiles'));
$parameters = array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir);
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/actions_printing.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2014-2016 Laurent Destailleur <[email protected]>
* Copyright (C) 2014-2018 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <[email protected]>
/* Copyright (C) 2014-2016 Laurent Destailleur <[email protected]>
* Copyright (C) 2014-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/class/html.formprojet.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* Copyright (c) 2013 Florian Henry <[email protected]>
* Copyright (C) 2015 Marcos García <[email protected]>
* Copyright (C) 2018 Charlene Benke <[email protected]>
/* Copyright (c) 2013 Florian Henry <[email protected]>
* Copyright (C) 2015 Marcos García <[email protected]>
* Copyright (C) 2018 Charlene Benke <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Benjamin Falière <[email protected]>
Expand Down Expand Up @@ -402,7 +402,7 @@ public function selectTasks($socid = -1, $selected = 0, $htmlname = 'taskid', $m
if (!empty($show_empty)) {
$out .= '<option value="0" class="optiongrey">';
if (!is_numeric($show_empty)) {
//if (!empty($conf->use_javascript_ajax)) $out .= '<span class="opacitymedium">aaa';
//if (!empty($conf->use_javascript_ajax)) $out .= '<span class="opacitymedium">';
$out .= $show_empty;
//if (!empty($conf->use_javascript_ajax)) $out .= '</span>';
} else {
Expand Down
2 changes: 2 additions & 0 deletions htdocs/core/class/html.formticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ function(response) {
print dol_get_fiche_end();
}

print '<br>';

if ($mode == 'create') {
print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : ""));
} else {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/admin.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ function unActivateModule($value, $requiredby = 1)
}

// Disable modules that depends on module we disable
if (!$ret && $requiredby && is_object($objMod) && is_array($objMod->requiredby)) {
if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
$countrb = count($objMod->requiredby);
for ($i = 0; $i < $countrb; $i++) {
//var_dump($objMod->requiredby[$i]);
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/lib/files.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,8 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
$ok = true;
$globencoded = str_replace('[', '\[', $file_osencoded);
$globencoded = str_replace(']', '\]', $globencoded);
$listofdir = glob($globencoded);
$listofdir = glob($globencoded); // This scan dir for files. If file does not exists, return empty.

if (!empty($listofdir) && is_array($listofdir)) {
foreach ($listofdir as $filename) {
if ($nophperrors) {
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -6332,7 +6332,7 @@ function load_fiche_titre($title, $morehtmlright = '', $picto = 'generic', $pict
}

$return .= "\n";
$return .= '<table '.($id ? 'id="'.$id.'" ' : '').'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ? ' '.$morecssontable : '').'">'; // maring bottom must be same than into print_barre_list
$return .= '<table '.($id ? 'id="'.$id.'" ' : '').'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ? ' '.$morecssontable : '').'">'; // margin bottom must be same than into print_barre_list
$return .= '<tr class="titre">';
if ($picto) {
$return .= '<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).'</td>';
Expand Down Expand Up @@ -6407,7 +6407,7 @@ function print_barre_liste($title, $page, $file, $options = '', $sortfield = '',

print "\n";
print "<!-- Begin print_barre_liste -->\n";
print '<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ? ' '.$morecss : '').'"><tr>'; // maring bottom must be same than into load_fiche_tire
print '<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ? ' '.$morecss : '').'"><tr>'; // margin bottom must be same than into load_fiche_tire

// Left

Expand Down
2 changes: 2 additions & 0 deletions htdocs/core/lib/ticket.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function ticket_prepare_head($object)
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$upload_dir = $conf->ticket->dir_output."/".$object->ref;
$nbFiles = count(dol_dir_list($upload_dir, 'files'));
/* disabled. Too many bugs. All file of a ticket must be stored into ticket. File must be linked to an event by column agenda_id into llx_ecmfiles.
$sql = 'SELECT id FROM '.MAIN_DB_PREFIX.'actioncomm';
$sql .= " WHERE fk_element = ".(int) $object->id." AND elementtype = 'ticket'";
$resql = $db->query($sql);
Expand All @@ -119,6 +120,7 @@ function ticket_prepare_head($object)
$nbFiles += count(dol_dir_list($upload_msg_dir, "files"));
}
}
*/
$head[$h][0] = DOL_URL_ROOT.'/ticket/document.php?id='.$object->id;
$head[$h][1] = $langs->trans("Documents");
if ($nbFiles > 0) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/oauth/microsoft_oauthcallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
// Microsoft is a service that does not need state to be stored as second parameter of requestAccessToken

//print $token->getAccessToken().'<br><br>';
//print $token->getExtraParams()['id_token'].'<br>';
//print $token->getExtraParams()['id_token'].'<br><br>';
//print $token->getRefreshToken().'<br>';exit;

setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1589,9 +1589,12 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf

if ($ret > 0 && getDolGlobalString('MAIN_COPY_FILE_IN_EVENT_AUTO')) {
if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) {
// Get directory of object
$tmpelems = getElementProperties($object->element.($object->module ? '@'.$object->module : ''));
$destdir = $tmpelems['dir_output'].'/'.$ret;

foreach ($object->attachedfiles['paths'] as $key => $filespath) {
$srcfile = $filespath;
$destdir = $conf->agenda->dir_output.'/'.$ret;
$destfile = $destdir.'/'.$object->attachedfiles['names'][$key];
if (dol_mkdir($destdir) >= 0) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/emailcollector/class/emailcollector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2716,12 +2716,12 @@ public function doCollectOneCollector($mode = 0)
}
}
}
} else {
} else { // $result > 0 is ID of thirdparty
dol_syslog("One and only one existing third party has been found");

$thirdpartystatic->fetch($result);

$operationslog .= '<br>Thirdparty already exists with id = '.dol_escape_htmltag($thirdpartystatic->id);
$operationslog .= '<br>Thirdparty already exists with id = '.dol_escape_htmltag($thirdpartystatic->id)." and name ".dol_escape_all($thirdpartystatic->name);
}
}
}
Expand Down
Loading

0 comments on commit 44f7572

Please sign in to comment.