From 1462fb517a3b75c786394c28fce63a63836ca965 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 18 Aug 2021 09:18:05 +0200 Subject: [PATCH] * PostgreSQL: fix SQL error when accessing eg. InfoLog Links class trys to delete empty attachment directories and virtual / empty attachment directories have non-integer (hash) id causing an SQL error in PostgreSQL. --- api/src/Link.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/Link.php b/api/src/Link.php index cafe986086..b13d81a69e 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -867,7 +867,7 @@ class Link extends Link\Storage if ($id && is_null($title)) // $app,$id has been deleted ==> unlink all links to it { static $unlinking = array(); - // check if we are already trying to unlink the entry, to avoid an infinit recursion + // check if we are already trying to unlink the entry, to avoid an infinite recursion if (!isset($unlinking[$app]) || !isset($unlinking[$app][$id])) { $unlinking[$app][$id] = true; @@ -1347,7 +1347,12 @@ class Link extends Link\Storage if (($Ok = !file_exists($url) || Vfs::remove($url,true)) && ((int)$app > 0 || $fname)) { // try removing the dir, in case it's empty - if (($dir = Vfs::dirname($url))) @Vfs::rmdir($dir); + try { + if (($dir = Vfs::dirname($url))) @Vfs::rmdir($dir); + } + catch (\Exception $e) { + // ignore SQL error caused by only virtual directories with non-integer (hash) fs_id + } } if (!is_null($current_is_root)) {