Skip to content

polyfill-php84 can "break" software in prod-environment #332

@renky

Description

@renky

This is not a really a bug and not a feature-request, but it is an issue, and I'd like to clarify

Today I had a production rollout of our software, running on PHP8.3 (Laravel and Livewire, but this isn't important here). In our local environment, all Tests have passed, the software works fine. In our CICD-Pipeline all tests have passed, finally it was rolled out and 5 minutes later, we had the first bug-report, 500 Server Error...

It was a error "Call to undefined function array_find()" and for sure - I immediately realized that there was used a PHP8.4 function by a dev, and yes, that is a human error and you can expect devs to know such things... on the other hand - in other projects we use 8.4 and it is totally fine that we can use array_find here... in the end even the IDE-Setting Language-Level 8.3 didn't help because the package symfony/polyfill-php84 was installed because of testbench, and it detected the existance of the function...

So my question is now: how to avoid that?! From my point of view I'd say: a tool that is meant for testing applications, should never use a polyfill - but maybe I'm alone with that opinion. I now see two solutions for us:

  1. change the pipeline - not use composer install to install the phpunit/pestphp packages, because it installs to much additional packages - like testbench. Try to switch to require the unit-testingpackages directly - as long as none of that uses a polyfill, it should work
  2. adding a arch-test to the pest-tests that checks for usage of php8.4 functions and denies it... I guess this is a overkill but especially for the array_find function it might be a good option....

Nevertheless - i wonder how many unseen bugs are out there because of that?! Testbench includes polyfills for 8.3 and 8.4 - so if anybody runs 8.2 he has even more chance to run into that... Did nobody ever have an issue like that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions