Skip to content

Contract list fails with DB_ERROR_NOSUCHTABLE on non-llx_ table prefix (hardcoded llx_contratdet) #39830

Closed

Description

@milamberspace

Bug

Opening the contract list (htdocs/contrat/list.php) throws a fatal DB error on any Dolibarr install whose SQL table prefix is not the default llx_:

DB_ERROR_NOSUCHTABLE - Table '<database>.llx_contratdet' doesn't exist

The main query correctly uses MAIN_DB_PREFIX (e.g. FROM ".MAIN_DB_PREFIX."contrat as c), but the six contratdet counting sub-queries that build the columns lower_planned_end_date, nb_initial, nb_running, nb_expired, nb_late and nb_closed use a hardcoded llx_contratdet (lines ~336-342).

Steps to reproduce

  1. Install Dolibarr with a table prefix different from llx_ (e.g. adp_).
  2. Enable the Contracts module.
  3. Go to Contracts ▸ List.

➡️ Technical error: DB_ERROR_NOSUCHTABLE ... llx_contratdet.

Affected versions

  • 24.0 and develop (25.0.0-alpha).
  • Not affected: ≤ 23.0 (these sub-queries did not exist yet).

Regression

Introduced by commit d704f6f "PERF Remove the "Group by" on list of contratcs", which replaced the GROUP BY by correlated sub-queries.

Environment

Dolibarr 24.0.0 · PHP 8.4 · MariaDB · table prefix adp_.

Fix

Replace the 6 hardcoded llx_contratdet by ".MAIN_DB_PREFIX."contratdet. PR incoming.

Activity

  1. added a commit that references this issue on Aug 29, 2026
    eaca198
  2. milamberspace commented on Aug 29, 2026

    @milamberspace
    ContributorAuthor

    Fixed by #39832, merged into branch 24.0 (merge commit eaca198) and propagated to develop. Closing manually — the Fixes # keyword did not auto-close because the PR targeted the 24.0 maintenance branch rather than the default branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions