fix(BookmarkWithTagsAndParent): Avoid requerying tags if a bookmark has no tags

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2024-01-03 13:56:52 +01:00
parent 3d51a44fd0
commit c2213b9e09
1 changed files with 10 additions and 4 deletions

View File

@ -23,12 +23,18 @@ class BookmarkWithTagsAndParent extends Bookmark {
public function toArray(): array {
$array = [];
foreach (self::$fields as $field) {
if ($field === 'tags' && is_string($this->{$field})) {
$array[$field] = $this->{$field} === ''? [] : array_values(array_unique(explode(',', $this->{$field})));
continue;
if ($field === 'tags') {
if (is_string($this->{$field})) {
$array[$field] = $this->{$field} === '' ? [] : array_values(array_unique(explode(',', $this->{$field})));
continue;
}
if ($this->{$field} === null) {
$array[$field] = [];
continue;
}
}
if ($field === 'folders') {
if ($this->{$field} === '') {
if ($this->{$field} === '' || $this->{$field} === null) {
$array[$field] = [];
} else {
$array[$field] = array_values(array_unique(array_map(static function ($id) {