Delete bug
Permalink Browser Info Environment
Deleting a file from Dashboard > Files which is being used in a gallery causes the add-in (and web page) to crash when viewed. The crash happens on line 24 of the file:
\packages\easy_image_gallery\blocks\easy_image_gallery\view.php
Workaround:
If you add "if ($f){" on line 24 and "}" on line 40 you can get things working again. but this only gets the page to work again, it does not fix the problem of the missing file ID saved in the btEasyImageGallery table.
The better fix would be to add something in "public function view()" to check if any of the fIDs have been deleted. If so remove if from the list and update the database.
Example:
Lets say we delete FileID #3 which was used in a gallery.
the "fIDs" field would still contain "1,2,3,4,5".
The SQL "SELECT fID FROM Files WHERE fID IN (1,2,3,4,5) would return the correct list "1,2,4,5" which could be could be used to fix the $files array.
Hope this helps - love the add-in!
\packages\easy_image_gallery\blocks\easy_image_gallery\view.php
Workaround:
If you add "if ($f){" on line 24 and "}" on line 40 you can get things working again. but this only gets the page to work again, it does not fix the problem of the missing file ID saved in the btEasyImageGallery table.
The better fix would be to add something in "public function view()" to check if any of the fIDs have been deleted. If so remove if from the list and update the database.
Example:
Lets say we delete FileID #3 which was used in a gallery.
the "fIDs" field would still contain "1,2,3,4,5".
The SQL "SELECT fID FROM Files WHERE fID IN (1,2,3,4,5) would return the correct list "1,2,4,5" which could be could be used to fix the $files array.
Hope this helps - love the add-in!
Type: | Pre-Sale |
---|---|
Status: | In Progress |
Hey Seb,
This will get you their...
Good luck.
This will get you their...
$db = Loader::db(); $MyfIDs = implode(",", $fIDs); $results = $db->query("SELECT fID FROM Files WHERE fID IN (" . $MyfIDs. ")"); $fID_array = []; foreach($results as $result){ $fID_array[] = $result['fID']; } $correctfIDs = implode(",", $fID_array); // Save new fIDs $result = $db->execute('UPDATE btEasyImageGallery SET fIDs=? WHERE bID=?',array($correctfIDs, $bID));
Good luck.
Thanks a lot for the tips! I.m not a killer in sql. I will'add this check in the controller.
I will invistigate also your proposition.
Don't hesitate to add a review if you like the add-on.
Thank again,
Seb