Repository navigation
Conversation
keevan
commented
Dec 1, 2026
- 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
|
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, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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]]); |
There was a problem hiding this comment.
is unserialize necessary? is that what core does? (alternatively is there a core function that does this)
There was a problem hiding this comment.
fwiw https://github.com/moodle/moodle/blob/MOODLE_405_STABLE/blocks/moodleblock.class.php#L472
I'll align it with my branch.
| * | ||
| * @return int[] | ||
| */ | ||
| private static function unpublished_imports(): array { |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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.
|
Moved to catalyst/moodle-block_sqlreports#8 |
|
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. |
fix: phpcs and concerns raised in peer review catalyst/moodle-report_sql#53 fix
fix: phpcs and concerns raised in peer review catalyst/moodle-report_sql#53 fix