[wp-trac] [WordPress Trac] #52241: Infinite loop in clean_dirsize_cache()

WordPress Trac noreply at wordpress.org
Fri Oct 15 22:58:01 UTC 2021


#52241: Infinite loop in clean_dirsize_cache()
--------------------------------------------+-----------------------------
 Reporter:  raubvogel                       |       Owner:  hellofromTonya
     Type:  defect (bug)                    |      Status:  closed
 Priority:  normal                          |   Milestone:  5.9
Component:  Filesystem API                  |     Version:  5.6
 Severity:  major                           |  Resolution:  fixed
 Keywords:  has-patch early has-unit-tests  |     Focuses:  multisite
--------------------------------------------+-----------------------------

Comment (by hellofromTonya):

 In [changeset:"51912" 51912]:
 {{{
 #!CommitTicketReference repository="" revision="51912"
 FileSystem API: Add safeguard for invalid return from
 `get_attached_file()` in `wp_delete_attachment()`.

 The `get_attached_file()` function is supposed to return the path to the
 file, but could:
 1. Return `false` if the file doesn't exist.
 2. Return literally anything else, as a filter is being applied to the
 value on return.

 As the `clean_dirsize_cache()` now has input validation, passing anything
 but a non-empty string to `clean_dirsize_cache()` will result in a PHP
 error notice.

 This was exposed by the `Tests_Post_GetPostStatus::wpSetUpBeforeClass()`
 method which started generating unexpected output (the doing it wrong
 message) during the test run.

 While this indicates that there is a flaw in the mocking being done in the
 test suite, debugging that is outside of the scope of the current patch.

 At the same time, as based on the above point, this ''could'' potentially
 happen in a real-world situation as well, adding additional conditions to
 the `if` in the `wp_delete_attachment()` function before calling the
 `clean_dirsize_cache()` function, is warranted.

 As there are no tests for the `wp_delete_attachment()` function at all at
 this time, we're not adding a test specifically for this change for now.
 This should however be addressed in the future, when tests will be added
 to cover the `wp_delete_attachment()` function completely.

 Follow-up to [32619], [49212], [51910].

 Props jrf, hellofromTonya.
 See #52241.
 }}}

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


More information about the wp-trac mailing list