getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony

Home Page:https://getgrav.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems when deleting a media in admin

JordanGuiz opened this issue · comments

Hi,

I'm using Grav v1.7.32 - Admin v1.10.32
I recently had troubles in a specific case when deleting a media, here are the steps of this specific case:

  1. I delete the media: a window opens to confirm and I confirm.
  2. I try to go back to pages' list without saving the modifications of the page: a new window opens, asking me if I want to continue without saving, and I click on "continue" (which means: without saving).
  3. I go back to this page and got a warning message:
    56299/fetchMedia/<@https://[mysitedomain]/user/plugins/admin/themes/grav/js/admin.min.js?a79f4db5c3:4325:16
    56299/request/<@https://[mysitedomain]/user/plugins/admin/themes/grav/js/admin.min.js?a79f4db5c3:1072:12

In the frontmatter, the name of the deleted media is still appearing in "media_order", and the label of the form "pagemedia" says "media (1)" even if there's no media anymore. So it seems like Grav consider that this page is still containing a media.

In Grav logs, here it what I found: "Call to a member function cropZoom() on null" and then

     /home/[mysitedomain]/public_html/user/plugins/flex-objects/classes/Controllers/AbstractController.php(127): Grav\Plugin\FlexObjects\Controllers\MediaController->actionMediaList() 
     /home/[mysitedomain]/public_html/user/plugins/flex-objects/classes/Admin/AdminController.php(1223): Grav\Plugin\FlexObjects\Controllers\AbstractController->handle() 
     /home/[mysitedomain]/public_html/user/plugins/flex-objects/classes/Admin/AdminController.php(1058): Grav\Plugin\FlexObjects\Admin\AdminController->forwardMediaTask() 
     /home/[mysitedomain]/public_html/user/plugins/flex-objects/classes/Admin/AdminController.php(1115): Grav\Plugin\FlexObjects\Admin\AdminController->taskMediaList() 
     /home/[mysitedomain]/public_html/user/plugins/flex-objects/classes/Admin/AdminController.php(1440): Grav\Plugin\FlexObjects\Admin\AdminController->taskListmedia() 
     /home/[mysitedomain]/public_html/user/plugins/flex-objects/flex-objects.php(587): Grav\Plugin\FlexObjects\Admin\AdminController->execute() 
     /home/[mysitedomain]/public_html/vendor/symfony/event-dispatcher/EventDispatcher.php(264): Grav\Plugin\FlexObjectsPlugin->onAdminPageInitialized() 
     /home/[mysitedomain]/public_html/vendor/symfony/event-dispatcher/EventDispatcher.php(239): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() 
     /home/[mysitedomain]/public_html/vendor/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners() 
     /home/[mysitedomain]/public_html/system/src/Grav/Common/Grav.php(592): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

Can I do something to avoid this problem? Something to make the page updated as soon as a media is deleted for example?
I know I would just have to save my modifications after deleting the media, but the problem is that the users I'm building this site for sometimes forget to to do it...

Thanks for your time and don't hesitate to ask me for more informations if needed!