Commit graph

975 commits

Author SHA1 Message Date
MDW
9bcc150f26
Fix(dict): Correct SQL query in dict.php (#39356)
A closing quote was left pending in f551727.  This removes it.
2026-08-04 18:40:53 +02:00
MDW
1d295abbef
Qual: Fix Phan notices (#39281)
# Qual: Fix Phan notices

Some phan notices are not reported in ci.

This fixes new ones that appeared:
- Update imap.phan_php to provide IMAP related typing info;
- Add typing info to variables;
- Decleare some variables global (htdocs/admin/dict.php) as reused in function;
- Cast potential null to string;
- Adjust param typing to correspond to default null value (getOnlineSignatureUrl);
- Check that parameter is object as expected by function all (dol_format_address);
2026-07-27 13:03:04 +02:00
MDW
f551727df9
Qual/Sec: Use db->sanitize instead of db->escape when not quoted, fix some quoting (#39286)
* FIX phpstan: Societe::$client (int<0,3>) does not accept -1 (#39244)

Societe::$client is annotated @var int<0,3> (domain 0=no customer,
1=customer, 2=prospect, 3=both) in societe.class.php, but the create
form in societe/card.php pre-set it to -1 as a transient "nothing
pre-selected" placeholder, tripping PHPStan level 10 on develop.

The value is never persisted (save paths compute 0..3) and the only
reader, the switch() building the form, treats -1 and 0 identically via
its default case. Use 0 (the property's own default) so the assignment
matches the declared type. No behavior change.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* Qual: Fix entity handling in bonprelevement.class.php

The variable name 'entities' was changed to 'entity' to better reflect the singular nature of the value being retrieved.
It was also casted to an int instead of using an unquoted db->escape.

* Qual: Improve SQL query construction in company.lib.php

By escaping the concatenated string, injection verification does not identify a false positive.

* Qual: Avoid void positive, sanitize instead of escape

* Qual: Avoid false positive, sanitize instead of escape

* Sec: Fix potential injection with cast to int (timespent_duration)

* Qual: Avoid false positive, sanitize instead of escape

* Qual: Avoid false positive, sanitize instead of escape

* fix: Replace escape() with sanitize() in SQL queries

# FIX: Replace escape() with sanitize() in SQL queries

- Replace escape() with sanitize() in SQL queries to ensure proper SQL injection protection
- Update SQL queries in multiple files to use sanitize() instead of escape()
- Ensure consistent use of sanitize() across the codebase for better security

* fix(sql): Replace escape with sanitize in SQL queries

# FIX: Replace escape with sanitize in SQL queries

- Replace `escape` with `sanitize` in SQL queries to ensure proper SQL injection prevention

* Qual: Improve field escaping/quoting

# Qual: Qual: Improve field escaping/quoting

---------

Co-authored-by: Jam Balaya <jambalaya.pyoncafe@outlook.jp>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 13:00:33 +02:00
MDW
6dac0c7263
Qual: Fix 'SqlInjection' notices (#39203)
# Qual: Fix 'SqlInjection' notices

Batch of 25 files with changes to fix 'SqlInjection' Notices
2026-07-19 15:53:14 +02:00
Laurent Destailleur
ad4ceba536 Automated merge from 23.0 to develop 2026-07-15 02:06:09 +02:00
Laurent Destailleur
967897f763 Automated merge from 22.0 to 23.0 by tool pullmerge.sh 2026-07-15 01:26:14 +02:00
Laurent Destailleur
4f27660d6d Automated merge from 21.0 to 22.0 by tool pullmerge.sh 2026-07-15 01:15:01 +02:00
Laurent Destailleur
6cb5380087 Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 21.0 2026-07-13 16:33:26 +02:00
Laurent Destailleur
dc382c14aa Automated merge from 19.0 to 20.0 by tool pullmerge.sh 2026-07-13 16:28:07 +02:00
Laurent Destailleur
febbfc8207 Automated merge from 18.0 to 19.0 by tool pullmerge.sh 2026-07-13 16:16:47 +02:00
w3houde
20b4edcf33
Fix #32407 translate prospection status libelle in dictionaries (#38923)
The dict.php renderer translated 'label' for some tables (c_units, c_product_nature,
c_productbatch_qcstatus) but left the 'libelle' column of c_stcomm and
c_stcommcontact as the raw English seed text. Map the row to its StatusProspect{id}
translation key when present so the French (or any other locale) shows the
expected label instead of 'Do not contact' / 'Never contacted' etc.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-07-02 09:56:59 +02:00
Laurent Destailleur
e4048515da Merge branch '23.0' of git@github.com:Dolibarr/dolibarr.git into develop 2026-06-22 13:31:11 +02:00
Laurent Destailleur
ee8933f3ec Automated merge from 22.0 to 23.0 by tool pullmerge.sh 2026-06-22 13:23:05 +02:00
Laurent Destailleur
998967c93a Automated merge from 19.0 to 20.0 by tool pullmerge.sh 2026-06-22 13:22:21 +02:00
Laurent Destailleur
d713e62c26 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2026-06-22 13:04:11 +02:00
Laurent Destailleur
9f6306bfeb Fix whitespace 2026-06-22 12:18:56 +02:00
Laurent Destailleur
f209f89c11 Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into 22.0 2026-06-21 23:35:08 +02:00
Laurent Destailleur
e42d6883e5 ci 2026-06-21 15:26:05 +02:00
Laurent Destailleur
d0091363b8 Fix regression. It was not possible to create an intervention on a
partner not customer.
2026-06-19 03:40:50 +02:00
Laurent Destailleur
f553ff53af Automated merge from 19.0 to 20.0 by tool pullmerge.sh 2026-06-19 03:34:30 +02:00
Laurent Destailleur
d7e92bcd50 Automated merge from 18.0 to 19.0 by tool pullmerge.sh 2026-06-19 03:34:19 +02:00
Laurent Destailleur
594129161d Automated merge from 17.0 to 18.0 by tool pullmerge.sh 2026-06-19 03:34:05 +02:00
Laurent Destailleur
50ceefb2a4 Automated merge from 16.0 to 17.0 by tool pullmerge.sh 2026-06-19 03:28:40 +02:00
Laurent Destailleur
6993c665bf Automated merge from 15.0 to 16.0 by tool pullmerge.sh 2026-06-19 03:28:31 +02:00
Laurent Destailleur
4b22126e44 Automated merge from 14.0 to 15.0 by tool pullmerge.sh 2026-06-19 03:28:24 +02:00
ThomasNgr-OpenDSI
4978cccc3b
Fix #38781 allow editing dictionary entries with rowid = 0 (ST_NEVER) (#38841) 2026-06-18 09:19:59 +02:00
ThomasNgr-OpenDSI
6c670f997d
Fix #38781 allow editing dictionary entries with rowid = 0 (ST_NEVER) (#38840) 2026-06-16 02:08:54 +02:00
ThomasNgr-OpenDSI
5556626a92
Fix #38781 allow editing dictionary entries with rowid = 0 (ST_NEVER) (#38842) 2026-06-16 02:08:22 +02:00
Laurent Destailleur
4ed21499e2 Merge branch '23.0' of git@github.com:Dolibarr/dolibarr.git into develop 2026-06-15 01:21:31 +02:00
w3houde
26e5d969a0
Fix #38781 allow editing dictionary entries with rowid = 0 (ST_NEVER) (#38796)
htdocs/admin/dict.php:2402 guards the edit-form rendering with
'$rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)'. PHP empty(0)
returns true, so the ternary falls back to $obj->code for any row whose
rowid is 0 - the comparison becomes '0' == 'ST_NEVER' and the form
never renders. ST_NEVER in llx_c_stcomm is inserted with id = 0 and is
therefore stuck non-editable for label, picto, etc.

Switch the guard to isset() so rowid = 0 is treated as a real rowid.
The same fallback exists at line 2415 for the name attribute of the
hidden div; apply the same change for consistency.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-06-13 18:52:17 +02:00
w3houde
111f29e30a
Fix #37266 write document backup tar to a temp dir outside its own source tree (#38763)
* Fix #36510 advance pg sequence after forced-rowid dictionary insert (#38741)

Dictionary entry creation in admin/dict.php computes $newid = MAX(rowid)+1
in PHP and INSERTs with that rowid explicitly. On PostgreSQL the matching
serial sequence (<table>_rowid_seq) is never told about the manually
chosen value, so the next auto-increment insert (the next dictionary
entry, or any other code path that pulls from the same sequence) hits a
duplicate-key error mis-reported to the user as
'already existing record'.

Bump the sequence with setval(pg_get_serial_sequence(...), GREATEST(MAX,1))
right after a successful forced-rowid INSERT, gated on $db->type == 'pgsql'
so MySQL/MariaDB behaviour is unchanged.

Diagnosis by @hregis (#36510).

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>

* Fix #35661 drop duplicated ref segment in notify pdf path (#38746)

The fixed-target branch of Notify::send built the PDF path as
"$dir_output/$ref/$ref.pdf" while $dir_output already includes the
get_exdir(...) ref subdirectory. The double ref segment made
dol_is_file always fail and the PDF was never attached when a
notification was routed to a fixed email address. The matching block
just above for user/group targets has always used the correct
"$dir_output/$ref.pdf" form.

Drop the extra ref segment so both branches produce the same path.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>

* Fix #38614 align extrafield help-row position with create form (#38753)

In admin/extrafields the create page renders the Help tooltip row right
after Totalizable, before the Css rows. The edit page renders it after
all Css rows, so jumping from create to edit visually moves the field
without any meaningful reason.

Move the <tr class="help"> row in admin_extrafields_edit.tpl.php to the
same position as in admin_extrafields_add.tpl.php (after Totalizable,
before Css edit). Pure markup ordering, no logic change.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>

* Fix #37266 write document backup tar to a temp dir outside its own source tree

htdocs/admin/tools/export_files.php at line 189 used to write the tar
archive directly under $outputdir = DOL_DATA_ROOT/admin/documents.
$outputdir is itself inside the directory being archived. Even with
`--exclude='documents/admin/documents'`, GNU tar notices the output
directory growing while reading the source and exits with code 1 plus
'file changed as we read it'. The check at line 194 treated any non-zero
return as fatal, short-circuited the gzip / bzip2 / zstd step and left
the user with an uncompressed .tar plus 'Error tar generation return 1'.

Write the tar to $conf->admin->dir_temp (which is outside the documents
tree), run the compression step against that temp file, then rename the
compressed artefact into $outputdir as the last step. Add the matching
cleanup paths so a failure does not leave temp tar / compressed temp
files lying around.

Signed-off-by: Dolicraft <contact@dolicraft.com>

---------

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-06-13 01:34:57 +02:00
w3houde
3dcfa2981e
Fix #36510 advance pg sequence after forced-rowid dictionary insert (#38741)
Dictionary entry creation in admin/dict.php computes $newid = MAX(rowid)+1
in PHP and INSERTs with that rowid explicitly. On PostgreSQL the matching
serial sequence (<table>_rowid_seq) is never told about the manually
chosen value, so the next auto-increment insert (the next dictionary
entry, or any other code path that pulls from the same sequence) hits a
duplicate-key error mis-reported to the user as
'already existing record'.

Bump the sequence with setval(pg_get_serial_sequence(...), GREATEST(MAX,1))
right after a successful forced-rowid INSERT, gated on $db->type == 'pgsql'
so MySQL/MariaDB behaviour is unchanged.

Diagnosis by @hregis (#36510).

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-06-12 19:45:08 +02:00
Laurent Destailleur
3fcf44b6f2 Debug v24 2026-05-27 12:43:14 +02:00
Laurent Destailleur
d0bcf2ce52 Doc 2026-05-27 10:56:39 +02:00
MDW
8e01162c73
Fix CI: fix current PHPStan notices and new notices in Phan cti. (#38447)
* Fix: Correct manifest.json.php for logo handling

# FIX: Update manifest.json.php for logo handling

All the alternative logo settings were applied only when MAIN_INFO_SOCIETE_LOGO_SQUARRED is true,
also implying a duplicate test.
It seems more likely that only one of the options is needed.
So changed it to a simple else clause (no extra condition)

* Qual: Ignore PHPStan notice

* Fix: PHPStan notice

When `!empty($valuetoshow)` already tests `(string) $valuetoshow != '0'`.

* Qual: Fix Phan notices in modulebuilder updates

# Qual: Fix Phan notices in modulebuilder updates

Fix PhanCompatibleTypedProperty, PhanPluginRedundantReturnComment notices
2026-05-26 19:21:29 +02:00
Laurent Destailleur
2f226300f3 FIX Pagination in dictionary and email template list 2026-05-25 15:55:50 +02:00
Laurent Destailleur
58608c5f8c NEW Add column einvoice_vate on VAT dictionary 2026-05-25 02:22:58 +02:00
Laurent Destailleur
b116273033 Clean code 2026-04-23 17:41:15 +02:00
Florian Charlaix
029a1fbc1b
NEW #37727 phone input with country code (#37728)
* New phone input with country code

* CI fixes

* Assure AJAX CSRF check

* Fix SQL migration typo

* Remove unnecessary CSRFCHECK_WITH_TOKEN in getphonecode.php AJAX endpoint
2026-04-21 16:15:38 +02:00
Laurent Destailleur
a7527e67e8 Clean code 2026-04-03 22:39:18 +02:00
ldestailleur
4030a7141f Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into 22.0 2025-09-02 22:48:53 +02:00
ldestailleur
e415fb7efa Fix CI 2025-09-02 22:48:34 +02:00
ldestailleur
4e89f046d1 Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into 22.0 2025-09-01 16:47:39 +02:00
ldestailleur
6e3de32c36 FIX error when using a code too large in dictionary 2025-08-29 17:44:18 +02:00
ldestailleur
74b37cdd50 Debug v22 2025-07-15 06:29:22 +02:00
ldestailleur
b3baf74c0d Debug v22 2025-07-10 16:34:06 +02:00
Laurent Destailleur
144854769a Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop
2025-06-13 16:27:57 +02:00
Lucas Marcouiller
10fbaf0c33
Fix bad display of type vet select + database save (#34384)
* Fix bad display of type vet select + database save

* Fix CI

* Fix by removing empty value

* remove unused condition
2025-06-12 12:49:54 +02:00
ldestailleur
a114767ea1 css 2025-05-26 14:32:19 +02:00
ldestailleur
19e7bea04a FIX warning in dictionnary for payment codes 2025-05-26 14:02:17 +02:00