fix(mariadb): Stabilisiere CTE 'modulenames' und COUNT-Logik #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The DASH block generates a complex SQL query using a CTE (
modulenames) that merges names and timestamps from multiple activity modules.When rendering (especially when determining the total number of pages), this SQL fails on MariaDB — Moodle displays “Error reading from database” and a stack trace pointing to the COUNT query.
Root Cause
assign,bigbluebuttonbn,board,kanban,subsection, …).If one or more of these modules are not installed, MariaDB aborts the query.
{modulenames}. Moodle’s curly-brace notation is meant for real tables, not CTEs — this caused incorrect prefix substitution.DISTINCT,GROUP BY, andORDER BY, or referenced the CTE via a derived subquery — combinations that MariaDB handles poorly.Fixes / Changes
DISTINCT,GROUP BY, andORDER BY.WITH … SELECT COUNT(…) …instead of wrapping the CTE in a subquery.{modulenames}→modulenamesand updated all references accordingly.NULLcolumns, preventingCOALESCEexpressions from failing.nameortimemodifiedfields, references are rewritten toNULL.Result
Notes