Commit 9a42c680 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1826948: update existing comments

behatnotneeded

Change-Id: I71bcdb6c98aa1382692a93db2399547e71838f19
parent 8a9170d8
......@@ -1288,5 +1288,40 @@ function xmldb_core_upgrade($oldversion=0) {
}
if ($oldversion < 2019043000) {
log_debug('remove extra html from comment artefact descriptions');
// Get all the comment artefacts with the issue
$sql = "SELECT * FROM {artefact}
WHERE artefacttype = 'comment'
AND description " . db_ilike() . " '<!DOCTYPE%'";
if ($artefacts = get_records_sql_array($sql)) {
$count = 0;
$limit = 1000;
$total = count($artefacts);
// Loop through all of them and update the description
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
foreach ($artefacts as $artefact) {
$dom->loadHTML($artefact->description);
$xpath = new DOMXPath($dom);
$body = $xpath->query('/html/body');
$innerHtml = '';
foreach ($body->item(0)->childNodes as $child) {
$innerHtml .= $dom->saveHTML($child);
}
$artefact->description = $innerHtml;
update_record('artefact', $artefact);
$count++;
if (($count % $limit) == 0 || $count == $total) {
log_debug("$count/$total");
set_time_limit(30);
}
}
}
}
return $status;
}
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2019040900;
$config->version = 2019043000;
$config->series = '19.10';
$config->release = '19.10dev';
$config->minupgradefrom = 2017031605;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment