Make WordPress Core

#56738 closed defect (bug) (fixed)

Use require_once instead of require to load block files

Reported by: aristath's profile aristath Owned by: desrosj's profile desrosj
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch commit
Focuses: Cc:

Description

In sync-stable-blocks.js we're compiling the contents of the require-dynamic-blocks.php file.
When doing that, we currently use require instead of require_once to load the block files.

We should change that in our sync script, in the context of loading files like that require_once makes more sense.

Change History (4)

This ticket was mentioned in PR #3409 on WordPress/wordpress-develop by aristath.


17 months ago
#1

  • Keywords has-patch added

In sync-stable-blocks.js we're compiling the contents of the require-dynamic-blocks.php file.
When doing that, we currently use require instead of require_once to load the block files.

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

#2 @SergeyBiryukov
17 months ago

  • Component changed from General to Build/Test Tools
  • Milestone changed from Awaiting Review to 6.1

Thanks for the ticket!

Should this be addresssed in 6.1? Introduced a few months ago in [53688] / #56179.

#3 @desrosj
17 months ago

  • Keywords commit added
  • Owner set to desrosj
  • Status changed from new to assigned

I think since [53688] is also a change in 6.1 that my preference is to correct this issue prior to release, especially since the resulting file introduced from this tooling update has not yet been included in a release.

The change makes sense to me and looks good.

#4 @desrosj
17 months ago

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

In 54406:

Build/Test Tools: Use require_once instead of require.

The sync-stable-blocks.js file is used to compile the contents of require-dynamic-blocks.php, which includes the PHP files required for dynamic Core blocks.

Since these files define PHP functions, require_once should be used instead of require to guard against fatal errors.

Follow up to [53688].

Props aristath, SergeyBiryukov, desrosj.
Fixes #56738. See #56179.

Note: See TracTickets for help on using tickets.