# Fix: Reviewed, fixed and optimized dol_dir_list
Review: had some issues using the exclusion filter, may be unrelated to implementation.
Fixed: is_link was testing utf8 filename, not os filename version.
Optimized:
- Simplified is_dir branches
- Avoid computing the exclusion arrays multiple times
# Fix: Protect from negative array index access
Negative array index access can happen when $i is 0.
While this raises a notice before PHP7.1 it would compare to the last
value in the string so it's invalid.
Detected with phan: PhanCompatibleNegativeStringOffset
* Fix: Allow new & old names to check if module is loaded.
# Fix: Allow new & old names to check if module is loaded.
The method 'isModEnabled()' was already checking some modules for
their new name, but after transitioning Conf this was not working
for 'member'. Now testing for both names as 'Conf' can handle
both and deprecation will be reported.
Several issues were discovered after removing deprecated values.
* Update functions.lib.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
# Qual: Optimisation in load criteria (dol_dir_list)
By moving the "$sortcriteria" conditions into the load conditions, the
comparison between strings is less frequent.
The original test can probably even be removed as it is part of load_*.
The only side-effect that I can see is with the hook, but I think
in theory there should not be a negative side-effect, only a positive
one as this tells the hook to load the data we need without relying
on the hook to make the proper interpretation of the searchcriteria.
* Qual: Refactor for distinction between encodings
# Qual: Refactor for distinction between encodings
Renamed path/file variable to equivalents with prefix os_ and utf8.
Also added $utf8_fullpath to optimize.
* Fix: Fix mixed os_path/utf8_path
# Fix: Fix mixed os_path/utf8_path
This fixes the mixing of a os_path encoding en utf8_path encoding
by reorganising the statement order.
Also avoid a os_encode call by reusing data already available.
* Qual: Apply php-cs-fixer to make only manual changes stand-out
# Qual: Apply php-cs-fixer to make only manual changes stand-out
A few changes will be proposed in the future to these files. This already commits
the esthetic changes using php-cs-fixes.
* Qual: Apply php-cs-fixer to make only manual changes stand-out
# Qual: Apply php-cs-fixer to make only manual changes stand-out
A few changes will be proposed in the future to these files. This already commits
the esthetic changes using php-cs-fixes.
* Qual: Apply php-cs-fixer to make only manual changes stand-out
# Qual: Apply php-cs-fixer to make only manual changes stand-out
A few changes will be proposed in the future to these files. This already commits
the esthetic changes using php-cs-fixes.
* feat(api): Add updateLine to Bank api + add salaries api
* feat(api): Add "deleteLine" to bank api
* fix(api): Remove unneeded mandatory field "salary"
* feat(api): Add PaymentSalaries and PaymentExpenseReports API
* fix(bankaccount): Fix bad phpdoc return type
* fix(bankaccount): Fix bad phpdoc return type and comments
* add updateLabel function to AccountLine
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Qual: Remove useless ignore case on regex
# Qual: Remove useless ignore case on regex
The ignore case on this regex is useless and may have a performance impact.
* Qual: Fastest test first, and test object type
# Qual: Fastest test first, and test object type
The test on nohook should be fastest, and the instanceof test helps
static tool checkers and supposedly also helps performance
# Qual: Add verification on filters (dol_dir_list)
As-is, '/' must be escaped in the regexes, this adds code to enforce
that requirement and avoid mistakes.
Even if the mathod using '{}' as delimiters is applied this check
could remain in place.
Also, returning empty array immediately - when the directory could
not be opened, closedir() can not be applied.
* FIX: Fix unneeded access outside open_basedir when looking for modules
# FIX: Fix unneeded access outside open_basedir when looking for modules
Change the order in which the if conditions are tested so that an is_dir("dir/..") is avoided
by first testing if the subpath starts with a dot.
Also changed uppercased the first 3 letters of the file before comparing to CVS.
Finally, improved the typing hint and documentation.
The PHPUNIT test failed like this:
```
35) ExportTest::testExportModulesDatasets
is_dir(): open_basedir restriction in effect. File(D:\a\dolibarr\dolibarr\htdocs/..) is not within the allowed path(s): (D:\a\dolibarr\dolibarr\htdocs;D:\a\dolibarr\dolibarr\documents;D:\a\dolibarr\dolibarr\test;D:\a\dolibarr\dolibarr\dev\initdemo;c:\tools\php)
D:\a\dolibarr\dolibarr\htdocs\core\lib\functions2.lib.php:100
D:\a\dolibarr\dolibarr\htdocs\exports\class\export.class.php:119
D:\a\dolibarr\dolibarr\test\phpunit\ExportTest.php:463
```
* Fix spelling