The day loop of num_public_holiday() advanced with
dol_time_plus_duree($timestampStart, 1, 'd'). On 21.0 and 22.0 that
function only forces UTC when MAIN_DATE_IN_MEMORY_ARE_GMT is set, so by
default it adds a wall-clock day in the server timezone. When the range
crosses a DST boundary (last Sunday of March in Europe), the GMT
timestamp advances by only 23 hours, the same GMT day is evaluated
twice, one day is counted as holiday twice and the working day after
the boundary is never examined.
For a leave request from Sat 28/03/2026 to Mon 30/03/2026 with a server
in Europe/Paris: 3 days between, 3 holidays counted (Sunday twice),
0 working days instead of 1.
Advance by exactly 86400 seconds instead. Inputs of this function are
GMT dates (enforced by the modulo check at the top of the function), so
a GMT day is always exactly 86400 seconds, in every timezone and conf.
This matches the behaviour that 23.0 and develop get by default since
dol_time_plus_duree() switched to UTC by default there.
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>
* FIX Mass reverse of stock movements bypasses the MAIN_LIMIT_FOR_MASS_ACTIONS limit
The confirm_reverse handler did not check the error raised by the
generic mass action limit control (TooManyRecordForMassAction), so
selecting more records than the limit still executed the reverse
after the error message was displayed. The reverse was also triggered
when relaunching a search while the confirmation form was open,
because the protection only reset $massaction, not $action.
* FIX phan: initialize $error at the start of the confirm_reverse handler
The new !$error guard lets phan narrow $error to falsy types inside
the block, so the $error++ in the query-error branch was reported as
PhanTypeInvalidUnaryOperandIncOrDec. Initialize $error to 0 at the
start of the handler (and drop the redundant init inside the loop
setup where present).
* FIX coding rule: comment on the $action test that only cancels the pending action
CodingPhpTest requires a permission check or an explicit comment on
every test of $action in the Actions section.
---------
Co-authored-by: Nicolas Zaou <nz@anatoleconseil.com>
When an object is created from another element whose extrafields do not exist on
the target element (e.g. an invoice created from a shipment: the source line
extrafields are copied into array_options but none match facturedet), the
top-level empty($this->array_options) guard passes but the filtered column set is
empty. When an extrafields row already exists for the object, the UPDATE branch
then built "UPDATE llx_..._extrafields SET WHERE fk_object = X" with an empty SET
clause, producing a MariaDB syntax error ("near 'WHERE fk_object = ...'") and
aborting the creation of the invoice.
Guard the UPDATE branch: when there is no column of the target element to update,
commit and return without running the query (the existing row is already
correct). This keeps the multicompany data-loss fix (UPDATE instead of
DELETE+INSERT, #34022) untouched.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Fix#39154 bypass paymentok session check when returning from Stripe
When STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is set to 2, Stripe
confirmPayment() redirects the customer directly to paymentok.php and
appends payment_intent, payment_intent_client_secret and redirect_status
to the return url, but not the internal paymentoksessioncode. When the
Dolibarr session cookie is not preserved across the cross-site redirect,
the strict session-code check rejected valid payments with 'Stripe
payment verification failed: TRANSACTIONID is not set or session key
does not match', even though the payment succeeded and was recorded by
the IPN webhook.
Skip the paymentoksessioncode check when payment_intent is present in
GET. Security is preserved: the PaymentIntent is then retrieved from the
Stripe API and its amount, currency and status are verified.
Backport of the develop fix (PR #38577) to the 23.0 maintenance branch.
Signed-off-by: Dolicraft <contact@dolicraft.com>
* Fix#39154 use !GETPOST instead of empty(GETPOST) per review
Signed-off-by: Dolicraft <contact@dolicraft.com>
---------
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
getWeekNumbersOfMonth() looped with "for ($day = 1; $day < $nb_days; ...)",
so the last day of the month was never inspected. When that last day is a
Monday it starts a new ISO week that no earlier day of the month belongs to,
so its week number was silently missing from the returned array.
This surfaces in the project "time spent per month" view
(htdocs/projet/activity/permonth.php), which builds one column per week from
this list: for such months the final week column is dropped. Over 2015-2035,
35 months are affected (e.g. 2015-08 returned weeks 31-35 but omitted 36, the
week of Monday 2015-08-31).
Fix: iterate up to and including the last day ($day <= $nb_days).
Signed-off-by: TowyTowy <towy@airreps.link>
Co-authored-by: Claude <noreply@anthropic.com>
* FIX#37026 Chart of accounts export drops root and cross-chart accounts
The "Chart of accounts" export dataset joined the parent account with an
old style comma join plus aa2.active = 1 and ac.pcg_version =
aa2.fk_pcg_version. That inner join silently dropped every account that
has no parent (root accounts), whose parent is inactive, or whose parent
belongs to another chart. The last case is common with a custom chart
derived from a base one (the derived accounts keep their base parents),
which is what the reporter saw: only the self consistent base chart came
through instead of the active custom chart.
Use an explicit INNER JOIN on accounting_system for the chart and a LEFT
JOIN on the parent account keyed on the parent rowid only, so accounts
are exported whatever their parent is. On a standard install this brings
the export from 3087 to 3171 accounts (84 root or cross-chart accounts
were missing).
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
* Update modAccounting.class.php
* Complete the sentence left dangling in the parent join comment
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
---------
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
The legacy FCKeditor file manager connector (config.inc.php, also included
by browser/default/browser.php and connectors/php/connector.php) only called
main.inc.php and never checked any module right on 21.0 and 22.0, so any
authenticated user, even one with no permission, could reach the connector,
browse the medias directory and upload files.
The permission check already present on 23.0 and develop was never backported.
This adds the same guard so a non-admin without website write right is refused.
Reported by Abderrahmane Aksoum.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
Extrafield labels are stored HTML encoded in llx_extrafields.label
because they are saved through Translate::trans(), which runs the
string through htmlentities(). write_title() wrote the label as-is,
so the CSV header line showed raw entities (Données instead of
Données) while the data cells were fine. With a ; separator the
trailing ; of each entity also wrapped the label in double quotes.
Decode entities and remove HTML with dol_string_nohtmltag() before
csvClean(), consistent with the TSV and Excel export drivers. For the
derived _label column of Select extrafields, append the suffix before
csvClean() so the column stays valid CSV when the decoded label
contains the separator or a quote.
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>
Since PHP 8.3 ldap_connect() takes a single URI argument. connectBind()
concatenated host and port as "host:port", which is a malformed URI for a
scheme-less host (localhost, 192.168.0.2) since the host is then parsed as the
URI scheme, so the following bind returns false. It also appended ":port" to an
already qualified ldaps:// URI. Prefix scheme-less hosts with ldap:// and leave
ldap(s):// URIs untouched.
Signed-off-by: Dolicraft <clement@pixodeo.com>
The double-space removal loop guarded its condition with the truthiness
of strpos():
while (strpos($temp, " ")) {
strpos() returns int 0 when the first double space is at position 0 of
the string, and 0 is falsy, so the loop body never runs. As a result NO
double spaces are collapsed at all in that string, including interior
ones. This happens for any input that begins with two spaces, e.g. text
whose leading "<br><br>" is turned into two leading spaces by the
removelinefeed step just above. The trailing trim() hides the leading
spaces but the interior double spaces survive, producing wrong output
(e.g. "Total amount due" instead of "Total amount due").
Fix by comparing against false, the standard PHP idiom used elsewhere in
this codebase. Strings that do not start with a double space were already
handled correctly, so behaviour is unchanged for them. Also corrected the
neighbouring comment ("double quotes" -> "double spaces").
Signed-off-by: TowyTowy <towy@airreps.link>
Co-authored-by: Claude <noreply@anthropic.com>
Two errors were surfaced on the 21.0 branch by the automated pullmerge
from the 18.0 to 20.0 branches, and they make the phan and phpstan CI
jobs fail on every open pull request:
- htdocs/takepos/invoice.php: dol_htmloutput_errors() second argument
must be an array, not null (phpstan).
- htdocs/societe/class/societe.class.php: the string parameter $remise
must be cast to float before the multiplication, like the surrounding
lines already do (phan PhanTypeInvalidLeftOperandOfNumericOp).
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>
Two errors were surfaced on the 21.0 branch by the automated pullmerge
from the 18.0 to 20.0 branches, and they make the phan and phpstan CI
jobs fail on every open pull request:
- htdocs/takepos/invoice.php: dol_htmloutput_errors() second argument
must be an array, not null (phpstan).
- htdocs/societe/class/societe.class.php: the string parameter $remise
must be cast to float before the multiplication, like the surrounding
lines already do (phan PhanTypeInvalidLeftOperandOfNumericOp).
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>