Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: compiled_templates doesn’t respect defaultDirMode #13049

Closed
vandres opened this issue Apr 4, 2023 · 4 comments
Closed

[4.x]: compiled_templates doesn’t respect defaultDirMode #13049

vandres opened this issue Apr 4, 2023 · 4 comments
Assignees

Comments

@vandres
Copy link
Contributor

vandres commented Apr 4, 2023

What happened?

Description

We are running Craft on a server, where apache is not a real user and every actual user is in the same group with apache. That are users for SFTP and running cronjobs. We had some weird issues with mutex locks, which were not accessable and cache directories, which could not be created.

In the general config we set dir and file mode to include group writing rights.

    ->defaultDirMode(0775)
    ->defaultFileMode(0664)

But on the server, not every directory is created with the correct mode. On the screenshot you can see, that "nocache" is created correctly, but all the other directories are just 0755.

grafik

Steps to reproduce

  1. set defaultDirMode
  2. enable template caching
  3. look at the mode of the created directories

Expected behavior

defaultDirModeis respected for all Craft created directories

Actual behavior

defaultDirMode is not respected everywhere

Craft CMS version

4.3.11

PHP version

8.1

Operating system and version

CentOS

Database type and version

MariaDB 10.5

Image driver and version

Installed plugins and versions

"require": {
"craftcms/cms": "~4.3.8",
"craftcms/commerce": "^4.1.0",
"craftcms/commerce-paypal-checkout": "dev-develop",
"craftcms/redactor": "^3.0",
"mmikkel/cp-field-inspect": "^1.4",
"nystudio107/craft-retour": "^4.1",
"nystudio107/craft-vite": "^4.0",
"php-http/curl-client": "^2.2",
"putyourlightson/craft-elements-panel": "^2.0",
"putyourlightson/craft-sprig": "^2.1",
"sebastianlenz/linkfield": "^2.1",
"spatie/craft-ray": "^2.0",
"spicyweb/craft-neo": "^3.2",
"ttempleton/craft-nocache": "^3.0",
"typesense/typesense-php": "^4.8",
"vaersaagod/geomate": "^2.1.0",
"verbb/expanded-singles": "^2.0",
"verbb/field-manager": "^3.0",
"verbb/tablemaker": "^4.0",
"verbb/wishlist": "^2.0",
"vlucas/phpdotenv": "^5.4.0",
"wbrowar/adminbar": "^3.2"
},
"require-dev": {
"deployer/deployer": "^7.0",
"yiisoft/yii2-shell": "^2.0.3",
"roave/security-advisories": "dev-master"
},

@i-just
Copy link
Contributor

i-just commented Apr 5, 2023

Hi, thanks for reaching out. The directories and files inside the compiled_templates directories are created by Twig’s FilesystemCache, not by Craft itself which is why the defaultDirMode is not respected there.

The compiled_templates itself is created by Craft, so the defaultDirMode for it is respected.

Same with the nocache directory, it’s created via Craft’s FileHelper::createDirectory() (https://github.com/ttempleton/craft-nocache/blob/main/src/Service.php#L35), which means the defaultDirMode is respected.

That being said, we’ll discuss this internally.

@vandres
Copy link
Contributor Author

vandres commented Apr 5, 2023

@i-just Thanks for the quick reply. Is there any way to configure Twig within Craft to use that file mode?

@i-just
Copy link
Contributor

i-just commented Apr 5, 2023

I’m not sure. I couldn’t see an option to do that easily. That’s why I want to discuss this internally. I’ll let you know once I have more info.

@i-just i-just self-assigned this Apr 5, 2023
@brandonkelly
Copy link
Member

brandonkelly commented Apr 5, 2023

Currently FilesystemCache doesn’t make the dir/file modes configurable. I’ve just opened a feature request to change that: twigphp/Twig#3827

If it gets implemented, we’ll definitely start taking advantage of it, and I’ll update this issue.

@brandonkelly brandonkelly changed the title [4.x]: compiled_templates and compiled_classes don't respect defaultDirMode [4.x]: compiled_templates doesn’t respect defaultDirMode Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants