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

glob() fails due GLOB_BRACE const usage, which is not available under alpine linux due non-standard libc (musl) usage #76

Closed
diimpp opened this issue Jun 20, 2023 · 4 comments
Labels
bug Something isn't working correctly

Comments

@diimpp
Copy link

diimpp commented Jun 20, 2023

Which version(s) is affected: 8.0.0.

Description

Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38
Fatal error: Uncaught TypeError: glob() expects parameter 2 to be int, string given in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php:38

Full log

Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38

Fatal error: Uncaught TypeError: glob() expects parameter 2 to be int, string given in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php:38
Stack trace:
#0 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php(38): glob('./*{.yml,.yaml,...', 'GLOB_BRACE')
#1 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php(20): YamlStandards\Command\Service\FilesPathService::globRecursive('./*{.yml,.yaml,...')
#2 /srv/sylius/vendor/sspooky13/yaml-standards/src/Model/Config/YamlStandardConfigLoader.php(43): YamlStandards\Command\Service\FilesPathService::getPathToFiles(Array)
#3 /srv/sylius/vendor/sspooky13/yaml-standards/src/Model/Config/YamlStandardConfigLoader.php(31): YamlStandards\Model\Config\YamlStandardConfigLoader->createConfigData(Array)
#4 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/YamlCommand.php(51): YamlStandards\Model\Config\YamlStandardConfigLoader->loadFromYaml('./yaml-standard...')
#5 /srv/sylius/vendor/symfo in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38

How to reproduce
call yaml-standard bin from docker with alpine linux

Possible Solution

Handle possiblity of GLOB_BRACE missing.

https://www.php.net/manual/en/function.glob.php

image

Additional information
zendframework/zend-stdlib#58
zend-stdlib has fallback glob for this exact issue https://github.com/zendframework/zend-stdlib/blob/6d965efcce81ee60e2b425792f1cd3f27aed82d9/src/Glob.php#L39-L46

@sspooky13 sspooky13 added the bug Something isn't working correctly label Jun 20, 2023
@sspooky13
Copy link
Owner

Hello, thanks for report. I will work on it.

@sspooky13
Copy link
Owner

@diimpp, I fixed this issue like Symfony and some more repositories -> 48d206f. Is it OK for you or do you really want to use GLOB_BRACE constant?

Thanks

@diimpp
Copy link
Author

diimpp commented Jun 20, 2023

Just patched my local version with it and seems to work correctly.

  • vendor/bin/yaml-standards is being called without errors now
  • Number of found files matches number of files in directory with find path/to/dir -mindepth 1 -type f -name "*.yml" -printf x | wc -c for yml/yaml file extensions.

Thank you for super fast fix :)

EDIT: P.S. Yes, it's okay for me and I've no use for GLOB_BRACE const directly.

@sspooky13
Copy link
Owner

You are welcome 😊 I released new version where is this issue fixed, so you can change version in composer.json to don't have to change your localhost version

Thank you for your report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

2 participants