Skip to content

Avoid use of glob() when loading PHP files #10052

@danielbachhuber

Description

@danielbachhuber

Use of glob() isn't reliable across distros, and also has some negative performance implications.

Instead of:

foreach ( glob( dirname( __FILE__ ) . '/../block-library/*/index.php' )

We should require_once each file individually, e.g.:

require_once dirname( dirname( __FILE__ ) ) . '/packages/block-library/src/archives/index.php';

It looks like there aren't that many files in the first place:

$ ls packages/block-library/src/*/index.php | wc -l
6

From #9946 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueAn issue that's suitable for someone looking to contribute for the first time[Type] PerformanceRelated to performance efforts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions