Commit Graph

3751 Commits

Author SHA1 Message Date
Laurent Destailleur
cc6fbef64d Update functions.lib.php 2024-03-12 14:44:48 +01:00
Laurent Destailleur
53c3406d11 Merge branch 'develop' into fix_element_type_part_05 2024-03-12 14:22:25 +01:00
Laurent Destailleur
dcca7cc3f6 Better support for MAIN_OPTIMIZEFORTEXTBROWSER 2024-03-12 02:54:05 +01:00
Laurent Destailleur
56950673b8 Better support for MAIN_OPTIMIZEFORTEXTBROWSER 2024-03-12 02:41:47 +01:00
Laurent Destailleur
93638f3980 Merge pull request #28667 from atm-john/fix_element_type_part_03
NEW : Factoring and Fix external module elementType limit - Part 03
2024-03-11 16:19:00 +01:00
Laurent Destailleur
41078a9a46 Merge branch 'develop' into test/security_dol_eval_ob_cleanup_on_exception 2024-03-11 14:57:33 +01:00
John BOTELLA
ed6874154d Merge branch 'develop' into fix_element_type_part_05 2024-03-11 14:33:48 +01:00
Laurent Destailleur
0f2121e3ba Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-11 13:46:08 +01:00
Laurent Destailleur
ff0d147847 Merge branch 'develop' into test/security_dol_eval_ob_cleanup_on_exception 2024-03-11 12:48:31 +01:00
Laurent Destailleur
a327d39062 Fix warning 2024-03-11 11:39:51 +01:00
MDW
101d56a2c1 Fix: Ob buffer cleanup on exception
# Fix: Ob buffer cleanup on exception

The OB buffer capture was incorrectly cleaned up on exception.
This fixes that.

Also modified the SecurityTest to enable running it standalone
2024-03-10 15:17:58 +01:00
Laurent Destailleur
429476e293 Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-10 01:53:32 +01:00
MDW
37afba949e Fix most PhanTypeMismatchDimAssignment notices (#28739)
* Qual: Add typing to fix PhanTypeMismatchDimAssignment notice

* Fix: Initialise array for code in somme

* Qual: Update type hint for  argument in _Set_Format

* Qual: Update type hint for childtables

* Qual: Add typing to attributes

* Qual: Add typing for _msgContent

* Qual: Suppress PhanTypeMismatchDimAssignment

* Qual: Add typing for liste

* Qual: Add typing to fields

* Qual: Add typing hint for $objMod

* Qual: Modify assignment of array with bool keys for phan typing

Demonstration:
```
php -r '$a=[true=>"yes",false=>"no"];var_dump($a);'
# Result demonstrates bool keys are converted to int.
Command line code:1:
array(2) {
  [1] =>
  string(3) "yes"
  [0] =>
  string(2) "no"
}
```

* Qual: Add typing hint to indicate value is not null

* Force non-null type on $paramname

* Qual: Add typing hint to getCats()

* Update inc.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-03-10 01:53:04 +01:00
Laurent Destailleur
28df0ba1ab Fix doc 2024-03-10 01:49:56 +01:00
MDW
c95bab2818 Qual: Add check on addExtraField type argument (#28738)
* Qual: Add check on addExtraField type argument

# Qual: Add check on addExtraField type argument

Added a check on the type argument for addExtraField

* Qual: Update phan ignore with more specific name
2024-03-10 01:46:10 +01:00
MDW
0b19aa415c Fix: Initialise array before assigning values (#28728)
* Qual: Enable PhanUndeclaredVariableDim

# Qual: Enable PhanUndeclaredVariableDim

The notifications are fixed in the code so the detection no longer
needs to be suppressed in the default flow

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Fix: initialise array before adding fields

* Qual: Add type hint to array to avoid phan notification

* Qual: Add type hint to array to avoid phan notification

* Qual: Enable PhanParamSpecial1 (all resolved)

* Qual: Ignore false PhanTypeArraySuspiciousNullable

* Qual: Improve typing to fix PhanTypeArraySuspicious

* Qual: Fix PhanTypeArraySuspicious by replacing null assignment with empty array

* Qual: Fix PhanTypeArraySuspicious by testing as instancof DebugBar

* Qual: Fix PhanTypeComparisonToArray with enhanced typing

* Qual: Fix PhanTypeComparisonToArray with enhanced typing

* Qual: Enable phan messages that no longer appear

* Qual: Exclude phan stubs from codesniffer ruleset
2024-03-09 16:32:02 +01:00
Laurent Destailleur
abc57a767b Merge branch 'develop' into fix_element_type_part_05 2024-03-09 15:23:23 +01:00
thibdrev
2cb4d40e5e qual: phan for functions.lib.php (#28655)
* Update card.php

* Update functions.lib.php

* Update card.php

* Update releve.php

* Update card-rec.php

* Update card.php

* Update prelevement.php

* Update card.php

* Update index.php

* Update index.php

* Update html.form.class.php

* Update card.php

* Update conferenceorbooth_card.php

* Update conferenceorbooth_contact.php

* Update conferenceorbooth_document.php

* Update conferenceorbooth_list.php

* Update conferenceorboothattendee_card.php

* Update conferenceorboothattendee_list.php

* Update shipment.php

* Update card.php

* Update card-rec.php

* Update card.php

* Update card.php

* Update document.php

* Update card.php

* Update comment.php

* Update element.php

* Update ganttview.php

* Update tasks.php

* Update comment.php

* Update contact.php

* Update document.php

* Update note.php

* Update task.php

* Update time.php

* Update card.php

* Update card.php

* Update bank.php

* Update card.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-03-09 01:49:07 +01:00
Laurent Destailleur
f1f9c2ee2e Merge branch 'develop' into fix_element_type_part_05 2024-03-09 01:48:08 +01:00
Laurent Destailleur
f4713ad8a2 Merge branch 'develop' into fix_element_type_part_03 2024-03-09 01:47:38 +01:00
MDW
746ca01423 Fix: Correctly close active output buffer. (#28723)
# Fix: Correctly close active output buffer.

Use ob_get_clean(), not ob_get_contents() and ob_clean().

Tests were failing with:
FunctionsLibTest::testVerifCond with data set "Test that verifConf("0") returns false" ('0', false)
Test code or tested code did not (only) close its own output buffers

OK, but incomplete, skipped, or risky tests\!

Also refactored a test case to use a data provider which helped identify that it was related
to dol_eval.
2024-03-09 01:27:01 +01:00
Laurent Destailleur
defc98f471 Merge branch 'develop' into fix_element_type_part_03 2024-03-08 22:04:51 +01:00
Laurent Destailleur
9a839a1c08 Merge branch 'develop' into fix_element_type_part_05 2024-03-08 21:40:34 +01:00
MDW
3d0a85608b Qual: Fix and enable alias deprecation detection (#28716)
* Qual: Ignore some false positives for deprecated functions

# Qual: Ignore some false positives for deprecated functions

The Phan Deprecation Plugin for internal functions has mixed up some
mail functions and lists them as deprecated, this ignores that

* Qual: Enable detection and fixing of internal deprecations

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Replace 'join' with 'implode'

* Qual: Update codespell lines ignore list after format

# Qual: Update codespell lines ignore list after forma

Done using latest library, so also adds some exceptions that are needed
in the future;

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-03-08 21:34:18 +01:00
Can Arslan
e74e638b26 FIX: skip adding tab if user doesn't have permission (#28698)
verifCond function checks whether user has right and we should skip adding it if user doesn't have right
2024-03-08 12:28:31 +01:00
John BOTELLA
d1c980b0be Factoring fetchObjectLinked 2024-03-08 11:57:07 +01:00
John BOTELLA
076a009554 Merge branch 'develop' into fix_element_type_part_03 2024-03-08 10:46:35 +01:00
MDW
79adb60cf5 Qual: Add instanceof tests to help static typing analysis (#28696)
# Qual: Add instanceof tests to help static typing analysis

Added instanceof tests to help identify that properties exist.
2024-03-07 23:09:25 +01:00
Laurent Destailleur
1d77e34daf Merge branch 'develop' into fix_element_type_part_03 2024-03-07 20:33:17 +01:00
thibdrev
e2026a1c14 qual: phan for functions.lib.php (#28654)
6 entries for:

TypeError PhanTypeMismatchArgumentProbablyReal Argument 5 ($objcon) is null of type null but \show_actions_messaging() takes \Contact|string (no real type) defined at htdocs/core/lib/functions.lib.php:13081
2024-03-07 20:23:45 +01:00
thibdrev
b9c843c086 qual: phan for functions.lib.php (#28653)
* qual: phan for functions.lib.php

54 entries for:

TypeError PhanTypeMismatchArgumentProbablyReal Argument 3 ($exclude) is null of type null but \getCommonSubstitutionArray() takes array (no real type) defined at htdocs/core/lib/functions.lib.php:8285

* phpcs
2024-03-07 16:55:12 +01:00
MDW
38e69184d1 Fix typing hints (#28676) 2024-03-07 16:04:39 +01:00
Laurent Destailleur
c0ee90aa7d Exclude require, include into dol_eval 2024-03-06 17:13:05 +01:00
Laurent Destailleur
7866ee472b QUAL Clean code around dol_eval use 2024-03-06 17:07:24 +01:00
ATM john
a644adbfe5 New hook for getElementProperties 2024-03-06 15:57:34 +01:00
Laurent Destailleur
f9a2c8ec5d Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-06 15:08:21 +01:00
Laurent Destailleur
f1aa29507a Fix sec more complete list of forbidden function 2024-03-06 15:01:25 +01:00
thibdrev
2664661afc qual: phan for htdocs/core/lib/functions.lib.php (#28640)
68 entries for "Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299"

Examples (first 10):

htdocs/accountancy/admin/categories.php	155	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/accountancy/admin/categories.php	189	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/accountancy/bookkeeping/card.php	778	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/admin/eventorganization.php	341	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/admin/hrm.php	596	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/admin/hrm.php	603	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/admin/hrm.php	627	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/admin/knowledgemanagement.php	293	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/admin/knowledgemanagement.php	300	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)

htdocs/admin/multicurrency.php	115	TypeError PhanTypeMismatchArgumentProbablyReal Argument 1 ($mesg) is null of type null but \setEventMessages() takes string (no real type) defined at htdocs/core/lib/functions.lib.php:9299 (the inferred real argument type has nothing in common with the parameter's phpdoc type)
2024-03-05 16:32:40 +01:00
Laurent Destailleur
d7f3feba74 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2024-03-05 04:00:09 +01:00
Laurent Destailleur
cda8a7d241 css 2024-03-05 03:57:56 +01:00
Laurent Destailleur
c544efec7f QUAL: Remove use of customurl filter. Must use the USF syntax. 2024-03-05 03:51:36 +01:00
Laurent Destailleur
ce010a54c7 Clean code and prepare a more powerfull phpunit check for sql forging. 2024-03-05 00:22:12 +01:00
Frédéric FRANCE
7090af2b51 fix phpstan (#28609)
* fix phpstan

* Update emailsenderprofile.class.php
2024-03-04 18:27:20 +01:00
Laurent Destailleur
61dd78b95e Fix regression. Removed bad fixer. GETPOST(... int) is not GETPOSTINT 2024-03-04 17:49:43 +01:00
Laurent Destailleur
8930bf83a9 Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-03 20:59:45 +01:00
Laurent Destailleur
301bec664a Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop
2024-03-03 19:59:34 +01:00
Laurent Destailleur
1e00cf34d4 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2024-03-03 19:50:22 +01:00
Laurent Destailleur
17ff0972ab Fix use of invoke into computed fields 2024-03-03 19:35:37 +01:00
Frédéric FRANCE
6f58a45220 fix phpstan (#28605)
* fix phpstan

* fix phpstan

* fix too few parameters

* fix typo

* ActionComm::$ref is not covariant with PHPDoc type string

* fix default values
2024-03-03 18:55:30 +01:00
Frédéric FRANCE
f5c0cfcf6b fix phpstan (#28588) 2024-03-03 17:09:55 +01:00