Skip to content

MDL-88218: Add experimental SQLite support for Moodle WASM environments (5.3) - #7

Open
erseco wants to merge 6 commits into
MOODLE_503_STABLEfrom
feature/sqlite-moodle-53
Open

erseco wants to merge 6 commits into
MOODLE_503_STABLEfrom
feature/sqlite-moodle-53

Conversation

@erseco

@erseco erseco commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Port the existing main SQLite driver and its column-metadata/MySQL-function fixes onto the exact v5.3.0-beta tag. Declare SQLite in the 5.3 environment block, leaving 5.2 untouched.

Upstream has no MOODLE_503_STABLE yet. The temporary base feature/moodle-53-baseline is the unmodified beta tag. Retarget/rebase onto MOODLE_503_STABLE when upstream creates it; keep #1 (main) and #5 (5.2) independent. No existing branches were renamed.

Validation completed: clean cherry-picks, PHP lint of all six changed PHP files, XML assertions for the 5.3 vendor declaration, diff checks, and exact beta/PHP 8.4.21/SQLite container installation, HTTP, Moosh, status, code sync and restart. The companion suite also passed PostgreSQL 17, MariaDB 11.4 and a real persistent 4.5.14 → 5.3 beta upgrade with course/file/plugin preservation, cron and restart.

Container PR #171 · reproducible validation report · SQLITE-53.md in this branch.

Experimental backend for WASM/demo/testing, not production.

erseco added 6 commits October 3, 2026 14:56
Reintroduces experimental SQLite support via PDO, intended for
WASM-based and other constrained ephemeral runtimes (portable demos,
educational sandboxes, local experimentation). Not proposed as a
production database backend.

- Add SQLite 3 (PDO) as an installer database option
- Restore the SQLite DML driver and DDL generator
- Fix transaction result handling in pdo_moodle_database

Also fix fetch_columns() to find temporary tables in SQLite: it only
queried sqlite_master, but SQLite stores temporary tables in
sqlite_temp_master, causing "Table does not exist" errors when Moodle
accessed temporary tables (e.g. backup_ids_temp during activity
duplication). Add UNION ALL with sqlite_temp_master, consistent with
the existing pattern in get_tables().

See tracker: MDL-88218
database_column_info::__construct() reads its fields via object property access,
so the SQLite driver's fetch_columns() must pass an object like the pgsql and
mysqli drivers do. Passing the raw array left every property (including ->name)
null, which broke callers reading $column->name (e.g. theme_snap's events query
produced 'SELECT e., e., ...' and a syntax error).
Plugins that accept raw SQL written for MySQL (e.g.
block_configurable_reports) fail on SQLite with errors such as
"no such function: FROM_UNIXTIME". SQLite supports user defined
functions, so register emulations of the most common MySQL date/time
and string helpers on every connection: FROM_UNIXTIME, UNIX_TIMESTAMP,
DATE_FORMAT, NOW, CURDATE, CURTIME, IF, MD5, CONCAT and CONCAT_WS.

The emulations follow MySQL semantics (CONCAT returns NULL when any
argument is NULL; unknown DATE_FORMAT specifiers yield the literal
character; week-based specifiers are approximated with ISO-8601
equivalents). Registration prefers Pdo\Sqlite::createFunction() when
available (PHP 8.4+) and falls back to PDO::sqliteCreateFunction().
@erseco
erseco force-pushed the feature/sqlite-moodle-53 branch from 02065e4 to 811d479 Compare October 3, 2026 13:57
@erseco
erseco changed the base branch from feature/moodle-53-baseline to MOODLE_503_STABLE October 3, 2026 13:57
erseco added a commit to erseco/alpine-moodle that referenced this pull request Oct 3, 2026
ateeducacion/moodle#7 was rebased onto and retargeted to the upstream
5.3 stable branch.
@erseco erseco changed the title MDL-88218: isolate experimental SQLite support for Moodle 5.3 MDL-88218: Add experimental SQLite support for Moodle WASM environments (5.3) Oct 3, 2026
erseco added a commit to erseco/alpine-moodle that referenced this pull request Oct 3, 2026
* Stage Moodle 5.3 LTS default runtime and latest promotion

* Align runtime documentation with the staged LTS promotion

* Cover successive Moodle 5.3 prereleases and document preserved runtimes

* Qualify Moodle 5.3 RC1 in the PHP 8.4 matrix and upgrade test

* Qualify Moodle 5.3.0 stable for the LTS promotion

Upstream released v5.3.0 and MOODLE_503_STABLE. Pin the PHP 8.4 CI
matrix and the persistent 4.5 -> 5.3 upgrade test to the stable tag
instead of RC1, and record the release in the promotion gate.

Related: ateeducacion/moodle-playground#328

* Patch the newest environment block when main predates its own

Upstream main moved to 6.0dev without a <MOODLE version="6.0"> block in
environment.xml. Moodle then checks the newest block not above the
running version (5.3), but the SQLite helper only patched an exact
6.0 block, so the CLI installer failed with "Error reading environment
data (10)". Pick the same block Moodle resolves.

* Point the 5.3 SQLite patch notes at MOODLE_503_STABLE

ateeducacion/moodle#7 was rebased onto and retargeted to the upstream
5.3 stable branch.

* Document PHP 8.4 as the default runtime with Moodle 5.3 LTS

State up front that since v5.3.0 latest is Moodle 5.3 LTS on PHP 8.4,
list the PHP version per image tag, and stop calling the PHP 8.4 page
opt-in now that it is the default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant