statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.71k stars 508 forks source link

Glide: Directory separator on Windows #6064

Open stuartcusackie opened 2 years ago

stuartcusackie commented 2 years ago

Bug description

I am trying to upgrade a 3.2 project to 3.3 but this happens when using the glide tag, or when using the SEO Pro addon, which generates glide social images: Call to a member function id() on null

It comes down to the fact that Windows uses backslashes instead of forward slashes for its filesystem. I don't know why it's an issue in Statamic 3.3 and not in Statamic 3.2.

Temporary workaround: @staudenmeir found a solution to this here. We can tell Laravel to use the correct directory separator in our filesystems config like so:

's3' => [
  'directory_separator' => '/'
]

It's quite annoying to do this in each of my projects, and I don't trust it entirely, so it would be nice to solve this properly. I have a feeling it will solve this issue as well: https://github.com/statamic/cms/issues/5593

How to reproduce

Use Windows and Glide.

Logs

No response

Versions

Statamic 3.3.12 Pro Laravel 9.13.0 PHP 8.1.1 statamic/seo-pro 3.1.0

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

No response

Additional details

No response

staudenmeir commented 2 years ago

5894 is caused by a filesystem change in Laravel 9, that's why the issue occurred after your upgrade to Statamic 3.3.

I'll try to submit a PR to Laravel to fix this.

stuartcusackie commented 2 years ago

5894 is caused by a filesystem change in Laravel 9, that's why the issue occurred after your upgrade to Statamic 3.3.

I'll try to submit a PR to Laravel to fix this.

Thanks very much!

stuartcusackie commented 1 year ago

Just bumping this one up. It's still a bit of a pain to customise the filesystems for Windows, and now I'm noticing that the temporary fix causes problems elsewhere.

stuartcusackie commented 1 year ago

I'm starting to think that this is not a Laravel issue but a Statamic one. It's not a problem for any other Laravel packages I have used, and even Spatie's responsive image package works fine on Windows.

It only happens when using Statamic::tag('glide:generate')

JohnathonKoster commented 7 months ago

Hey there! I've been trying to reproduce this on the latest versions of Statamic (both for L9/L10), and have not been able to get this to happen (very possible I'm overlooking something). Do you know if this is still occurring for you?

Thanks!

stuartcusackie commented 6 months ago

I've just tested tried two different websites:

The problem still occurs on both if I don't explicitly tell my filesystem to use the correct directory separator, i.e.: directory_separator => "/"

Same error as usual: Call to a member function id() on null

On Website A: It occurs because of a custom glide call to a remote image (digital ocean): @foreach (Statamic::tag('glide:generate')->src($ogImage)->width(1200)->height(627)->fit('crop_focal')->fm('jpg') as $image)

On Website B: It occurs because of the og image stuff in the Statamic SEO Pro Addon: @seo_pro('meta')

I think it actually does occur when using Spatie's Responsive Images addon as well, contrary to what I said in one of my comments.

Let me know if you can think of any useful info that I might have at my disposal. Please also bear in mind that I am using a simple wamp-style virtualhost called Laragon. You won't notice this problem on something like vagrant and homestead because those use a linux filesystem.