Problem/Motivation

Not sure what component to put this in.

Using array any cause php 8.3 tests to fail since the polyfill did not load.

https://www.drupal.org/project/drupal/issues/3551308#comment-16383389

Steps to reproduce

Switch back to array any and run unit tests on php 8.3

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3563359

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nicxvan created an issue. See original summary.

mondrake made their first commit to this issue’s fork.

mondrake’s picture

Yep, the PHP 8.4 polyfill is not loaded by composer. Weirdly, the PHP 8.5 one is.

https://git.drupalcode.org/issue/drupal-3563359/-/jobs/7679099

mstrelan’s picture

Is there a package with symfony/polyfill-php84 in the replace section, perhaps?

mondrake’s picture

Title: Explore why php 8.3 polyfill for array_any fails » Explore why PHP 8.4 polyfill is not loaded for test runs on PHP 8.3

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

nicxvan’s picture

Can this be closed as outdated?

mstrelan’s picture

Short answer to #8 is no. I will push an MR shortly. More info below.

I set the robots to work on this to answer the question and was able to replicate and pinpoint the issue.

\Drupal\Tests\package_manager\Build\TemplateProjectTestBase::createTestProject disables packagist and points at a locally generated repo. That repo is generated in ::createVendorRepository which explicitly unsets symfony/polyfill-php84 from the requirements. This also explains why symfony/polyfill-php85 is still available. There is also a comment before the unset:

// These polyfills are dependencies of some packages, but for reasons we
// don't understand, they are not installed in code bases built on PHP
// versions that are newer than the ones being polyfilled, which means we
// won't be able to build our test project because these polyfills aren't
// available in the local code base. Since we're guaranteed to be on PHP
// 8.3 or later, no package should need to polyfill older versions.

There is a simple explanation to this. They are not installed on newer versions because they appear in replace section of drupal/drupal.

I think we should restore the array_any call, remove the line that unsets polyfill-php84, fix the comment that says we don't know what this does and then potentially look at dynamically populating that list to be unset, from the replace section of drupal/drupal.

mstrelan changed the visibility of the branch 3563359-explore-why-php to hidden.

mstrelan’s picture

Title: Explore why PHP 8.4 polyfill is not loaded for test runs on PHP 8.3 » Explore why PHP 8.4 polyfill is not loaded for test runs on PHP 8.3
Status: Active » Needs review

FWIW #9 is mostly about 11.x, but it makes sense to resolve the @todo comment in main, and to provide a better explanation. I've created 2 MRs, one for main, one for 11.x.

We need a better issue title so it makes sense for main, but I couldn't think of how to word it.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Think the title is fine?

This list should be kept in sync with the replace section of composer.json.

Should we have a test around this? Would be out of scope here but asking.

smustgrave’s picture

I'm being awful about using that tag sorry for the noise

  • catch committed aec96fd0 on 11.x
    task: #3563359 Explore why PHP 8.4 polyfill is not loaded for test runs...

  • catch committed 8e8418bc on 12.0.x
    task: #3563359 Explore why PHP 8.4 polyfill is not loaded for test runs...

  • catch committed 26873db1 on main
    task: #3563359 Explore why PHP 8.4 polyfill is not loaded for test runs...
catch’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

I'm not sure how easy it would be to write a test that doesn't need to be kept up to date when we change minimum PHP versions / new polyfills are added (which would have the same problem), we could open a follow-up issue if someone has an idea how to do it.

Committed/pushed the respective MRs to main, 12.0.x and 11.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed e495b7f5 on 11.5.x authored by catch
    task: #3563359 Explore why PHP 8.4 polyfill is not loaded for test runs...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.