Framework for storing revisions of Post Meta in 6.4

RevisionsRevisions The WordPress revisions system stores a record of each saved draft or published update. The revision system allows you to see what changes were made in each revision by dragging a slider (or using the Next/Previous buttons). The display indicates what has changed in each revision. are now supported for post metaMeta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. on an opt-in basis. This feature is currently used by coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. for footnotes – enabling footnotes to be correctly previewed, stored in autosaved and stored and retrieved from revisions. In the future, this may be expanded to the featured imageFeatured image A featured image is the main image used on your blog archive page and is pulled when the post or page is shared on social media. The image can be used to display in widget areas on your site or in a summary list of posts. which is also stored in meta.

When registering a new meta field with register_meta or register_post_meta, the $args parameter accepts a new revisions_enabled argument. This defaults to false—set to true to opt in to revisions for this meta field. Note that the object type the meta is being created for must have revision support in order for the meta field to have revisions enabled. Attempting to enable meta revisions for a post type that doesn’t support revisions will result in a doing_it_wrong warning.

This feature is designed to lay the groundwork for future improvements to GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ as part of Phase 3: Collaboration. Care has been made to do this in a backwards compatible manner, but if you are unhooking anything in the post save/update process, please read this entire note and test your code before WordPress 6.4 is released

A new wp_post_revision_meta_keys filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. is introduced, which can be used to filter the list of meta fields to be revisioned. The post type is also passed to the filter, which can be used to adjust revisioning of meta fields.

// Example to add a `my_product_price` meta field to revisions.
function enable_revisions_for_product_price_field( $revisioned_keys ) {
	if ( ! in_array( 'my_product_price', $revisioned_keys, true ) ) {
		$revisioned_keys[] = 'product_price';
	}
	return $revisioned_keys;
}
add_filter( 'wp_post_revision_meta_keys', 'enable_revisions_for_product_price_field' );

The _wp_put_post_revision action, which fires once a revision is saved, includes a new parameter—the post ID associated with the revision. This is used by core to copy the meta data from the main post to the revision.

The wp_creating_autosave action, which fires before an autosave is stored, includes a new parameter `$is_update`, added to indicate if the autosave is being updated or was newly created.

Meta revisions are also stored for autosaves and when previewing posts, fixing a long standing bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. (#20299) that caused live post meta to be overwritten when post meta was previewed. This is because using update_post_meta to save meta to a revision actually resulted in it being saved to the parent post. With this change, developers can now opt in to meta revisions and core will correctly attach the meta data to the revision. Meta that has revisions is also restored when restoring an autosave or revision. 

The REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/. revisions endpoint now returns meta when stored as part of a revision and the autosaves endpoint now handles storing of meta.

The new meta revision features are enabled in core via hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same.; removing the hooks will disable the features:

To disable post meta revisions entirely, use:

remove_action( 'wp_after_insert_post', 'wp_save_post_revision_on_insert', 9, 3 );

To disable storing post meta on autosaves, use:

remove_action( 'wp_creating_autosave', 'wp_autosave_post_revisioned_meta_fields' );

To disable restoring meta when restoring revisions or autosaves, use:

remove_action( 'wp_restore_post_revision', 'wp_restore_post_revision_meta', 10, 2 );

Important note: as part of this change, the timing for the storing of post revisions has been changed. Previously, revisions were created before post meta had been saved by the REST API on the post_updated hook.  Revisions are now hooked on the wp_after_insert_post action, fired after post meta has been saved. 

Special backwards compatibility consideration has been given to plugins that may be unhooking post_updated from wp_save_post_revision to disable revisions—in that case, core ensures revisions are still not created.


Props to @westonruter, @jorbin and @webcommsat for reviewing.

#6-4-2, #dev-notes, #dev-notes-6-4

Dev Chat Summary, May 31, 2023

(Update June 6, 2023 – posts on 6.4 and GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ added to section at the end of this post.)

Notes from the weekly WordPress developers chat which took place in the core channel of Make WordPress Slack. All are welcome.

To read the meeting on SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. itself, it starts at this link.

1.Welcome and housekeeping

Dev Chat agenda – thanks to @webcommsat for preparing.

Note: The agenda includes information links for releases and some related content to coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress., especially this and next week to help new contributors to core going to WordCampWordCamp WordCamps are casual, locally-organized conferences covering everything related to WordPress. They're one of the places where the WordPress community comes together to teach one another what they’ve learned throughout the year and share the joy. Learn more. Europe. To allow time for more discussions on tickets, all the links may not always be highlighted during the actual dev chat, and attendees are encouraged to check the full link list in the agenda itself.

Thanks to @ironprogrammer for facilitating the meeting.

2. WordPress Announcements 

Details on the latest Gutenberg pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party release: What’s new in Gutenberg 15.9? (31 May).

3. Highlighted posts

6.2 server performance analysis summary from the Core-Performance team.

Celebrating 20 years of WordPress – post by Josepha on May 27, 2023.

Analysis of the results of the individual learner survey from Learn.WordPress.org – posted by @webcommsat. This shares findings of the survey, and presents opportunities for cross-collaboration with Core and other Make teams.

Contributor Mentorship Programme – post by @harishanker. Share your feedback to help shape mentorship in our community, and even volunteer as a mentor!

The next phase of initiatives to promote and increase sustainability in the WordPress community and wider is the Proposal: establishment of a formal WordPress Sustainability Team. The sustainability initiative meets weekly on Fridays in the #sustainability channel on the Make WordPress Slack. All welcome to attend or view the discussions asynchronously.

4. Updates on releases

Next major releasemajor release A release, identified by the first two numbers (3.6), which is the focus of a full release cycle and feature development. WordPress uses decimaling count for major release versions, so 2.8, 2.9, 3.0, and 3.1 are sequential and comparable in scope.

WordPress 6.3 will be the next major release.

Roadmap to 6.3 

WordPress 6.3 Planning Roundup

6.3 Bug Scrub schedule

#6-3-release-leads channel on Slack is a good way to keep up with what is happening with the release.

Last minor releaseMinor Release A set of releases or versions having the same minor version number may be collectively referred to as .x , for example version 5.2.x to refer to versions 5.2, 5.2.1, 5.2.3, and all other versions in the 5.2 (five dot two) branch of that software. Minor Releases often make improvements to existing features and functionality. for reference

6.2.2 Security release – this came out on May 20, 2023. It addresses 1 bug and 1 security issuesecurity issue A security issue is a type of bug that can affect the security of WordPress installations. Specifically, it is a report of a bug that you have found in the WordPress core code, and that you have determined can be used to gain some level of access to a site running WordPress that you should not have.. As it is a security release, it is recommended that sites are updated immediately if you have not done so already.

Last Gutenberg release: 15.9 available to download.


4. Help requests relating to tickets or from Component Maintainers

If you have any tickets you would like to raise, you can share them in comments too. If you can not attend live, you can still add a ticketticket Created for both bug reports and feature development on the bug tracker. and your query in the comments, and the facilitator will be able to share it in the meeting.

Volunteers are also needed to help run bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. scrubs.

@oglekler requested feedback on ticket #58354 in the Help/About component.

@kebbett requested review and test the PR for ticket #57893. This ticket is in the 6.3 milestone.

@petitphp requested a second opinion on ticket #58312.

@mrinal highlighted ticket #58416.

5. Open floor

Update on core tables at WordCamp Europe – if you have an update to share, you can also add it to the comments on the agenda.
Preparing for WordCamp Europe 2023 Contributor Day.

@webcommsat shared the link to a draft post to be shared with WCEU team once published.

Post dev chat posts

Preparing to join the WordCamp Europe 2023 core tables at Contributor DayContributor Day Contributor Days are standalone days, frequently held before or after WordCamps but they can also happen at any time. They are events where people get together to work on various areas of https://make.wordpress.org/ There are many teams that people can participate in, each with a different focus. https://2017.us.wordcamp.org/contributor-day/ https://make.wordpress.org/support/handbook/getting-started/getting-started-at-a-contributor-day/.? Information to help you get started and set up a local environment in advance.

WordPress 6.4 Development Cycle – published June 5, 2023.

Gutenberg 15.9.1 available.

Are you interested in helping draft Dev Chat summaries? Volunteer at the start of the next meeting on the #core Slack channel.

Props to @marybaum for review.

#6-3-2, #6-4-2, #contributor-day, #dev-chat, #summary, #wceu