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

WordPress Trac noreply at wordpress.org
Thu Jun 27 20:29:40 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 azaozz):

 Replying to [comment:67 peterwilsoncc]:

 > 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.

 Yea, I agree a lambda callback to a filter is somewhat unusual in core. It
 is quite common in plugins. However I don't see how that is a "maintenance
 burden" especially after the decision to revisit this code early in WP
 6.6. I also don't see how using a lambda function is "against the coding
 standards". It is undesirable as those filter callbacks cannot be removed
 (easily). However in this particular case the fact that this is non-
 removable prevents plugins from mangling the Uploads API.

 Also changing from a lambda callback to a normal function callback doesn't
 change anything about an infinite loop possibility. Both are equally bad
 as both increase the risk that "the infinite loop trap would be
 introduced". As I've said several times already [57740] not only didn't
 fix that possibility of infinite loop, but also made it worse by hiding it
 from the developers.

 > 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.

 Great! So how come this patch couldn't be reviewed and committed for over
 three months now? Sounds bizarre, isn't it? :(

 > 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...

 As I explained earlier this patch **does not introduce** a way for plugins
 to bypass the `uploads_dir` filter as used in core. Please have a look at
 the code again.

 I'd like to repeat this again: The only way a plugin can use the new
 parameters added in this patch is by using either the
 `_wp_handle_upload()` or the `wp_upload_bits()` functions directly. A
 plugin cannot use these parameters when core is using these functions,
 hence a plugin cannot bypass any filters and cannot change anything else.
 The behavior is exactly the same as before the patch.

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


More information about the wp-trac mailing list