Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Library refactor: Migrate legacy font family content #58032

Merged

Conversation

creativecoder
Copy link
Contributor

@creativecoder creativecoder commented Jan 20, 2024

What?

In #57688, we are changing the post_content of wp_font_family posts and splitting out the font faces into separate wp_font_face posts.

This change adds a migration so fonts previously installed with the old format will continue working.

Why?

To prevent Gutenberg plugin users from loosing installed fonts when the refactor lands.

How?

Running a one-time migration function on the init hook.

Testing Instructions

  • Checkout trunk and install fonts
  • Checkout this branch and check that those fonts remain installed and working in the font library.

You may also want to check that the database content is correct

  • The gutenberg_font_family_format_converted option is set after the migration
  • The fontFace json array items contained within wp_font_family content are moved to newly created wp_font_face posts
  • The old post_content within font families is backed up to _gutenberg_legacy_font_family_format post meta for each family
  • Font faces have _wp_font_face_file post meta created for their font file assets

@creativecoder creativecoder added [Type] Experimental Experimental feature or API. [Feature] Typography Font and typography-related issues and PRs labels Jan 20, 2024
@creativecoder creativecoder self-assigned this Jan 20, 2024
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ phpunit/tests/fonts/font-library/fontFamilyBackwardsCompatibility.php
❔ lib/experimental/fonts/font-library/font-library.php

Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given this a smoke test:

  • Checkout this branch and check that fonts from trunk remain installed and working in the font library ✅
  • I no longer see a client-side error when trying to load legacy-format fonts in the editor ✅

Database changes:

  • The gutenberg_font_family_format_converted option is set after the migration ✅
  • The fontFace json array items contained within wp_font_family content are moved to newly created wp_font_face posts ✅
  • The old post_content within font families is backed up to _gutenberg_legacy_font_family_format post meta for each family ✅ (It was saved under _gutenberg_legacy_font_family)
  • Font faces have _wp_font_face_file post meta created for their font file assets ✅

Approving as this is working well for me! This is a great way to handle the legacy format and functionality 👏

@creativecoder
Copy link
Contributor Author

PHP unit tests are failing, but it doesn't seem to be this branch, as they are failing across the repo.

@creativecoder creativecoder merged this pull request into try/font-library-refactor Jan 22, 2024
39 of 62 checks passed
@creativecoder creativecoder deleted the add/font-family-back-compat branch January 22, 2024 15:25
creativecoder added a commit that referenced this pull request Jan 23, 2024
* Font Library: add wp_font_face post type and scaffold font face REST API controller (#57656)

* Font Library: create font faces through the REST API (#57702)

* Refactor Font Family Controller (#57785)

* Font Family and Font Face REST API endpoints: better data handling and errors  (#57843)

* Font Families REST API endpoint: ensure unique font family slugs (#57861)

* Font Library: delete child font faces and font assets when deleting parent (#57867)

* Font Library: refactor client side install functions to work with revised API (#57844)

* Cleanup/font library view error handling (#57926)

* Font Faces endpoint: prevent creating font faces with duplicate settings (#57903)

* Font Library: Update uninstall/delete on client side (#57932)

* Font Library: address JS feedback in #57688 (#57961)

* Font Library REST API endpoints: address initial feedback from feature branch (#57946)

* Font Library: font collection refactor to use the new schema (#57884)

* Fix font asset download when font faces are installed (#58021)

* Font Families and Faces: disable autosaves using empty class (#58018)

* Adds migration for legacy font family content (#58032)

---------

Co-authored-by: Jeff Ong <jonger4@gmail.com>
Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com>
Co-authored-by: Jason Crist <jcrist@pbking.com>
Co-authored-by: Sarah Norris <sarah@sekai.co.uk>
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Type] Experimental Experimental feature or API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants