From 7370dee913a63a2f7d4bc09bd4e5605eac2eb382 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 29 Apr 2020 02:23:29 +0200 Subject: fix bookmark construction in user fix colortag file creation by fixing fn access media --- app/class/Modelmedia.php | 4 ++++ app/class/User.php | 10 +++++++--- app/fn/fn.php | 3 --- app/view/templates/media.php | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/class/Modelmedia.php b/app/class/Modelmedia.php index 4da7707..89a2305 100644 --- a/app/class/Modelmedia.php +++ b/app/class/Modelmedia.php @@ -376,9 +376,13 @@ class Modelmedia extends Model { try { accessfile($oldname); + accessfile($newname); } catch (InvalidArgumentException $e) { throw new InvalidArgumentException($e->getMessage()); } + if (!file_exists($oldname)) { + throw new InvalidArgumentException("File : $oldname does not exist"); + } return rename($oldname, $newname); } } diff --git a/app/class/User.php b/app/class/User.php index efd89ae..e78c10c 100644 --- a/app/class/User.php +++ b/app/class/User.php @@ -202,9 +202,13 @@ class User extends Item if (is_array($bookmark)) { $bookmark = array_map( function ($datas) { - try { - return new Bookmark($datas); - } catch (RuntimeException $e) { + if (is_array($datas)) { + try { + return new Bookmark($datas); + } catch (RuntimeException $e) { + return false; + } + } else { return false; } }, diff --git a/app/fn/fn.php b/app/fn/fn.php index 461f129..103062a 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -425,9 +425,6 @@ function accessfile(string $path, bool $createdir = false): bool if (!is_writable($dir)) { throw new \InvalidArgumentException("Directory '$dir' is not writable."); } - if (!file_exists($path)) { - throw new \InvalidArgumentException("The file '$path' does not exist."); - } if (is_file($path) && !is_writable($path)) { throw new \InvalidArgumentException("The file '$path' is not writable."); } diff --git a/app/view/templates/media.php b/app/view/templates/media.php index d0caaf2..ea87fba 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -140,8 +140,8 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' - - + + -- cgit v1.2.3