MDL-18541 replace script - now also replaces within well known html blocks. Merged from 19_STABLE

This commit is contained in:
stronk7 2009-03-12 19:04:53 +00:00
parent c49e414b79
commit 36fa17855f

View File

@ -40,6 +40,20 @@ if (!db_replace($search, $replace)) {
print_simple_box_end();
/// Try to replace some well-known serialised contents (html blocks)
notify('Replacing in html blocks...');
$sql = "SELECT bi.*
FROM {$CFG->prefix}block_instance bi
JOIN {$CFG->prefix}block b ON b.id = bi.blockid
WHERE b.name = 'html'";
if ($instances = $DB->get_records_sql($sql)) {
foreach ($instances as $instance) {
$blockobject = block_instance('html', $instance);
$blockobject->config->text = str_replace($search, $replace, $blockobject->config->text);
$blockobject->instance_config_commit($blockobject->pinned);
}
}
/// Rebuild course cache which might be incorrect now
notify('Rebuilding course cache...', 'notifysuccess');
rebuild_course_cache();