Skip to content

[FR] dirMode and fileMode options for FilesystemCache #3827

Open

Description

@brandonkelly

Currently FilesystemCache creates directories with 777 permissions, and PHP files with 666 permissions. It would be nice if new dirMode and fileMode options were supported, which could be used to override those default permissions.

Activity

  1. fabpot commented on Sep 12, 2024

    @fabpot
    Contributor

    I think the current code is reasonable. We're doing the same in Symfony as well. Note that the mode is affected by the umask. So, it's not necessarily 0777. You can call umask() to change the permissions.

    if new dirMode and fileMode options were supported -> I'm not sure what you're referring to here?

  2. brandonkelly commented on Sep 15, 2024

    @brandonkelly
    ContributorAuthor

    if new dirMode and fileMode options were supported -> I'm not sure what you're referring to here?

    I was suggesting that Twig could add new dirMode and fileMode options, giving us a way to set the permissions programmatically when initializing the Twig environment.

  3. fabpot commented on Sep 15, 2024

    @fabpot
    Contributor

    Would you agree that using umask() is enough?

  4. fabpot commented on Feb 8, 2025

    @fabpot
    Contributor

    Any feedback on my suggestion @brandonkelly?

  5. ericmorand commented on Feb 8, 2025

    @ericmorand
    Contributor

    What about not setting any permission at all and just creating the directories and files?

  6. brandonkelly commented on Feb 10, 2025

    @brandonkelly
    ContributorAuthor

    @fabpot I don’t think umask() would help in our case.

    Several libraries that work with files have dirMode/dirPermission and fileMode/filePermission settings (e.g. RotatingFileHandler in Monolog), so Craft has defaultDirMode and defaultFileMode config settings, and the hope is that those could apply to directories and files created by Twig as well.

  7. brandonkelly commented on Feb 10, 2025

    @brandonkelly
    ContributorAuthor

    (Sorry, didn’t mean to close the issue. Rogue trackpad click!)

  8. reopened this on Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions