* 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.
This commit is contained in:
Ralf Becker 2021-08-18 09:18:05 +02:00
parent c609485fe4
commit 226ee1485d

View File

@ -867,7 +867,7 @@ class Link extends Link\Storage
if ($id && is_null($title)) // $app,$id has been deleted ==> unlink all links to it if ($id && is_null($title)) // $app,$id has been deleted ==> unlink all links to it
{ {
static $unlinking = array(); 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])) if (!isset($unlinking[$app]) || !isset($unlinking[$app][$id]))
{ {
$unlinking[$app][$id] = true; $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)) if (($Ok = !file_exists($url) || Vfs::remove($url,true)) && ((int)$app > 0 || $fname))
{ {
// try removing the dir, in case it's empty // 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)) if (!is_null($current_is_root))
{ {