cdowdy / boltbetterthumbs

Bolt Extension for thumbnails, srcset and picture element using Glide
6 stars 2 forks source link

Image previews missing from cache management page. #21

Closed saltpeanuts closed 7 years ago

saltpeanuts commented 7 years ago

When I visit /extend/betterthumbs/files in v1.5.2 I can see a card for each image with a delete image button. However the image previews are not found. All I get is the dark grey background where the image should be and the filename as alt text.

If I click the delete button anyway I get an endless spinner and a not found response for the delete request.

cdowdy commented 7 years ago

@saltpeanuts could you do me a quick favor? could you see if any files are saved in the cache without a file extension? Meaning no jpg/png/gif etc.

I think I messed up :) haha. I switched to always saving with file extensions here: 63fd0479c7d4f7b43edfb6e082eade877ad2f514 for the cache primer and I don't think I made sure all files existed with an extension before the update

Edit.. I skipped over your last paragraph.. yeah indeed no file extensions.. haha..

If you can manually delete those images right now you should get it working... I'll work on a permanent fix in a bit!

saltpeanuts commented 7 years ago

@cdowdy the files saved in the cache folder do have a file extension eg: 0db2333a509a775ab1969c6d9f812844.jpg If I manually empty the cache this is the format the new images have.

cdowdy commented 7 years ago

Ok I pushed some things that should fix this. I'll put out a new release in a few minutes and hopefully it squashed this!

If you get the release when it hits bolt's servers and try it out can you let me know if it works? Thanks again!

saltpeanuts commented 7 years ago

Still not working this end.

Preview images still not loading, checking console shows they all have 403 errors.

cdowdy commented 7 years ago

Well damn.. OK what's the URL for the images in the preview? And what's listed in the button to delete all the images in data-all="" ?

I'm going to setup a clean VM in a bit see if I can get this to do it again because I can't reproduce it in my current dev environment.

cdowdy commented 7 years ago

And for the above for the image preview URL I should only need one that is broken in the preview... Thanks @saltpeanuts !

saltpeanuts commented 7 years ago

The url for the broken image is: /files/.cache/subfolder/original-filename.jpg/hashvalue.jpg

In the delete all button: data-all="["subfolder\/original-filename.jpg"]"

cdowdy commented 7 years ago

huh.. thanks @saltpeanuts Im kinda stumped.

You say it's returning a 403 so that has me thinking it either still has the old code to generate a signed secure url but the image src string you provided doesn't have a signature like this old code here https://github.com/cdowdy/boltbetterthumbs/blob/a700081363350999e3212a131e637c87fa7c59d8/src/Controller/BetterThumbsBackendController.php#L79-L82 and it uses the /files/.cache/ url which that old code doesn't, or there is a directory permissions error.

Here is the listing in my dev environment. Some images with extensions and others with no extension:
no-ext

and here is how it looks for me in the backend page: _backend_files

going to do an "IT Crowd" thing haha.. can you try to clear bolt's cache and then go to bolt/extend and select rebuild autoloader from the dropdown on the right and can you check bolt's system log see if there are any errors logged for of the routes betterthumbs_prime or betterthumbs_files

I'm really sorry about all these hoops you're having to jump through right now .. sorry about this!

saltpeanuts commented 7 years ago

Bolt's cache cleared and autoloader rebuilt but still no change. No errors logged in system log

First thing I thought was a permissions issue, but the folder is being written to ok, and read from just fine by the site front-end. Could that still happen if a permission is wrong somewhere? Checked permissions for files and .cache folders and they're both 775

No problem at all with the hoops. There's no rush on anything, I just log things if I spot them.

saltpeanuts commented 7 years ago

Maybe this is relevant ...

I just tried removing the extension completely and reinstalling. When I reinstalled I got the following error message after returning to the dashboard:

Extension package cdowdy/betterthumbs has an invalid class 'Bolt\Extension\cdowdy\betterthumbs\BetterThumbsExtension' and has been skipped.

Everything carried on working as before despite the message.

cdowdy commented 7 years ago

Yeah that skipped package error is from bolt probably when you updated to the newest release.

If rebuilding the autoloader doesn't fix your issue and remove the missing package error you might have to uninstall the extension and reinstall ( use bolt's admin uninstall button - it should keep all your config settings so you wont' have to redo any of those)

I really appreciate you finding this stuff! It's extremely helpful thanks!

saltpeanuts commented 7 years ago

Just set up a clean install of Bolt. It has one simple content type and a couple of basic .twig templates. Everything else is default.

Bolt BetterThumbs is the only extension installed and I'm using all the default settings.

Still getting the same problem. If it helps, the test site is public so I can send you details if you want to take a look.

cdowdy commented 7 years ago

@saltpeanuts are you using Apache by chance?

cdowdy commented 7 years ago

ok @saltpeanuts I think I actually do have a solution to this now.. but I'm gonna ask the core bolt devs about something first to see if I can actually implement this a differnt way instead of renaming the cache directory

If you comment out the cache rewrite around line 25

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteRule cache/ - [F]  

  # other stuff here  

or change it too RewriteRule /app/cache/ -[F]

It should work... But I'm not so sure what the unattended consequences of that will be.. I'll have to experiment a little further

saltpeanuts commented 7 years ago

Yes, using either Apache or Litespeed.

Either of those changes fix the preview images not showing issue. I still get a not found error trying to delete though.

A step closer then, haha. If you need me to test anything, just let me know.

Thanks!

cdowdy commented 7 years ago

Ok... I don't want to rename the cache right now... so I think I have a workaround. If you get a chance could you install the branch named "missing_previews_21" https://github.com/cdowdy/boltbetterthumbs/tree/missing_previews_21

if this works I'll put a more permanent fix in a release.

I tested this on apache 2.4.18 and php 7.0.8 and it seemed to work.

Much appreciated @saltpeanuts without you raising this issue I woulda kept plugging along and not noticed haha.

saltpeanuts commented 7 years ago

No problem @cdowdy .

Getting a composer error trying to install at the moment:

Could not find package cdowdy/betterthumbs at any version for your minimum-stability (dev). Check the package spelling or your minimum-stability

Guessing it hasn't hit Bolt's servers yet? I'll give it a try later.

cdowdy commented 7 years ago

nah I haven't published it as a release. You should be able to install it by choosing "install another version" or however its worded I can't remember right now.. If that still doesn't work it's because its considered "development" by bolt and or composer and your settings wont allow it. Youll have to adjust your extensions settings in app/config.yml to be able to install dev versions.. which in many cases isn't worth it..

So if you can't install it from the "other version" dropdown then you'll have to wait till I can create a release and push it.

saltpeanuts commented 7 years ago

Used the 'install other version' option, I can see the version I want, and its definitely set to dev.

I've seen this issue before, there's sometimes quite a lag between seeing the release in the menu and being able to install it, for some reason. I've had to wait a few hours in the past. Not sure if it's a bolt thing or a github thing.

saltpeanuts commented 7 years ago

Ok, it's caught up now and let me install.

All looks to be working fine with Apache 2.4.9, I'll check Litespeed later.

cdowdy commented 7 years ago

@saltpeanuts thank you very much!

saltpeanuts commented 7 years ago

Litespeed looking good. Preview images working. Delete single and all images is working. Cache primer working.

Thanks for all your work on this @cdowdy

cdowdy commented 7 years ago

@saltpeanuts no seriously thank you! I didn't test apache/litespeed very closely and just assumed what I had was working haha.. bad move by me and I didn't put any of my error checking into the extension releases which is another bad move by me haha.. Thanks a ton!

I'll push an official release here in a bit! thanks again!