[wp-trac] [WordPress Trac] #60835: Fix and improve handling of uploading of font files

WordPress Trac noreply at wordpress.org
Wed Jun 26 23:56:28 UTC 2024


#60835: Fix and improve handling of uploading of font files
----------------------------------------------------+---------------------
 Reporter:  azaozz                                  |       Owner:  (none)
     Type:  defect (bug)                            |      Status:  new
 Priority:  high                                    |   Milestone:  6.6
Component:  Upload                                  |     Version:  6.5
 Severity:  normal                                  |  Resolution:
 Keywords:  needs-testing has-patch has-unit-tests  |     Focuses:
----------------------------------------------------+---------------------

Comment (by peterwilsoncc):

 > Yet another bug here is that [57868] introduces an anti-pattern to WP, a
 filter is run in the callback to another filter. This causes several
 problems including a possibility for infinite loop and possibility for
 plugins to completely remove the "nested" filter. A plugin removing a
 filter that is a part of an API in WP is not acceptable imho. This is more
 of a "code architecture" bug but I think it has major drawbacks and such
 code should never exist in WP.

 As I've pointed out previously, this behaviour was introduced in the
 original pull request to Gutenberg and delivered in the
 [https://github.com/WordPress/wordpress-
 develop/blob/4757b7ad7f7e023903ec75c16318f58a6da19dcd/src/wp-includes
 /rest-api/endpoints/class-wp-rest-font-faces-controller.php#L859-L877
 original merge of the font API to WordPress-Develop].

 The reason I reopened #60652 was because of the introduction of a lamda
 function in [57740]. This represented a maintenance burden to maintainers
 as it went against the coding standards, increasing the risk the infinite
 loop trap would be introduced.

 > Having a /fonts directory (whether it is wp-content/uploads/fonts or at
 any other place) is a base part of the WP Uploads API. Not having a /fonts
 directory is a major breakage of the design and of the intended behavior
 when storing fonts.

 I don't necessarily disagree with this. As I mentioned in one of my
 earlier comments on the PR linked to this ticket, the introduction of a
 context to the various uploads APIs is something I am happy to work
 towards.

 This would allow WordPress to prevent the bypassing of the `font_dir`
 filter.

 > Don't think there are any significant architectural changes in this
 patch. The only change is that it prevents plugins from making the WP
 Uploads API inconsistent.

 My main issue with this ticket is that I don't think introducing an API
 that allows plugin authors to bypass the `uploads_dir` filter is a good
 solution to the issue that the original code allowed plugin authors to
 bypass the `font_dir` filter.

 The use of `uploads_dir` to enable the use of offloading is a long term
 feature of WordPress that the changes in this ticket allows to be
 bypassed. This is the significant architectural change I am concerned
 about and it appears I am not alone in this.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60835#comment:67>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list