Make WordPress Core

Opened 14 months ago

Closed 14 months ago

Last modified 14 months ago

#57795 closed defect (bug) (fixed)

[@wordpress packages] Make the safeguard for using private APIs opt-in rather than opt-out

Reported by: zieladam's profile zieladam Owned by: zieladam's profile zieladam
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch gutenberg-merge commit
Focuses: Cc:

Description (last modified by zieladam)

Summary: The current system of sharing private APIs in Gutenberg (WordPress/gutenberg#46131) includes a series of safeguards: Only core JavaScript modules can participate in the private APIs system and each of them can only be registered once.

The latter safeguard is enabled by default in WordPress 6.2. However, in the most recent editor version it is disabled by default (WordPress/gutenberg#48352) and needs to be explicitly enabled by setting the IS_WORDPRESS_CORE to true.

Change History (14)

This ticket was mentioned in PR #4121 on WordPress/wordpress-develop by @zieladam.


14 months ago
#1

  • Keywords has-patch added

## Description

Gutenberg introduced a system of sharing private APIs in
https://github.com/WordPress/gutenberg/pull/46131. One of the
safeguards is a check preventing the same module from opting-in
twice so that contributors cannot easily gain access by pretending
to be a core module.

That safeguard is only meant for WordPress core and not for
the released @wordpress packages. However, right now it is
opt-out and must be explicitly disabled by developers wanting to
install the @wordpress packages. Let's make it opt-out instead.

This commit opts-out from that check in WordPress core by setting
the ALLOW_EXPERIMENT_REREGISTRATION to false. Once it's merged,
the Gutenberg plugin should be adjusted to use true as the
default value.

## Test plan:

Run npm run build with this PR applied. The resulting build/wp-includes/js/dist/js/private-apis.js file should say _process$env$ALLOW_EX = false.

Trac ticket: https://core.trac.wordpress.org/ticket/57795

@zieladam commented on PR #4121:


14 months ago
#2

cc @gziolo @ntsekouras @hellofromtonya

#3 @zieladam
14 months ago

  • Keywords has-patch removed
  • Summary changed from [@wordpress packages] Make the safeguard for using private APIs opt-out rather than opt-in to [@wordpress packages] Make the safeguard for using private APIs opt-in rather than opt-out

#4 @hellofromTonya
14 months ago

  • Component changed from General to Build/Test Tools
  • Keywords has-patch gutenberg-merge added
  • Priority changed from high to normal

The change is for webpack as part of the build tooling. Though not technically a gutenberg-merge, it is part of Gutenberg PR 46131 scope. So tracking synchronization of changes from Gutenberg into Core, adding the gutenberg-merge keyword.

@zieladam commented on PR #4121:


14 months ago
#5

@hellofromtonya @peterwilsoncc let me know if you think this is suitable for merging, and if yes then I could make it my first commit.

#6 @hellofromTonya
14 months ago

  • Keywords commit added
  • Owner set to zieladam
  • Status changed from new to reviewing

Marking for commit. Assigning to @zieladam for commit.

@hellofromTonya commented on PR #4121:


14 months ago
#7

@adamziel I marked the ticket for commit and assigned the commit to you. Go ahead with your first commit 🎉

This ticket was mentioned in Slack in #core by costdev. View the logs.


14 months ago

This ticket was mentioned in Slack in #core by costdev. View the logs.


14 months ago

#10 @costdev
14 months ago

  • Milestone changed from 6.2 to 6.3

As we're about to enter 6.2 RC, moving this ticket 6.3.

#11 @zieladam
14 months ago

  • Description modified (diff)

#12 @zieladam
14 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55512:

Build/Test tools: Prevent registering the same private JavaScript API twice.

This sets the IS_WORDPRESS_CORE global variable to true in the webpack build script to enable extra safeguards around private JavaScript APIs.

Props costdev, hellofromTonya, gziolo, peterwilsoncc.
Fixes #57795.

#13 @zieladam
14 months ago

I just committed this to trunk – props to @gziolo for helping me during my first commit! This doesn't require a backport to WordPress 6.2 as it doesn't have any effects yet. It will only affect the build after the next editor merge.

@zieladam commented on PR #4121:


14 months ago
#14

Committed in https://core.trac.wordpress.org/changeset/55512/trunk – thank you everyone! 🎉

Note: See TracTickets for help on using tickets.