From 0fb620244df60eb9daceab87c17a5e26ff2620ed Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Tue, 3 May 2022 21:47:57 +0200 Subject: check if variable is null before striping tags Signed-off-by: Benjamin Brahmer Co-authored-by: Sean Molenaar --- CHANGELOG.md | 1 + lib/Db/Item.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99fc8477f..ea0add23e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1 ### Fixed - Fix updated api not returning any item after marking item as read (#1713) +- Fix deprecation warning for strip_tags() on a null value (#1766) # Releases diff --git a/lib/Db/Item.php b/lib/Db/Item.php index 693b9417c..b30bd31cf 100644 --- a/lib/Db/Item.php +++ b/lib/Db/Item.php @@ -383,8 +383,10 @@ class Item extends Entity implements IAPI, \JsonSerializable public function setAuthor(string $author = null): self { - $author = strip_tags($author); - + if (!is_null($author)) { + $author = strip_tags($author); + } + if ($this->author !== $author) { $this->author = $author; $this->markFieldUpdated('author'); @@ -549,8 +551,10 @@ class Item extends Entity implements IAPI, \JsonSerializable public function setTitle(string $title = null): self { - $title = trim(strip_tags($title)); - + if (!is_null($title)) { + $title = trim(strip_tags($title)); + } + if ($this->title !== $title) { $this->title = $title; $this->markFieldUpdated('title'); -- cgit v1.2.3