Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Loader: Use glob constant instead of numeric value. #18893

Merged
merged 2 commits into from
Dec 3, 2019

Conversation

epiqueras
Copy link
Contributor

Fixes #18876

Description

This PR changes the calls to glob in the template loader to use the constant GLOB_NOSORT instead of the literal 1 which seems to have been causing issues in certain environments.

How has this been tested?

It was verified that template loading still works as expected.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@aduth
Copy link
Member

aduth commented Dec 3, 2019

Can you explain what's meant to be accomplished with this flag?

And what was meant to be accomplished with the previous value? (since GLOB_NOSORT evaluates to 32, a different behavior from what existed previously)

@epiqueras epiqueras force-pushed the fix/template-loader-glob-flags branch from 913fd52 to f2052cf Compare December 3, 2019 21:35
@epiqueras
Copy link
Contributor Author

I thought the constants were 0 indexed and intended to use GLOB_NOSORT to be more efficient since we don't need to sort the results here.

@aduth
Copy link
Member

aduth commented Dec 3, 2019

intended to use GLOB_NOSORT to be more efficient since we don't need to sort the results here.

Does it make a measurable difference?

If I find myself questioning why it exists today, I think it would be a fair assumption that it might catch the attention of future maintainers as well, as to why it needs to exist.

At the very least, if we keep it, can we add an inline comment explaining its purpose for the benefit of those who work with this code in the future?

@epiqueras
Copy link
Contributor Author

I don't think the minimal performance difference warrants the potential for confusion so I've removed them.

Copy link
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

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

+1 for removal. The performance benefit here will be negligible.

@epiqueras epiqueras merged commit 0480528 into master Dec 3, 2019
@epiqueras epiqueras deleted the fix/template-loader-glob-flags branch December 3, 2019 23:36
@youknowriad youknowriad modified the milestones: Future, Gutenberg 7.1 Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Templates API Related to API powering block template functionality in the Site Editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Templates: PHP warning: glob(): At least one of the passed flags is invalid or not supported on this platform
4 participants