Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

'filemtime(): stat failed' after nova update #50

Closed
iaK opened this issue Dec 9, 2019 · 6 comments
Closed

'filemtime(): stat failed' after nova update #50

iaK opened this issue Dec 9, 2019 · 6 comments

Comments

@iaK
Copy link

iaK commented Dec 9, 2019

Nova version: 2.8.0
Laravel version: 6.6.2
Nova froala field version: 3.2.1

Efter updating nova to 2.8, I'm getting the following error in nova:

filemtime(): stat failed for https://cdn.jsdelivr.net/npm/tui-image-editor@3.2.2/dist/tui-image-editor.css

Seems to happen when filemtime is ran on the remote files loaded in the FroalaFieldServiceProvider.php (line 21)

Nova::style('tui-editor', 'https://cdn.jsdelivr.net/npm/tui-image-editor@3.2.2/dist/tui-image-editor.css');
Nova::style('tui-color-picker', 'https://uicdn.toast.com/tui-color-picker/latest/tui-color-picker.css');
@slavarazum
Copy link
Collaborator

slavarazum commented Dec 12, 2019

Could you try it now? Maybe it was an issue on cdn.jsdelivr.net

@iaK
Copy link
Author

iaK commented Dec 13, 2019

I don't think you can run filemtime on remote files. Probably need to include the styles in the package.

@1destiny
Copy link

Breaking change here: https://github.com/laravel/nova/commit/558156753b2772638e537bc1a468b281ce361e3a#diff-4f97552ae74c24e92b54d327885cc4b4

I have quite a few patches that I use because updates to Nova constantly breaks 3rd party plugins.
Not sure if Nova::script() or Nova::style() are meant to be used with remote files but certainly filemtime() didn't appear to work with remote urls - at least, not in my tests on different versions of php with php.ini setting allow_url_fopen = On.

My (temporary & not perfect) patch for this issue:

--- vendor/laravel/nova/src/Http/Controllers/StyleController.php	2019-12-15 11:37:08.000000000 +1300
+++ vendor/laravel/nova/src/Http/Controllers/StyleController.new.php	2019-12-15 11:37:43.000000000 +1300
@@ -30,6 +30,6 @@
             [
                 'Content-Type' => 'text/css',
             ]
-        )->setLastModified(DateTime::createFromFormat('U', filemtime($path)));
+        )->setLastModified(DateTime::createFromFormat('U', @filemtime($path) ?: now()->timestamp));
     }
 }
--- vendor/laravel/nova/src/Http/Controllers/ScriptController.php	2019-12-15 11:36:13.000000000 +1300
+++ vendor/laravel/nova/src/Http/Controllers/ScriptController.new.php	2019-12-15 11:36:54.000000000 +1300
@@ -30,6 +30,6 @@
             [
                 'Content-Type' => 'application/javascript',
             ]
-        )->setLastModified(DateTime::createFromFormat('U', filemtime($path)));
+        )->setLastModified(DateTime::createFromFormat('U', @filemtime($path) ?: now()->timestamp));
     }
 }

Use the patch with patch -p0 -N < patch-file-name.

@iaK
Copy link
Author

iaK commented Dec 17, 2019

@1destiny - thanks. Have you PR:ed it into nova itself?

@zippoxer
Copy link

zippoxer commented Mar 14, 2020

Do you think it's better to include the styles in the package instead of waiting for Nova to fix the remote files issue?

@slavarazum
Copy link
Collaborator

Fixed in 3.3.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants