Skip to content

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

Closed

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)

Activity

  1. added
    Good First IssueAn issue that's suitable for someone looking to contribute for the first time
    on Sep 20, 2018
  2. pento commented on Sep 20, 2018

    @pento
    Member

    Yah, this was just a developer convenience thing.

    It'll need to be changed for merge at the absolute latest, but I think it's safe to change anytime, really. We're not going to be making massive changes to the block library between now and then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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