Skip to content

Commit

Permalink
Merge branch 'develop' of [email protected]:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Aug 27, 2024
2 parents e7cfa4d + f07ebe0 commit 26ceda2
Show file tree
Hide file tree
Showing 34 changed files with 732 additions and 214 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# This is faster for a big repo.
- name: Get all changed php files (if PR)
id: changed-php
uses: tj-actions/changed-files@v44
uses: tj-actions/changed-files@v45
if: env.gh_event == 'pull_request'
with:
files: |
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
# The next uses git, which is slow for a bit repo.
# - name: Get all changed php files (if PR)
# id: changed-php
# uses: tj-actions/changed-files@v44
# uses: tj-actions/changed-files@v45
# if: env.gh_event == 'pull_request'
# with:
# files: |
Expand Down
13 changes: 6 additions & 7 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ return [
'htdocs/admin/mails_templates.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/admin/menus.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/admin/menus/edit.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/admin/modulehelp.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchDimFetchNullable', 'PhanUndeclaredGlobalVariable'],
'htdocs/admin/modulehelp.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/admin/modules.php' => ['PhanEmptyFQSENInClasslike', 'PhanInvalidFQSENInClasslike', 'PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'],
'htdocs/admin/mrp.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/admin/mrp_extrafields.php' => ['PhanUndeclaredGlobalVariable'],
Expand Down Expand Up @@ -470,7 +470,7 @@ return [
'htdocs/core/class/rssparser.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeExpectedObjectPropAccess'],
'htdocs/core/class/smtps.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchDimFetch'],
'htdocs/core/class/socialnetworkmanager.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/core/class/stats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'],
'htdocs/core/class/stats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'],
'htdocs/core/class/timespent.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/core/class/translate.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/core/class/utils.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
Expand Down Expand Up @@ -603,7 +603,7 @@ return [
'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/import/import_csv.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/core/modules/import/modules_import.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchDimFetch'],
'htdocs/core/modules/import/modules_import.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchDimFetch'],
'htdocs/core/modules/mailings/advthirdparties.modules.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/core/modules/mailings/contacts1.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/mailings/modules_mailings.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'],
Expand Down Expand Up @@ -703,7 +703,6 @@ return [
'htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php' => ['PhanPluginUnknownObjectMethodCall'],
'htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php' => ['PhanPluginUnknownObjectMethodCall'],
'htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php' => ['PhanPluginUnknownObjectMethodCall'],
'htdocs/core/triggers/interface_50_modNotification_Notification.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeExpectedObjectPropAccess'],
Expand Down Expand Up @@ -752,7 +751,7 @@ return [
'htdocs/ecm/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/ecm/index_auto.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/ecm/index_medias.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/emailcollector/class/emailcollector.class.php' => ['PhanInvalidFQSENInClasslike', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/emailcollector/class/emailcollector.class.php' => ['PhanInvalidFQSENInClasslike', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/emailcollector/class/emailcollectoraction.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/emailcollector/class/emailcollectorfilter.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/emailcollector/lib/emailcollector.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
Expand Down Expand Up @@ -864,9 +863,9 @@ return [
'htdocs/hrm/skill_card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/hrm/skill_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/skill_tab.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/imports/class/import.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType'],
'htdocs/imports/class/import.class.php' => ['PhanPluginEmptyStatementIf'],
'htdocs/imports/emptyexample.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/imports/import.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/imports/import.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/install/check.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/install/fileconf.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
Expand Down
10 changes: 4 additions & 6 deletions dev/tools/phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@
'menumanager' => '\MenuManager',
'mysoc' => '\Societe',
'nblines' => '\int',
'obj' => '\CommonObject', // Deprecated
'object_rights' => 'int|stdClass',
'objectoffield' => '\CommonObject',
'objsoc' => '\Societe',
'senderissupplier' => 'int<0,2>',
Expand Down Expand Up @@ -419,12 +417,12 @@

'PhanCompatibleNegativeStringOffset', // return false positive
'PhanPluginConstantVariableBool', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanPluginUnknownArrayPropertyType', // this option costs more time to be supported than it solves time
// 'PhanPluginUnknownArrayPropertyType', // this option costs more time to be supported than it solves time
'PhanTypeArraySuspiciousNullable', // this option costs more time to be supported than it solves time
'PhanTypeInvalidDimOffset', // this option costs more time to be supported than it solves time
'PhanTypeObjectUnsetDeclaredProperty',
'PhanTypePossiblyInvalidDimOffset', // a lot of false positive, in most cases, we want to keep the code as it is
'PhanPluginUnknownArrayFunctionReturnType', // a lot of false positive, in most cases, we want to keep the code as it is
// 'PhanPluginUnknownArrayFunctionReturnType', // a lot of false positive, in most cases, we want to keep the code as it is

'PhanPluginWhitespaceTab', // Dolibarr used tabs
'PhanPluginCanUsePHP71Void', // Dolibarr is maintaining 7.0 compatibility
Expand All @@ -448,8 +446,8 @@
'PhanPluginRedundantAssignment', // Not essential, useless
'PhanPluginDuplicateCatchStatementBody', // Requires PHP7.1 - 50+ occurrences

'PhanPluginUnknownArrayMethodParamType', // Too many troubles to manage. Is enabled in config_extended only.
'PhanPluginUnknownArrayMethodReturnType', // Too many troubles to manage. Is enabled in config_extended only.
// 'PhanPluginUnknownArrayMethodParamType', // Too many troubles to manage. Is enabled in config_extended only.
// 'PhanPluginUnknownArrayMethodReturnType', // Too many troubles to manage. Is enabled in config_extended only.
'PhanUndeclaredGlobalVariable', // Too many false positives on .tpl.php files. Is enabled into config_extended only.
// 'PhanPluginUnknownObjectMethodCall', // False positive for some class. Is enabled in config_extended only.
],
Expand Down
37 changes: 29 additions & 8 deletions htdocs/adherents/class/api_subscriptions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ public function get($id)
*
* Get a list of subscriptions
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
* @return array Array of subscription objects
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
* @return array Array of subscription objects
*
* @throws RestException 403 Access denied
* @throws RestException 404 No Subscription found
* @throws RestException 503 Error when retrieving Subscription list
*/
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '')
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false)
{
global $conf;

Expand All @@ -111,6 +112,9 @@ public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100,
}
}

//this query will return total orders with the filters given
$sqlTotals = str_replace('SELECT rowid', 'SELECT count(rowid) as total', $sql);

$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
Expand All @@ -137,6 +141,23 @@ public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100,
throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror());
}

//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
if ($pagination_data) {
$totalsResult = $this->db->query($sqlTotals);
$total = $this->db->fetch_object($totalsResult)->total;

$tmp = $obj_ret;
$obj_ret = [];

$obj_ret['data'] = $tmp;
$obj_ret['pagination'] = [
'total' => (int) $total,
'page' => $page, //count starts from 0
'page_count' => ceil((int) $total / $limit),
'limit' => $limit
];
}

return $obj_ret;
}

Expand Down
16 changes: 13 additions & 3 deletions htdocs/admin/modulehelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@


$filename = array();
'@phan-var-force DolibarrModules[] $modules';
$modules = array();
$orders = array();
$categ = array();
Expand Down Expand Up @@ -225,10 +226,13 @@
//var_dump($modules);


unset($objMod);
$objMod = null;
$dirofmodule = null;
$key = -1;
$i = 0;
foreach ($orders as $tmpkey => $tmpvalue) {
$tmpMod = $modules[$tmpkey];
'@phan-var-force DolibarrModules $tmpMod';
if ($tmpMod->numero == $id) {
$key = $i;
$modName = $filename[$tmpkey];
Expand All @@ -238,6 +242,12 @@
}
$i++;
}
if (!is_object($objMod)) {
$msg = __FILE__." Module with no found for id:".$id;
dol_syslog($msg, LOG_ERR);
return;
}

$value = $orders[$key];
$tab = explode('_', $value);
$familyposition = $tab[0];
Expand Down Expand Up @@ -346,11 +356,11 @@

$textexternal = '';
if ($objMod->isCoreOrExternalModule() == 'external') {
$tmpdirofmoduletoshow = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $dirofmodule);
$tmpdirofmoduletoshow = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', (string) $dirofmodule);
$textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $tmpdirofmoduletoshow);

global $dolibarr_allow_download_external_modules;
if (!empty($dolibarr_allow_download_external_modules) && preg_match('/\/custom\//', $dirofmodule)) {
if (!empty($dolibarr_allow_download_external_modules) && preg_match('/\/custom\//', (string) $dirofmodule)) {
// Add a link to download a zip of the module
$textexternal .= ' <a href="'.DOL_URL_ROOT.'/admin/tools/export_files.php?export_type=externalmodule&what='.urlencode($moduledir).'&compression=zip&zipfilename_template=module_'.$moduledir.'-'.$version.'.notorig" target="_blank" rel="noopener">'.img_picto('', 'download').'</a>';
}
Expand Down
7 changes: 3 additions & 4 deletions htdocs/admin/system/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
$todisabletext = '';
$i = 0;
foreach ($arrayoffunctionstodisable as $functiontodisable) {
if (! in_array($functiontodisable, $arrayoffunctionsdisabled)) {
if (\function_exists($functiontodisable)) {
if ($i > 0) {
$todisabletext .= ', ';
}
Expand All @@ -170,7 +170,7 @@
$todisabletext = '';
$i = 0;
foreach ($arrayoffunctionstodisable2 as $functiontodisable) {
if (! in_array($functiontodisable, $arrayoffunctionsdisabled)) {
if (\function_exists($functiontodisable)) {
if ($i > 0) {
$todisabletext .= ', ';
}
Expand All @@ -182,8 +182,7 @@
print img_picto('', 'warning', 'class="pictofixedwidth"').$langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
print '<br>';
}

if (in_array($functiontokeep, $arrayoffunctionsdisabled)) {
if (!\function_exists($functiontokeep)) {
print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning', 'class="pictofixedwidth"');
} else {
print img_picto('', 'tick', 'class="pictofixedwidth"');
Expand Down
Loading

0 comments on commit 26ceda2

Please sign in to comment.