Skip to content

feature/49 bcr block migration - #53

Closed
keevan wants to merge 3 commits into
MOODLE_405_STABLEfrom
feature/49-bcr-block-migration
Closed

keevan wants to merge 3 commits into
MOODLE_405_STABLEfrom
feature/49-bcr-block-migration

Conversation

@keevan

@keevan keevan commented Dec 1, 2026

Copy link
Copy Markdown
Contributor
  • feat(import): migrate block_configurable_reports blocks to block_sqlreports
  • refactor(import): simplify block migration lookup and fix lint
  • feat(import): migrate BCR blocks to block_sqlreports list mode

…eports

Record the CR report id to imported query id map during import and add
cr_block_migrate (plus cli/migrate_cr_blocks.php with --dry-run) which
replaces legacy block instances using DB rows only, so it works with the
BCR plugin code removed but its tables retained.

Refs #49
Each BCR block becomes one list-mode block (block_sqlreports PR #6),
carrying over title and the course/global report list settings.

Refs #49
@matthewhilton

matthewhilton commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

thought - should this live in BSQLR instead? Given this plugin technically doesn't require BSQLR in its version.php

I would lean strongly towards yes, because logically it makes sense for the block instances to be created/managed/migrated by the block plugin. Makes it easier to keep the code contained within there as well.

if (!\core_component::get_component_directory('block_' . self::NEW_BLOCK)) {
foreach ($instances as $inst) {
$out['blocks'][(int) $inst->id] = self::result(
(int) $inst->id,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

named params make this clearer

* drafts:int[]} Per old-instance outcome (status: migrated|skipped) and the ids of
* target queries that are still drafts and need publishing.
*/
public static function migrate(bool $dryrun = false): array {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather use proper typed class/object rather than arbitrary array

*/
private static function decode_config(string $configdata): \stdClass {
$raw = base64_decode($configdata);
$config = $raw === '' ? false : @unserialize($raw, ['allowed_classes' => [\stdClass::class]]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is unserialize necessary? is that what core does? (alternatively is there a core function that does this)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*
* @return int[]
*/
private static function unpublished_imports(): array {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be called unpublished_imports_ids() given it returns ids

'subpagepattern' => $inst->subpagepattern,
]);
foreach ($rows as $row) {
if ((self::decode_config((string) $row->configdata)->displaymode ?? '') === 'list') {

@matthewhilton matthewhilton Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my PR i made displaymode in BSQLR use an enum not arbitrary strings.
Technically here we couldn't use an enum without adding the other plugin to version.php dependencies in this plugin which we shouldn't do.
Makes me lean towards moving this into BSQLR instead of having it here.

@keevan

keevan commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Moved to catalyst/moodle-block_sqlreports#8

@keevan

keevan commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by catalyst/moodle-block_sqlreports#8 (issue catalyst/moodle-block_sqlreports#9), which moves the block migration into block_sqlreports as suggested in review. This PR can be closed.

keevan added a commit to catalyst/moodle-block_sqlreports that referenced this pull request Dec 2, 2026
keevan added a commit to catalyst/moodle-block_sqlreports that referenced this pull request Dec 2, 2026
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.

Migration tool: convert block_configurable_reports block instances to block_sqlreports

2 participants