Merge pull request #4759 from annando/update-render-cache

Update the cached rendered html when it changed
This commit is contained in:
Hypolite Petovan 2018-04-06 14:22:12 -04:00 committed by GitHub
commit e4ebf8263c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1184,6 +1184,7 @@ function put_item_in_cache(&$item, $update = false)
$body = $item["body"];
$rendered_hash = defaults($item, 'rendered-hash', '');
$rendered_html = defaults($item, 'rendered-html', '');
if ($rendered_hash == ''
|| $item["rendered-html"] == ""
@ -1196,6 +1197,16 @@ function put_item_in_cache(&$item, $update = false)
$item["rendered-html"] = prepare_text($item["body"]);
$item["rendered-hash"] = hash("md5", $item["body"]);
// Force an update if the generated values differ from the existing ones
if ($rendered_hash != $item["rendered-hash"]) {
$update = true;
}
// Only compare the HTML when we forcefully ignore the cache
if (Config::get("system", "ignore_cache") && ($rendered_html != $item["rendered-html"])) {
$update = true;
}
if ($update && ($item["id"] > 0)) {
dba::update('item', ['rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]],
['id' => $item["id"]], false);