JesseWebDotCom / webtrees-theme-modern

A theme for webtrees, optimized for a mobile and modern experience
22 stars 2 forks source link

filemtime(): stat failed #18

Closed hartenthaler closed 1 year ago

hartenthaler commented 1 year ago

ErrorException: filemtime(): stat failed for /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/modules_v4/webtrees-theme-modern2/resources/css/palettes/colorful (white/blue/bootstrap.min.css in /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/app/Module/ModuleCustomTrait.php:155 Stack trace: #0 [internal function]: Fisharebest\Webtrees\Webtrees::Fisharebest\Webtrees\{closure}() #1 /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/app/Module/ModuleCustomTrait.php(155): filemtime() #2 /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/modules_v4/webtrees-theme-modern2/ModernTheme.php(252): JessewebDotCom\Webtrees\Module\ModernTheme\ModernTheme->assetUrl() #3 /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/resources/views/layouts/default.phtml(58): JessewebDotCom\Webtrees\Module\ModernTheme\ModernTheme->stylesheets() #4 /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/app/View.php(183): include('...') #5 /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/app/View.php(278): Fisharebest\Webtrees\View->render() #6

JesseWebDotCom commented 1 year ago

"colorful (white/blue/bootstrap.min.css" - means you are using the old version of the theme (as this palette is not present in the latest version of the theme). Wipe out the entire old theme directory and add the new theme directory.

hartenthaler commented 1 year ago

I added to the directory name of the existing modern theme ".disable". Then copied the new module to another (new) directory "modules_v4/webtrees-theme-modern2" which results in the above error.

JesseWebDotCom commented 1 year ago

keeping the old theme in the modules_v4 folder will still load the theme, even when renaming. Move the old theme out of the webtrees directory structure and try again.

BTW - I am about to upload a release of the "Life Story" tab module with language translation (English, Spanish, and German to start). I'll announce in the webtrees community and tag you.

hartenthaler commented 1 year ago

I have deleted now both modern directories. Uploaded only the new modern theme, but the error is the same.

I'm curious about the new "Life Story" and can support you by translating it into German.

JesseWebDotCom commented 1 year ago

Try this:

hartenthaler commented 1 year ago

In "modules_v4/webtrees-theme-modern/resources/css/palettes" there are two subfolders "bootswatch" and "modern". Is the folder "bootswatch" needed? There is no "modules_v4/webtrees-theme-modern/resources/css/palettes/colorful.

JesseWebDotCom commented 1 year ago

You need to delete the entire module (not just the subfolders or files in the module). So for you, I think you need to delete:

Then follow my instructions above

hartenthaler commented 1 year ago

I deleted the entire module (both folders modern and moden2). I followed the instructions and deleted preferences for modern and modern2. Copied the folder again to the webtrees server. And the error is there again.

JesseWebDotCom commented 1 year ago

I worry when you say "copied the folder again", you copied old theme files (or you are mixing new theme files with old ones - like you customized a file in the old them and are trying to use it in the new theme).

Can you reply with a screenshot of the "folder" showing every folder, file, and file size?

hartenthaler commented 1 year ago

I just downloaded https://github.com/JesseWebDotCom/webtrees-theme-modern/releases/download/0.0.1/webtrees-theme-modern.0.0.1.zip again from your release. I did not mixed up anything. I copied only the new folder with the new modern theme to the server. There is no old version there. Screenshot (344)

JesseWebDotCom commented 1 year ago

Looks good. According to the error, your problem is here: /mnt/web109/a3/99/51547399/htdocs/hermann/hartenthaler/php/webtrees/modules_v4/webtrees-theme-modern2/ModernTheme.php

Which is likely the old theme file. Are you able to access that directory and delete the files? If not, sounds like you are using an external provider to host webtrees and there's a caching issue going on.

Maybe also try deleting the files, restarting your web server, adding the files, and testing again.

JesseWebDotCom commented 1 year ago

BTW (and unrelated to this issue) - you can test out the preview release of the Life Story tab (I added German translations): https://www.webtrees.net/index.php/en/forum/4-customising/38105-new-tab-life-story

JesseWebDotCom commented 1 year ago

And according to chatgpt (I have not tested these recommendations nor do I know if they are safe/valid):

hartenthaler commented 1 year ago

I have deleted now in another of my webtrees installations the existing modern theme. In the control panel, I have deleted the settings for this module. Copied the new module folder to the server. The error is there in this environment, too. It is not a cache problem and it is not a file permission problem.

I out-commented the line #252 in ModernTheme.php ($files[] = $this->assetUrl($file);). Now the error disappeared. But the functionality is gone, too.

JustCarmen commented 1 year ago

I wanted to try this theme out of curiosity, but got the same error message as a logged in user. Without logging in I did get a working theme.

It took some digging in the code (largely a copy of the justlight theme so not too hard for me to read) and I found the culprit.

To get rid of this error message you have to manually remove the modern-palette setting from the table wt-user-setting in the database.

JesseWebDotCom commented 1 year ago

@JustCarmen - thanks. that's problematic but only for users of the old theme. any suggestions on how to do this in the theme so users do not have to dig into the database?

JustCarmen commented 1 year ago

Not tested but I think this should work:

In the function palette you have this code:

// If we are logged in, use our preference     
$palette = Auth::user()->getPreference('modern-palette', '');

After that put this code:

if (!in_array($palette, $this->palettes())) {
    // remove the remaining setting from the old theme
    DB::table('user_setting')->where('setting_name', '=', 'modern-palette')->delete();
}
hartenthaler commented 1 year ago

This additional code does the trick. Thank you, @JustCarmen

The new themes are looking great now. Thank you, @JesseWebDotCom

hartenthaler commented 1 year ago

I like the modern theme! Especially the new Ancestry theme looks familiar.

JesseWebDotCom commented 1 year ago

Closing as this only applies to people who had the old theme