Skip to content

🐛 Declare main edflex table to fix course deletion - #6

Merged
DamienVauchel merged 2 commits into
mainfrom
bugfix/EDFLEX1-14964
Jun 25, 2026
Merged

🐛 Declare main edflex table to fix course deletion#6
DamienVauchel merged 2 commits into
mainfrom
bugfix/EDFLEX1-14964

Conversation

@DamienVauchel

@DamienVauchel DamienVauchel commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

🎯 Purpose of this Pull Request

The plugin never declared its mandatory main edflex table. Moodle's core remove_course_contents() runs SELECT … FROM mdl_{modname} for every installed module on course deletion, so the missing table raised a dmlreadexception that broke deletion of any course platform-wide — even courses that never used Edflex.

Related to #5


📝 Summary of Changes

  • Declare the main edflex table in db/install.xml (id, course, name, intro, introformat, timemodified).
  • Create the table on already-installed v1.0.0 instances in db/upgrade.php, guarded by table_exists(); bump $plugin->version to 2026062400.
  • edflex_delete_instance() now purges its {edflex} row instead of returning false.

✔️ Moodle Plugin Checklist

Code Quality & Standards

  • Code follows Moodle coding guidelines
  • PHPDoc blocks updated where needed
  • No debug statements left
  • Namespace and file structure follow Moodle plugin conventions

Functional Changes

  • Upgrade steps added to db/upgrade.php

Database & Files

  • DB schema changes added to db/install.xml and db/upgrade.php

🧪 Testing

Manual Tests

  • On an instance upgraded from v1.0.0: run the plugin upgrade, confirm the edflex table is created.
  • Create any course (no Edflex activity needed) and delete it → succeeds, no dmlreadexception.
  • Fresh install: confirm the edflex table is present after install.

Automated Tests

  • No unit test added — change is schema/upgrade only; moodle-plugin-ci (validate + savepoints) covers it on CI.

🔄 Regression Risk

Additive schema only. Touches the upgrade path for existing installs and the course-deletion path (the fix target). Low risk.


🔗 Additional Notes

  • Moodle plugin CI is expected to catch a missing main table — worth understanding why it passed before.
  • Follow-up, out of scope: add backup/restore + privacy provider once the edflex table actually stores instance data (today edflex_add_instance still returns false, so no data is written yet).

@DamienVauchel DamienVauchel self-assigned this Jun 24, 2026
Moodle's remove_course_contents() runs SELECT ... FROM mdl_{modname} for
every installed module on course deletion. The missing main edflex table
raised a dmlreadexception that broke deletion of any course platform-wide.

- Add the edflex table to db/install.xml
- Create it on existing installs in db/upgrade.php (guarded by table_exists),
  bump version to 2026062400
- Make edflex_delete_instance purge its row instead of returning false
@DamienVauchel
DamienVauchel force-pushed the bugfix/EDFLEX1-14964 branch from a530ee6 to d4bb731 Compare June 24, 2026 11:54
@DamienVauchel
DamienVauchel marked this pull request as ready for review June 24, 2026 14:11
@DamienVauchel
DamienVauchel merged commit 2b63a34 into main Jun 25, 2026
4 checks passed
@DamienVauchel
DamienVauchel deleted the bugfix/EDFLEX1-14964 branch June 25, 2026 14:53
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.

2 participants