Magento2: Use of undefined constant GLOB_BRACE in dependency "allure-framework/allure-phpunit"

Created on 18 Sep 2019  路  21Comments  路  Source: magento/magento2

Preconditions (*)

Magento Version: 2.3.2

Steps to reproduce (*)

./bin/magento dev:test:run unit

Expected result (*)

No PHP Warnings

Actual result (*)

several:

Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /var/www/html/src/vendor/allure-framework/allure-phpunit/src/Yandex/Allure/Adapter/AllureAdapter.php:74.

Related Informations

Problem is, GLOB_BRACE is not available in alle Unix Systems.
For example the often in Docker context used "Alpine"
https://github.com/docker-library/php/issues/719

There is an (not merged) upstream PullRequest available in https://github.com/allure-framework/allure-phpunit/pull/44
But I did not check yet, if this is the proper solution.

ready for confirmation P3 S3

Most helpful comment

@engcom-Delta did you run it in the official php docker container based on alpine?

All 21 comments

Hi @Flyingmana. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@Flyingmana do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hello @Flyingmana !
Could you show me where(
outside the vendor) Magento uses GLOB_BRACE constant?

I am closing this issue now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

For future reference here is a solution:
vendor/allure-framework/allure-phpunit/src/Yandex/Allure/Adapter/AllureAdapter.php@74

//            $files = glob($outputDirectory . DIRECTORY_SEPARATOR . '{,.}*', GLOB_BRACE);
//            foreach ($files as $file) {
//                if (is_file($file)) {
//                    unlink($file);
//                }
//            }

Comment out this code, or replace it with:

$directoryPath = $outputDirectory . DIRECTORY_SEPARATOR;
$dir = scandir($directoryPath);
$rel = ['.', '..'];
$files = array_diff($dir, $rel);

foreach ($files as $file) {
    $path = $directoryPath . $file;
    if (is_file($path)) {
        unlink($path);
    }
}

The solution to the problem is the pull request https://github.com/allure-framework/allure-phpunit/pull/44 which the author may accept

@Flyingmana since this problem is related to Allure, we can just wait when PR https://github.com/allure-framework/allure-phpunit/pull/44#issue-312713152 will be confirmed.
We hope the fix will be merged in the next Magento release(2.3.4).

@engcom-Charlie thats not completely right.
As a good OpenSource User, you can also test the solution, communicate them that it works, and encourage them to merge it, because it is a part, which affects your own Users.

Usually its a good and helpfull thing for maintainers, to hear this also from the bigger users of an open source library/tool.

Upstream have released version 1.3.1, which includes this fix: https://github.com/allure-framework/allure-phpunit/pull/44#issuecomment-563175882
It looks like there's a dependency chain preventing this upgrade however:

  • allure-framework/allure-phpunit 1.3.1 requires phpunit/phpunit >=7.0.0
  • codeception/phpunit-wrapper 6.7.0 requires phpunit/phpunit >=6.5.13 <7.0
  • codeception/codeception 2.4.5 requires codeception/phpunit-wrapper ^6.0.9|^7.0.6
  • allure-framework/allure-codeception 1.3.0 requires codeception/codeception ~2.1
  • magento/magento2-functional-testing-framework 2.5.4 requires allure-framework/allure-codeception ~1.3.0
  • No suitable versions of magento/magento2-functional-testing-framework currently available.

(Reopening as this clearly isn't solved yet.)

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

@Flyingmana I searched for GLOB_BRACE in the Magento 2.3.4 code and it is used many times, even at quite important places:
\Magento\Framework\App\Utility\Files::getDiConfigs

            Glob::glob($moduleDir . '/etc/{di,*/di}.xml', Glob::GLOB_BRACE)

I think that means Magento might not run properly at all on Alpine based PHP images?

So is the problem maybe bigger than expected?

At least Alpine is not officially liste in the rough list of supported distributions.

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hi @fredden I'm not able to reproduce initial issue on clean 2.4-develop.
Result:
bin/magento dev:test:run unit runs without errors
image

Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.4-develop branch. Thank you for collaboration.

@engcom-Delta did you run it in the official php docker container based on alpine?

No, this is not yet resolved.
https://github.com/magento/magento2/blob/a1e5689cc6092e40e1ebb975f4eaae32c4d8d1e5/composer.lock#L5983-L5984

I don't seem to have a 'reopen' button; @engcom-Delta please can you re-open this issue.

@engcom-Delta please re-open this.

@fredden @amenk Could you provide additional steps to reproduce this issue? Is it reproducible on alpine with php7.4 without any additional configuration? What magento version do you use?

This issue is still affecting Magento 2, both 2.4.1 and 2.4-develop.

In order to reproduce you have to:

  1. Create a new magento installation
  2. Run bin/magento setup:install
  3. Configure integration tests in dev/tests/integration
  4. Run bin/magento dev:tests:run

At the end of the tests you will see:

Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /home/user/Projects/projetname/vendor/allure-framework/allure-phpunit/src/Yandex/Allure/Adapter/AllureAdapter.php:74.

Testing with alpine php 7.4, I believe this issue was resolved in a later version of allure-framework/allure-phpunit as I could not find references to GLOB_BRACE in the latest version of that repository.

To reproduce using Docker:

git clone --depth=1 https://github.com/magento/magento2.git
docker run --rm -it -v "$PWD"/magento2:/var/www/html php:7.4-fpm-alpine sh
# Then inside the container:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php composer.phar install --ignore-platform-reqs
php -d memory_limit=-1 vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist

This shows the error:

Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /var/www/html/vendor/allure-framework/allure-phpunit/src/Yandex/Allure/Adapter/AllureAdapter.php:74.

To fix, allure-framework/allure-phpunit should be upgraded to at least 1.3.1. This is an eventual dependency of magento/magento2-functional-testing-framework. See https://github.com/magento/magento2/issues/24635#issuecomment-566314746.

It's worth noting this isn't the only use of GLOB_BRACE within the codebase/dependency tree, but this is the instance that's the topic of this issue.

Was this page helpful?
0 / 5 - 0 ratings