MDL-82877 customfield: pass correct instanceid for restore structure.

This commit is contained in:
Paul Holden 2024-10-15 15:54:13 +01:00
parent d015c4c213
commit e9f56511bc
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -521,8 +521,11 @@ abstract class handler {
* @param int $oldid The original ID of the custom field data before backup.
*/
public function restore_define_structure(\restore_structure_step $step, int $newid, int $oldid): void {
$datacontrollers = $this->get_instance_data($newid);
// Retrieve the 'instanceid' of the new custom field data.
$instanceid = (new data($newid))->get('instanceid');
$datacontrollers = $this->get_instance_data($instanceid);
foreach ($datacontrollers as $controller) {
$controller->restore_define_structure($step, $newid, $oldid);
}