From 9a68f0784d333ab094b7bb51fa9c807be5e87c55 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 9 Sep 2016 14:50:12 +0200 Subject: [PATCH] Fix issue in calling page.summary when no content is present in a page Related forum topic: https://getgrav.org/forum#!/general:error-when-summary-is-emtpy --- CHANGELOG.md | 3 ++- system/src/Grav/Common/Helpers/Truncator.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a2a18753..09c19bce43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ 1. [](#improved) * Refactored `onPageNotFound` event to fire after `onPageInitialized` * Follow symlinks in `Folder::all()` - * Twig variable `base_url` now supports multi-site by path feature + * Twig variable `base_url` now supports multi-site by path feature 1. [](#bugfix) * Quietly skip missing streams in `Cache::clearCache()` + * Fix issue in calling page.summary when no content is present in a page # v1.1.4 ## 09/07/2016 diff --git a/system/src/Grav/Common/Helpers/Truncator.php b/system/src/Grav/Common/Helpers/Truncator.php index 4f67a56c1b..8f02ebcb1a 100644 --- a/system/src/Grav/Common/Helpers/Truncator.php +++ b/system/src/Grav/Common/Helpers/Truncator.php @@ -123,6 +123,10 @@ public static function truncateLetters($html, $limit = 0, $ellipsis = "") */ public static function htmlToDomDocument($html) { + if (!$html) { + $html = '

'; + } + // Transform multibyte entities which otherwise display incorrectly. $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');