MDL-73878 core_user: Creating a new category for social fields

This commit is contained in:
Amaia Anabitarte 2022-04-21 14:07:54 +02:00
parent d2fb057b7e
commit ffc655b181
2 changed files with 19 additions and 1 deletions

View File

@ -4476,5 +4476,23 @@ privatefiles,moodle|/user/files.php';
// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2022042900.01) {
// Social custom fields could had been created linked to category id = 1. Let's check category 1 exists.
if (!$DB->get_record('user_info_category', ['id' => 1])) {
// Let's check if we have any custom field linked to category id = 1.
$fields = $DB->get_records('user_info_field', ['categoryid' => 1]);
if (!empty($fields)) {
$categoryid = $DB->get_field_sql('SELECT min(id) from {user_info_category}');
foreach ($fields as $field) {
$field->categoryid = $categoryid;
$DB->update_record('user_info_field', $field);
}
}
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2022042900.01);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2022042900.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2022042900.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.1dev (Build: 20220429)'; // Human-friendly version name