Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Kernel initialization on random requests, using GLOB function #33990

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

Closed
hurricane-voronin opened this issue Oct 15, 2019 · 5 comments
Closed

Comments

@hurricane-voronin
Copy link
Contributor

Symfony version(s) affected: 4 (dev envs)

Description
I'm not sure if it's a bug in symfony, but I've got the next behavior with
\Symfony\Component\Config\Resource\GlobResource::getIterator witch loads files using glob not it the stable sorting, e.g several files: doctrine.yml and doctrine_mongodb.yaml in config/packages folder.
On requests these files come(randomly) in a different order, which leads to reinitialization of symfony kernel in dev environment. It's a little bit annoying and takes a lot of time in a common :(

How to reproduce

  1. Create several files like doctrine.yaml and doctrine_mongodb.yaml
  2. Observe that files could be randomly fetched from directory
<?php // index.php

$files = glob('directory', GLOB_BRACE);
echo reset($files);

Possible Solution
I guess it's possible to add sorting. (Or probably use GLOB_NOSORT, as a native sorting is a little bit buggy).

@lyrixx
Copy link
Member

lyrixx commented Oct 15, 2019

What OS are you using?

@hurricane-voronin
Copy link
Contributor Author

Container of Debian GNU/Linux 9.9 (stretch)

@nicolas-grekas
Copy link
Member

Does GLOB_NOSORT help? If yes, let's add it, PR welcome once confirmed.

@stof
Copy link
Member

stof commented Oct 15, 2019

well, if we want to ensure reproduceable builds, we should enforce a reproduceable sorting of the files.

@nicolas-grekas
Copy link
Member

That's true - so we could disable sorting for debug builds only, IF that fixes the issue.

nicolas-grekas added a commit that referenced this issue Oct 30, 2019
… due of unstable sort (hurricane-voronin)

This PR was squashed before being merged into the 3.4 branch.

Discussion
----------

[Config] Disable default alphabet sorting in glob function due of unstable sort

…table sort

| Q             | A
| ------------- | ---
| Branch?       | 3.4  <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #33990  <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | no <!-- required for new features -->

`\Symfony\Component\Config\Resource\GlobResource::getIterator` loads files using `glob` not it the stable sorting, e.g several files: `doctrine.yml` and `doctrine_mongodb.yaml` in `config/packages` folder.
On requests these files come(randomly) in a different order, which leads to reinitialization of symfony kernel in `dev` environment. It's a little bit annoying and takes a lot of time in a common :(

<!--
Additionally (see https://symfony.com/roadmap):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

Commits
-------

3bed024 [Config] Disable default alphabet sorting in glob function due of unstable sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants