venveo / craft-compress

Automatically compress asset queries into zip files
https://www.venveo.com/
MIT License
12 stars 3 forks source link

Error when using getContents in Servd #31

Open Mosnar opened 1 week ago

Mosnar commented 1 week ago
          @kennethormandy I changed this because i kept getting an error for the `getContents()` function:
2024-09-24 16:37:24 [web.ERROR] [Error] Error: Call to a member function getAsset() on null in /var/www/html/vendor/venveo/craft-compress/src/controllers/CompressController.php:73

I wasn't sure if this was because we were using Servd and their remote storage and it was struggling to grab the image.

I suppose if you want to keep the way i've done it, you could just pass the path rather than the url if some filesystems don't have public URL's

Originally posted by @bymayo in https://github.com/venveo/craft-compress/issues/29#issuecomment-2373312730

Mosnar commented 1 week ago

@bymayo I reverted this change, switching back to $asset->getContents() and tested the following scenarios trying to reproduce the issue:

  1. Create archive using only S3 volumes
  2. Create archive using public Servd volume
  3. Create archive using private Servd volume

None of these scenarios caused any errors. Were you running the code on Servd when you got this error or were you running locally using a Servd volume?

For the moment, I've pushed a commit reverting back to the old getContents method, as I think it's a cleaner API for us to use. I haven't tagged a release yet because I'd like to get to the bottom of your error.

bymayo commented 1 week ago

@Mosnar I was running it locally, hooking in to Servd on a DDEV environment.

I'll use this release and see if i can figure out the issue a bit better.

Mosnar commented 1 week ago

@Mosnar I was running it locally, hooking in to Servd on a DDEV environment.

I'll use this release and see if i can figure out the issue a bit better.

Thanks! One thing worth checking is that your Servd asset storage environments are in-sync. If you're using a copy of the production database but using staging assets, it's possible an asset is missing.