mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-72025 Upgrade: Out of memory when updating social profile fields
This commit is contained in:
parent
2094d420e1
commit
68204f0870
1 changed files with 8 additions and 3 deletions
|
@ -145,8 +145,11 @@ function user_profile_social_create_profilefield($social) {
|
||||||
*/
|
*/
|
||||||
function user_profile_social_update_module_availability() {
|
function user_profile_social_update_module_availability() {
|
||||||
global $DB;
|
global $DB;
|
||||||
$modules = $DB->get_records('course_modules');
|
// Use transaction to improve performance if there are many individual database updates.
|
||||||
foreach ($modules as $mod) {
|
$transaction = $DB->start_delegated_transaction();
|
||||||
|
// Query all the course_modules entries that have availability set.
|
||||||
|
$rs = $DB->get_recordset_select('course_modules', 'availability IS NOT NULL', [], '', 'id, availability');
|
||||||
|
foreach ($rs as $mod) {
|
||||||
if (isset($mod->availability)) {
|
if (isset($mod->availability)) {
|
||||||
$availability = json_decode($mod->availability);
|
$availability = json_decode($mod->availability);
|
||||||
if (!is_null($availability)) {
|
if (!is_null($availability)) {
|
||||||
|
@ -159,6 +162,8 @@ function user_profile_social_update_module_availability() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$rs->close();
|
||||||
|
$transaction->allow_commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -184,4 +189,4 @@ function user_profile_social_update_availability_structure(&$structure) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue