#61297 closed defect (bug) (fixed)
Font Directory uploads ignore `subdir` property.
| Reported by: | peterwilsoncc | Owned by: | hellofromTonya |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.5.5 |
| Component: | Editor | Version: | 6.5 |
| Severity: | normal | Keywords: | has-patch has-unit-tests has-test-info commit dev-reviewed |
| Cc: | Focuses: |
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 (14)
This ticket was mentioned in PR #6638 on WordPress/wordpress-develop by @peterwilsoncc.
2 years ago
#3
- Keywords has-patch has-unit-tests added
@peterwilsoncc commented on PR #6638:
2 years 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
@
2 years ago
- Milestone Awaiting Review → 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
@
2 years 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 !
#8
@
2 years ago
- Keywords dev-feedback added
- Milestone 6.6 → 6.5.5
- Resolution fixed
- Status closed → 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:
2 years ago
#9
#10
@
2 years ago
- Owner changed from to
- Status reopened → reviewing
Currently reviewing and testing [58353] for backport to the 6.5 branch.
#11
@
2 years 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Edited the description to clarify the bug: the sub-directory is not stored in the post meta.