greenrivers / grav-plugin-webp

Grav Webp plugin.
MIT License
11 stars 0 forks source link

Convert and Clear buttons give error #8

Closed beejay41 closed 1 year ago

beejay41 commented 1 year ago

Your scripts assume the Administrator path is /admin, so on a site where this has been changed, to say "/panel", the script button actions are not found (cause 500 error). An alternate admin path also appears to affect saving/loading the plugin parameters.

MajorKuprich commented 1 year ago

Hello @beejay41,

I've checked how the plugin works with the changed urls for the admin panel: https://learn.getgrav.org/17/admin-panel/faq#custom-admin-url. I didn't notice the problems You described. The plugin refers to urls starting with /admin but handling the request on the PHP side doesn't matter the url of the admin panel: https://github.com/greenrivers/grav-plugin-webp/blob/master/webp.php#L76.

Can you provide more details:

Regards

beejay41 commented 1 year ago

OK so this is only failing on 1 of 3 websites, I've tested. On clicking "Convert", I'm seeing:

Grav\Plugin\Webp\Webp::process(): Argument #1 ($totalImages) must be of type array, null given, called in /srv/www/.../grav/user/plugins/webp/webp.php on line 89

On "Clear All", I'm seeing:

The "user/webp" directory does not exist.

Apologies, nothing to do with "/admin", I was mislead by the 500 error.

MajorKuprich commented 1 year ago

Hi @beejay41,

Unfortunately I can't reproduce this error, all I can do is to analyse working of conversion. It looks like a problem with set/get session parameters.

  1. When you click the Convert button, the array of images to be converted is saved in the session.

https://github.com/greenrivers/grav-plugin-webp/blob/master/webp.php#L116

The images array will always be an array, return type hinting in the function is responsible for this.

https://github.com/greenrivers/grav-plugin-webp/blob/master/classes/Webp.php#L54

2 Then the conversion is handled by retrieving the previously saved images array from the session.

https://github.com/greenrivers/grav-plugin-webp/blob/master/webp.php#L85

The error regarding the Clear button occurs because a folder with webp images hasn't been created, due to an earlier error for the Convert button.

Please let me know if you have any further questions.

MajorKuprich commented 1 year ago

It has been over month since last activity in this topic, so I close this issue. Reopen or create new ticket if You need more explanations, please. :)