* Render support ticket edit history as Markdown instead of raw source
Follow-up to #3906: the edit history modal for admin ticket replies
showed the stored Markdown source verbatim in a <pre> block, unlike
the live message body which renders it to HTML. getMessageHistory()
now converts each revision's content with the same Markdown converter
used by the markdown_to_html Twig filter, and the modal renders that
HTML in a .markdown-body article to match the rest of the thread.
* Render edit history Markdown with admin theme defaults
ADMIN_AREA is only set true for admin panel page loads, not for
api/admin/... requests, so FOSSBillingMarkdown was picking up the
client theme's markdown_attributes when converting ticket message
history from the admin API endpoint. Let callers pass isAdmin
explicitly to bypass that runtime check.
Addresses review feedback from https://github.com/FOSSBilling/FOSSBilling/pull/3970
* Pass gateway identity to payment adapters
* Route Stripe webhooks to their originating gateway
* Test Stripe webhook gateway ownership
* Use DBAL for Stripe gateway ownership lookups
* Test DBAL gateway ownership fallbacks
* Limit batch invoice reminders to once daily
* Run invoice generation before reminders in cron
* Isolate cron batch failures and reminder logs
* Track reminders and run fallback reminder pass
* Optimise invoice reminder queries and fix ordering
* Bump install default last_patch to 88
* Prevent duplicate invoice reminders via DB claim
* Harden cron failures and invoice reminders
* Restore broad due-event dispatch and surface cron failures to CLI
Move the reminded_at claim from the batch-level SQL into the built-in
onEventBeforeInvoiceIsDue/onEventAfterInvoiceIsDue handlers, and stop
filtering the due-date candidate queries by reminder interval. Extensions
listening to these events previously received every unpaid/approved due
invoice regardless of the reminder-interval configuration; narrowing that
in this PR's earlier claim-based fix silently broke that contract.
Duplicate-reminder protection is preserved because the handlers still
atomically claim each invoice before sending.
Also make src/cron.php and the cron:run console command honor
runCrons()'s boolean result: a partial failure (an isolated cron task
that threw) now exits non-zero / returns Command::FAILURE instead of
always reporting success, so cron monitors can detect it.
* Release reminder claims on send failure, trim log noise
Both onEventBeforeInvoiceIsDue and onEventAfterInvoiceIsDue now release
their reminded_at claim (reset it to NULL) if the email is never confirmed
queued, so a transient failure gets retried on a later cron run instead of
silently losing the reminder for the day. Also drops the now-redundant
second store() in onEventAfterInvoiceIsDue since the claim UPDATE already
persists reminded_at/updated_at.
Cron task failure logging now records exception class/message/file:line
instead of the full stack trace, to avoid flooding logs on recurring
failures. cron.php's failure message gets a trailing newline so it doesn't
run into subsequent terminal/log output.
* Stop EmailService from silently swallowing queue-persist failures
_queue() caught its own persist/flush exception and only logged it via a
raw error_log() call, so sendMail()/sendTemplate() always returned as if
the email had been queued even when nothing was actually persisted. For
onEventAfterInvoiceIsDue, this meant a transient DB error during queueing
would still leave the invoice's reminded_at claim in place with no way to
retry it, since no exception reached the handler's catch block.
Every other sendTemplate() caller already wraps it in its own try/catch
and logs failures with better context, so removing the swallow here lets
those exceptions surface as intended instead of vanishing before they can
be handled.
Also drop an unused $service variable in two Invoice ServiceTest cases.
* Harden Stripe webhooks and server manager input
* Add `whsec` to cspell dictionary
Updates `cspell.json` to include `whsec` in the custom words list, preventing it from being flagged as a spelling error.
* Require Stripe webhook secret by mode
* Apply suggested fix to tests/Unit/FOSSBilling/RateLimiterTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/RateLimiterTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Server/Manager/Directadmin.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/Api/AbstractApiTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Remove tests path from CODEOWNERS
* Apply suggested fix to src/modules/Order/Service.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Fix uncancel emails and zero-credit payments
* Preserve orders when invoice generation fails
* Fix RateLimiterTest CI failures from prior autofix commits
- Add a public RateLimiter::getStatus() so tests can read the token
limit for a policy without hardcoding it (getRateLimitState() now
reuses it).
- Fix consumeOrThrow test's toThrow() call: Pest expects the assertion
closure as the first argument (with the exception type-hinted), not
as a second argument alongside the class string.
* Fix DirectAdmin apostrophe entity decoding to avoid trailing semicolon
str_replace(''', "'", $data) also matched the fully-terminated
' entity, replacing just the ' part and leaving the semicolon
behind (e.g. "O'Brien" became "O';Brien"). Replace the terminated
form first, then the legacy unterminated form, so both decode to a
plain apostrophe.
* Fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix duplicate domain activation caused by stale order object
Cart checkout can activate an order that was already activated
synchronously via an invoice paid with account credit, since the
in-memory order held by the checkout loop is never refreshed after
the credit-payment path activates it through its own freshly-loaded
copy. activateOrder() now re-fetches the order before checking its
status, closing the gap that let EPP domain registration run twice
and fail with "Domain is not available: In use".
* Treat already-active orders as a no-op in activateOrder
The reload alone turned the stale-order race into a thrown exception
for orders that were already correctly activated by another code
path in the same request. Cart::checkoutCart()'s catch block then
tried to record an 'error' order status, which isn't a valid status
and threw a second exception that broke the whole checkout. An
already-active order (without force) should just be a no-op success.
* Update src/modules/Order/Service.php
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
---------
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
PR #3863 migrated the Extension module to Doctrine and removed
Service::findExtension(), but missed three call sites in
UpdatePatcher.php that still used it. Users upgrading from 0.6.x
hit "Call to undefined method ...findExtension()" when these
update patches ran.
* Fix GET fetch body and DRY DirectAdmin fields
* Remove unused bindings in Support module
* Gate dashboard invoice and order cards
* Extract and test data-fb-api parser
* Refactor API helpers and add unit tests
* Extract link action and loading state helpers
* Refactor icon checks into tested helpers
* Refactor frontend helpers and slim tests
* Harden API CSRF handling and icon checks
* Fix crash on Product Promotions page for promo rows with NULL flags
The `promo` table's maxuses/used/freesetup/once_per_client/recurring/
active columns are nullable in the DB, but the Doctrine entity mapped
them as non-nullable typed properties. When a row (typically from a
legacy install) has NULL in one of these columns, Doctrine's
TypedNoDefaultPropertyAccessor unsets the property instead of applying
the PHP default, so any read throws "must not be accessed before
initialization" — crashing the admin Product Promotions page.
Align the entity mapping with the actual nullable schema and coalesce
null to the intended defaults in the getters and toApiArray().
Fixes#3942
* Coalesce NULL used counts in promo usage SQL
promoCanBeApplied() now treats a NULL used column as 0, but
PromoRepository's raw SQL for incrementing/decrementing usage did not:
`used + 1` and `GREATEST(used - ?, 0)` both propagate NULL in MySQL,
and `maxuses > used` is unknown (never true) when used IS NULL. That
let checkout accept a legacy promo with a NULL used count and then
immediately fail to reserve it, throwing "maximum number of uses
reached". Coalesce used to 0 in both the SET and WHERE clauses so
reservation matches what promoCanBeApplied() already allows.
Apply suggested fix to src/themes/admin_default/html/mod_index_dashboard.html.twig from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/themes/admin_default/html/mod_index_dashboard.html.twig from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/themes/admin_default/html/mod_index_dashboard.html.twig from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Use Request object instead of superglobals
* Use Request in locale resolution
* Queue cookies and remove direct header writes
* Fix flaky i18nTest: de_DE locale isn't installed in CI
CI builds with INSTALL_TRANSLATIONS=false, so only en_US exists on
disk and getLocales() never considers de_DE "enabled". Use en_US as
the cookie value (always installed) against a different config
default to still prove the cookie takes precedence.
* Speed up CI: share Docker test image, dedupe PHPStan, fix cache contention
live-tests and cypress-tests each independently rebuilt the same PHP 8.5
test image already built by the php-build-test matrix, paying for a
registry-cache pull each time. Build it once, export it as a workflow
artifact, and have live-tests/cypress-tests just docker load it.
PHPStan analyzes source, not runtime behavior, so running it identically
across all 3 PHP versions in the matrix was pure duplication. Now it runs
once, on PHP 8.3.
php-build-test-push and preview-build-push wrote to the shared GHCR
registry cache on every push to every branch, not just main. Concurrent
branch pushes (including frequent bot autofix branches) could stomp on
each other's cache entries, degrading hit rates for everyone. Cache
writes are now restricted to main; other branches read-only, same as the
existing PR path.
* Trim comment verbosity to match existing workflow style
The repo's existing workflow comments are single-line "why" notes; tighten
the multi-line ones added in the previous commit to match, and drop an
unused step id.
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/RouteMatcherTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/RouteMatcherTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Fix syntax error from orphaned brace in PayPalEmail adapter
A prior autofix commit closed the `payment_status == 'Completed'` if-block
early with an else/break, but left the block's original closing brace in
place, breaking the rest of the switch statement.
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/library/Payment/Adapter/PayPalEmail.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
PayPal can resend/duplicate the subscr_signup IPN for a subscription,
and the handler had no idempotency check before creating a new
Subscription row (unlike subscr_payment, which is well-guarded). This
could result in duplicate subscription records and duplicate renewal
notifications, matching reports on issue #3055.