Skip to content

Commit

Permalink
Merge pull request #337 from humhub/fix/310-ignore-cache-search-index
Browse files Browse the repository at this point in the history
Ignore cache on content search index building
  • Loading branch information
luke- committed Jul 15, 2024
2 parents f906cde + 8c6cbd4 commit 5314ac0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.10.5 (Unreleased)
----------------------
- Enh #336: Renaming page and snippet to global and space types
- Fix #337: Ignore cache on content search index building

1.10.4 (June 19, 2024)
----------------------
Expand Down
2 changes: 1 addition & 1 deletion models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function getSearchAttributes()
return [
'title' => $this->title,
'content' => preg_replace('/[\r\n\s]+/', ' ', strip_tags($this->type === TemplateType::ID
? TemplateRenderer::render($this, false, false)
? TemplateRenderer::render($this, false, false, true)
: $this->abstract . "\r\n" . $this->page_content)),
];
}
Expand Down
7 changes: 4 additions & 3 deletions modules/template/components/TemplateRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ class TemplateRenderer
* @param $page
* @param bool $editMode
* @param bool $applyScriptNonce
* @param bool $ignoreCache
* @return string
* @throws HttpException
*/
public static function render($page, $editMode = false, bool $applyScriptNonce = true)
public static function render($page, $editMode = false, bool $applyScriptNonce = true, bool $ignoreCache = false)
{
$templateInstance = TemplateInstance::findOne(['object_model' => get_class($page) ,'object_id' => $page->id]);

if(!$templateInstance) {
if (!$templateInstance) {
throw new HttpException(404, 'Template instance not found!');
}

if(!$editMode && TemplateCache::exists($templateInstance)) {
if (!$ignoreCache && !$editMode && TemplateCache::exists($templateInstance)) {
$html = TemplateCache::get($templateInstance);
} else {
$html = $templateInstance->render($editMode);
Expand Down

0 comments on commit 5314ac0

Please sign in to comment.