Skip to content

Fix/removed files persist take 2#12206

Open
desrosj wants to merge 3 commits into
WordPress:trunkfrom
desrosj:fix/removed-files-persist-take-2
Open

Fix/removed files persist take 2#12206
desrosj wants to merge 3 commits into
WordPress:trunkfrom
desrosj:fix/removed-files-persist-take-2

Conversation

@desrosj

@desrosj desrosj commented Jun 17, 2026

Copy link
Copy Markdown
Member

When a file was removed from the Gutenberg repository upstream, it currently persists in src/wp-includes/ indefinitely unless someone knows to manually delete it. While the build process copies new files in, it never performs a proper clean.

This PR makes a few changes to address this and fix some loosely related pre-existing bugs along the way

First, all Gutenberg-sourced files are now built into src. Because files were previously built into the WORKING_DIRECTORY, when someone ran a combination of build:dev and build after pulling recent changes that modified file names or added/removed files, this sometimes resulted in built files being out of sync, or stale version controlled files in src despite them appearing "correct" in build.

Second, the clean:gutenberg is now the first task run as part of build:gutenberg. It has also been updated to clean all versioned and unversioned files managed by the Gutenberg-related build scripts. However, only versioned files will only be cleaned if clean:gutenberg is called directly. If grunt clean is called, then only unversioned files are cleaned. This is to avoid a dirty state after running grunt clean where versioned files have been deleted and not regenerated.

Lastly, the jsFiles has been adjusted so that gutenbergVersionedFiles, gutenbergUnversionedFiles and webpackFiles become reponsible for the files generated in the respective tasks.

Trac ticket: Core-65418.

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.7 & 4.8
Used for: Analyzing and documenting the various tasks and scripts and the outcomes of different build paths before creating a first draft of this PR that was adjusted and reviewed by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@desrosj desrosj self-assigned this Jun 17, 2026
@github-actions

Copy link
Copy Markdown

Hi there! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

This adjusts the build script to ensure that any files deleted from the upstream built asset are removed as expected.

This also solves a long-standing issue where unversioned files persist in `src` after being eliminated, which can cause `grunt verify:old-files` to fail.
@desrosj desrosj force-pushed the fix/removed-files-persist-take-2 branch from ea9fbd2 to f4a738b Compare June 17, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Gutenberg integration build pipeline so Gutenberg-sourced artifacts are generated into src/ and proactively cleaned, preventing stale/removed upstream files from lingering in src/wp-includes/ across different build flows.

Changes:

  • Always copy Gutenberg build outputs into src/ (not WORKING_DIR) to avoid build vs build:dev drift and stale files.
  • Run clean:gutenberg first in build:gutenberg, expanding it to clean both tracked and ignored Gutenberg-managed files (with safeguards when running plain grunt clean).
  • Refactor Gutenberg block copying in tools/gutenberg/copy.js into explicit steps (JSON, PHP, CSS) and update related task grouping in Gruntfile.js.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tools/gutenberg/copy.js Standardizes Gutenberg copy destination to src/ and splits block copying into JSON/PHP/CSS steps.
Gruntfile.js Reworks Gutenberg-related clean/copy task wiring to clean first and consistently build into src/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/gutenberg/copy.js Outdated
Comment thread Gruntfile.js
Comment thread tools/gutenberg/copy.js
* Handles both the top-level `<block>.php` dynamic block files and any nested
* `*.php` helpers under `<block>/` (e.g. `navigation-link/shared/render-submenu-icon.php`).
*
* @param {Object} config - Block configuration from `COPY_CONFIG.blocks`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can a @typedef be added for the shape of this to be reused here and in copyBlockStyles()?

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props desrosj, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment thread Gruntfile.js
Comment on lines +281 to +286
const isExplicitGutenbergClean =
grunt.cli.tasks.length === 1 &&
grunt.cli.tasks[ 0 ] !== 'clean';
return isExplicitGutenbergClean ?
gutenbergUnversionedFiles.concat( gutenbergVersionedFiles ) :
gutenbergUnversionedFiles;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const isExplicitGutenbergClean =
grunt.cli.tasks.length === 1 &&
grunt.cli.tasks[ 0 ] !== 'clean';
return isExplicitGutenbergClean ?
gutenbergUnversionedFiles.concat( gutenbergVersionedFiles ) :
gutenbergUnversionedFiles;
if( grunt.cli.tasks.length === 1 && grunt.cli.tasks[ 0 ] !== 'clean' ) {
return gutenbergUnversionedFiles.concat( gutenbergVersionedFiles );
} else {
return gutenbergUnversionedFiles;
}

Nit: The back to back multiple lines single line functions is a bit hard to grok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants