Skip to content

Reconsider placing uploaded fonts within the uploads directory #59417

Closed

Description

@johnbillion

In #53965 the decision was made to use the wp-content/fonts directory for uploaded fonts rather than wp-content/uploads/fonts.

Following this discussion in Slack about the Font Library, this decision should be reassessed. There are pros and cons for using wp-content/fonts versus using a fonts directory within the uploads directory, some of which are technical.

Notes

Arguments in favour of wp-content/fonts

Arguments in favour of wp-content/uploads/fonts

  • Directories outside of wp-content/uploads may not be writable, either as a security measure or due to offloading uploaded media to a CDN
    • This is potentially a blocker
    • A discussion on this topic has been started in the #hosting channel in Slack
    • This has been raised previously
    • The decision to store fonts outside the uploads folder is problematic for immutable file systems and set ups in which user uploads are offloaded. It's not simply a case of making the directory writable, plugins will need to be updated, servers reconfigured.
    • This could affect high impact hosts such as WordPress VIP, any site using security hardening plugins, or any site using DISALLOW_FILE_MODS
  • Font files are uploaded by users, therefore it makes sense to place the uploaded files within the uploads directory
  • Personal data export files are placed within the uploads directory. Even though there is no specific discussion on that decision in the core Trac ticket for that feature, it's likely this was done for the technical reasons above.

Please comment with any further arguments in favour or against either location.

Activity

  1. added
    [Priority] High
    Needs Design
    Needs Decision
    and removed
    Needs Design
    on Feb 27, 2024
  2. moved this to 🗣️ In Discussion / Needs Decision in WordPress 6.5 Editor Taskson Feb 27, 2024
  3. priethor commented on Feb 27, 2024

    @priethor
    Contributor

    I believe the fonts location should be outside uploads for the above reasons, which outweigh the cons. Furthermore, I would argue that users don't upload the fonts; they are downloaded from external directories just like themes and plugins.

    Since the primary reasons for using the uploads folder seem to be practical reasons to ensure compatibility, why not use it only as a fallback or allow a setting to configure it?

  4. hellofromtonya commented on Feb 27, 2024

    @hellofromtonya
    Contributor

    For historical context, during 6.4's merge consideration, this concern was raised. But the discussion didn't continue forward and IMO was unresolved.

    Why? The primary focus was on the REST API's architecture as it was the biggest blocker and highest priority at that time. I suspect it consumed the focus and times, leaving less for deeper reviews and follow-ups.

  5. costdev commented on Feb 27, 2024

    @costdev
    Contributor

    I believe the fonts location should be outside uploads for the above reasons, which outweigh the cons. Furthermore, I would argue that users don't upload the fonts; they are downloaded from external directories just like themes and plugins (maybe wp-content should be considered instead?).

    I agree. I think from an organisational perspective, wp-contents/fonts is the correct choice. IMO, we should be looking at what's needed to make that work, and the lead time needed on all fronts to make sure it's usable at release.

    uploads, plugins, mu-plugins, themes, upgrade and upgrade-temp-backup are directories located in wp-content. Deployment setups will largely only have uploads as a writable directory there. I understand why this would lead us to putting a fonts subdirectory in uploads instead to avoid technical implications, though I think that would be us leaning into what's easier and immediately workable, though it's also a permanent decision for BC. To me, it feels more like we need to work on a solid communication strategy and affording appropriate timeframes to facilitate this change, than on the implementation.

    If we were introducing the wp-content/uploads directory, and all of the same technical implications existed, how would we go about introducing this new writable directory, communicating this to hosts, developers and users, with enough time for identifying issues and for everyone to do what needs done to make it work?

  6. hellofromtonya commented on Feb 27, 2024

    @hellofromtonya
    Contributor

    I would argue that users don't upload the fonts; they are downloaded from external directories just like themes and plugins (maybe wp-content should be considered instead?).

    I'm not sure I understand @priethor. Can you share more?

    Media (images, videos, audio, PDFs, etc.) can also be first downloaded from somewhere (a camera, recording device, external media providers, etc.). It's the same for fonts as a user can upload a font file that they have stored on their computer.

  7. swissspidy commented on Feb 27, 2024

    @swissspidy
    Member

    Initial response from asking in the #hosting channel:

    Both Pantheon and WordPress.com VIP change the default location to wp-content/uploads/fonts because the current location doesn't work for them. See https://github.com/pantheon-systems/pantheon-mu-plugin/blob/main/inc/fonts.php and Automattic/vip-go-mu-plugins#5265.

    If they have to add workarounds to make the feature work for them, that's an indicator that the default location is maybe not the best.

  8. costdev commented on Feb 27, 2024

    @costdev
    Contributor

    If they have to add workarounds to make the feature work for them, that's an indicator that the default location is maybe not the best.

    I agree that it's perhaps an indicator, though I'd like to know about the roadblocks to them and others making the new wp-content/fonts directory writable instead of filtering to wp-content/uploads/fonts. I think it's important that we document the reason(s) why one possible path is chosen over another.

  9. johnbillion commented on Feb 27, 2024

    @johnbillion
    MemberAuthor

    This is because the uploads directory is mounted on a completely separate filesystem to facilitate horizontal scaling, replication, CDN etc. It's not just about making other directories writable.

    Most WordPress hosts that provide scalable architecture work in the same way, and it's nothing new. Some docs here for Altis Cloud as an example: https://docs.altis-dxp.com/cloud/s3-storage/.

  10. andreilupu commented on Feb 27, 2024

    @andreilupu
    Contributor

    I think that any uploadable should go to wp-content/uploads/ because this is the premise that we all followed by either plugin/themes developers, hosts, etc.

    Introducing uploaded files outside of wp-content/uploads/ will introduce a new level of complexity. I can only imagine how many troubles this will bring to

    • multi-sites with front-end editors & upload capabilities.
    • external storages
    • CDNs (while any production site will want to cdn the fonts)
    • Docker instances that assume wp-content/uploads/ as a separate volume.
    • Hosts that use git as file versioning/backup systems; they usually treat wp-content/uploads/ differently.
  11. 40 remaining items

  12. justlevine commented on Mar 6, 2024

    @justlevine
    Contributor

    This talk about DISALLOW_FILE_MODS has me wondering... If we are discussing from the philosophical-side-of-things, what actually is the default assumption of behavior for fonts when DISALLOW_FILE_MODS is enabled?

    Whatever that assumption is, we can adapt the behavior if necessary (as @azaozz noted earlier), but there's something to be said for having our code checks and directory tree follow the same logical structure.

    (alternatively, allowing fonts to be autodiscoverable if they're added directly to the fonts folder would also seem to clear all this up. I'm sure that's been discussed in a previous ticket, but I cant seem to find it).

  13. jazzsequence commented on Mar 6, 2024

    @jazzsequence

    @justlevine

    (alternatively, allowing fonts to be autodiscoverable if they're added directly to the fonts folder would also seem to clear all this up. I'm sure that's been discussed in a previous ticket, but I cant seem to find it).

    You mean like this one? 😁 #59102

  14. azaozz commented on Mar 6, 2024

    @azaozz
    Contributor

    I don't think that's a coincidence—that was the intended behaviour when DISALLOW_FILE_MODS was introduced in... April 2010, almost 14 years ago

    Hmm, doesn't seem to be the case? Several of the "other" files and/or dirs in /wp-content that WP may use were introduced before that. Also, imho the commit message puts it quite nicely:

    (In [14088]) Introduce DISALLOW_FILE_MOD for disabling all ops that modify core, theme, or plugins files. see #13000

    In any case, as far as I see it this is more of a "future proof" architecture decision, coincidence or not.

  15. johnbillion commented on Mar 7, 2024

    @johnbillion
    MemberAuthor
  16. peterwilsoncc commented on Mar 7, 2024

    @peterwilsoncc
    Contributor

    I've closed this issue as unplanned. As a reminder, discussion can continue on a closed issue and participants will continue to be notified.

    #59699 has been opened for considering the architectural decisions that are required for the fallback.

  17. moved this from 🗣️ In Discussion / Needs Decision to ✅ Done in WordPress 6.5 Editor Taskson Mar 7, 2024
  18. peterwilsoncc commented on Mar 21, 2024

    @peterwilsoncc
    Contributor

    After learning a little more about including a fallback within Core by default, its' been decided not to include the feature in 6.5. An announcement post has posted on the Make Core blog.

    The original feature announcement dev note has been updated to reflect this change.

  19. justlevine commented on Mar 22, 2024

    @justlevine
    Contributor

    After learning a little more about including a fallback within Core by default, its' been decided not to include the feature in 6.5. An announcement post has posted on the Make Core blog.

    The original feature announcement dev note has been updated to reflect this change.

    Wasn't Josepha's decision for 6.5 based on the ability to make this compromise?

  20. peterwilsoncc commented on Mar 26, 2024

    @peterwilsoncc
    Contributor
  21. added
    [Status] In Progress
    on Apr 2, 2024
  22. creativecoder commented on Apr 2, 2024

    @creativecoder
    Contributor

    I created a PR to bring WP changes from https://core.trac.wordpress.org/changeset/57878 to Gutenberg: #60354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Needs Decision[Feature] Font Library[Priority] High[Status] In Progress

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions