social 0.14.5 (2): Fix warning in entry preview on metadesc key

This commit is contained in:
onli 2021-09-12 14:10:50 +02:00
parent e5f4f0b15a
commit 0f8f059f72
2 changed files with 5 additions and 2 deletions

View file

@ -1,5 +1,8 @@
0.14.5
* Avoid warning situation in entry preview with PHP 8
* Avoid PHP 8 warning warning about missing view key
in entry preview
* Avoid PHP 8 warning about missing metadesc key in
entries without such a description
0.14.4
* Prevent possible error when some articles could not

View file

@ -194,7 +194,7 @@ class serendipity_event_social extends serendipity_event {
echo '<meta name="twitter:card" content="summary" />' . "\n";
echo '<meta property="og:title" content="' . serendipity_specialchars($entry['title']) . '" />' . "\n";
# get desciption from serendipity_event_metadesc, if set; take first 200 chars from body otherwise
$meta_description = strip_tags($entry['properties']['meta_description']);
$meta_description = strip_tags($entry['properties']['meta_description'] ?? '');
if (empty($meta_description)) {
# /\s+/: multiple newline and whitespaces
$meta_description = trim(preg_replace('/\s+/', ' ', substr(strip_tags($entry['body']), 0, 200))) . '...';