Repository navigation
Migrate Configurable Reports blocks to SQL report list blocks - #8
Merged
Merged
Conversation
This was referenced Dec 2, 2026
fix: phpcs and concerns raised in peer review catalyst/moodle-report_sql#53 fix
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Overlapping CLI/admin migrations can create a duplicate replacement block from a stale legacy row, leaving the duplicate without its copied visibility restrictions. Separately, in the cited Moodle default-branch implementation, deleting the old block context removes block-local role assignments, potentially causing affected users to lose edit access or bypass a view prohibition.
2 open issues
What changed in this PR
Moves Configurable Reports block migration into block_sqlreports, keeping report importing and publishing in report_sql.
Changes:
- Adds database-driven conversion to report-list blocks with per-block transactions.
- Provides an admin preview/confirmation page and CLI dry-run support.
- Adds migration tests, documentation, language strings, and a version bump.
| File | Description |
|---|---|
version.php |
Bumps the plugin version and release. |
tests/local/bcr_migrate_test.php |
Tests migration, configuration mapping, and reruns. |
settings.php |
Links plugin settings to the migration page. |
README.md |
Documents migration steps and scope. |
migrate_bcr.php |
Adds admin preview, confirmation, and results. |
lang/en/block_sqlreports.php |
Adds migration interface strings. |
cli/migrate_bcr.php |
Adds CLI migration and dry-run options. |
classes/local/bcr_migration_item.php |
Represents per-block migration results. |
classes/local/bcr_migrate.php |
Implements block replacement and state transfer. |
block_sqlreports.php |
Enables the plugin settings page. |
Review effort: Balanced
Add dry run functionality and locking mechanism for migration. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
matthewhilton
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Closes #9
Moves the Configurable Reports (BCR) block migration out of report_sql (catalyst/moodle-report_sql#53) into this plugin, as suggested in review there.
What it does
Replaces every
block_configurable_reportsblock with ablock_sqlreportsblock in "List of reports" mode, from database rows only (no BCR code required).Carried over as-is:
block_positions) and per-user collapsed/docked state;moodle/block:viewandmoodle/block:editpermission overrides;Each block is migrated in its own transaction. A failure leaves that block unchanged and the rest go ahead. Re-running is safe.
How to use
/blocks/sqlreports/migrate_bcr.php). It previews the blocks, then migrates on confirm.php blocks/sqlreports/cli/migrate_bcr.php --dry-run, then without--dry-run.Suggested order: import the reports with report_sql, publish them and set audiences, run this migration, then remove BCR. Publishing and report import stay in report_sql.
Changes
classes/local/bcr_migrate.php,bcr_migration_item.php: migration logic and result objectmigrate_bcr.php,cli/migrate_bcr.php: admin page and CLIsettings.php,block_sqlreports::has_config(): settings page linking to the migrationtests/local/bcr_migrate_test.phpTesting