Opened 4 months ago
Closed 4 months ago
#61297 closed defect (bug) (fixed)
Font Directory uploads ignore `subdir` property.
Reported by: | peterwilsoncc | Owned by: | hellofromTonya |
---|---|---|---|
Milestone: | 6.5.5 | Priority: | normal |
Severity: | normal | Version: | 6.5 |
Component: | Editor | Keywords: | has-patch has-unit-tests has-testing-info commit dev-reviewed |
Focuses: | Cc: |
Description (last modified by )
The data structure for the font directory matches the uploads directory and contains the following properties:
- path
- url
- subdir
- basedir
- baseurl
- error (only used during directory creation)
When uploading fonts, the sub-directory is not stored in the post meta and prevents the deletion of files when the font-face post objects are deleted.
add_filter( 'font_dir', function ( $font_dir ) {
/*
* Change sub-directory every 5 minutes.
*
* POC only, a more likely use is to get the `fontFamily` from the API
* request or the currently active theme and use either of those values
* to generate a unique sub-directory.
*
* The POC is simply to allow for eaiser testing by setting a new
* sub-directory every few minutes.
*/
$subdir = '/' . (string) floor( time() / 300 );
$font_dir['subdir'] = $subdir;
$font_dir['path'] .= $subdir;
$font_dir['url'] .= $subdir;
return $font_dir;
} );
The following will need to be updated to account for the sub-directory:
- post meta data containing the file reference
- deletion of files in
_wp_before_delete_font_face()
To reproduce:
- Upload a font/sideload from Google
- Observe the font file is stored in a sub-directory
- Observe the font file's sub-directory is not stored in the post meta
- Wait five minutes (using sample plugin above)
- Delete the font via the font library
- Observe the file is not deleted
Change History (13)
This ticket was mentioned in PR #6638 on WordPress/wordpress-develop by @peterwilsoncc.
4 months ago
#3
- Keywords has-patch has-unit-tests added
@peterwilsoncc commented on PR #6638:
4 months ago
#4
@costdev Done, the failing tests can be seen against 134770eb5d6ba43faa1fb5475890e188ec890a77 and passing against the latest commit.
The Gutenberg tests are failing but it looks to be typescript related so I am not sure what is happening there.
#5
@
4 months ago
- Milestone changed from Awaiting Review to 6.6
Moving this to the 6.6 milestone while a discussion takes place in Slack as to whether it ought to be included in a minor 6.5 release.
#6
@
4 months ago
I've tested and approved the PR attached to this ticket (https://github.com/WordPress/wordpress-develop/pull/6638#pullrequestreview-2099643069). Thanks for finding and fixing this @peterwilsoncc !
#7
@
4 months ago
- Owner set to peterwilsoncc
- Resolution set to fixed
- Status changed from new to closed
In 58353:
#8
@
4 months ago
- Keywords dev-feedback added
- Milestone changed from 6.6 to 6.5.5
- Resolution fixed deleted
- Status changed from closed to reopened
Re-opening and moving to the minor release milestone for backport consideration.
If it's decided not to backport, please close as fixed and move the ticket back to WP 6.6.
@peterwilsoncc commented on PR #6638:
4 months ago
#9
#10
@
4 months ago
- Owner changed from peterwilsoncc to hellofromTonya
- Status changed from reopened to reviewing
Currently reviewing and testing [58353] for backport to the 6.5 branch.
#11
@
4 months ago
- Keywords has-testing-info added
Test Report
Patch tested:[58353]
Steps to Reproduce or Test
- Add mini-plugin to mu-plugins
- Upload/install a font from Google
- Wait 30 seconds or so (for a tick of the clock in the plugin above to change the directory)
- Delete the font from the font-library 🐞
Expected Results
When testing a patch to validate it works as expected:
- ✅ The font file should be deleted / removed from the file system.
When reproducing a bug:
- ❌ The font file remains on the filesystem.
Environment
- OS: macOS
- Web server: nginx
- PHP: 8.3
- WordPress: 6.5.4 and 6.6 Beta 3
- Plugins: none
- Theme: TT4 default
Actual Results
On 6.5.4:
Yes, I can reproduce the bug
- ❌ The font file was not deleted from the filesystem.
When testing the bugfix patch:
- ✅ The font file was deleted from the filesystem, while the subdirectory was not.
Also tested 6.6 Beta 3 which includes the [58353]:
- ✅ The font file was deleted from the filesystem, while the subdirectory was not.
Edited the description to clarify the bug: the sub-directory is not stored in the post meta.