Rules tests stopped working on Drupal 10. See https://www.drupal.org/pift-ci-job/2322824

The error is:
PHP Fatal error: Declaration of Drupal\Tests\rules\Unit\TestSession::start() must be compatible with Symfony\Component\HttpFoundation\Session\SessionInterface::start(): bool in /var/www/html/modules/contrib/rules/tests/src/Unit/TestSession.php on line 146

I think this MAY be because of: Return type hints added to some class methods for Symfony 5.4/Symfony 6 compatibility, but SessionInterface is not mentioned in any change record.

Comments

TR created an issue. See original summary.

tr’s picture

Status: Active » Needs review
StatusFileSize
new2.46 KB

Status: Needs review » Needs work

The last submitted patch, 2: 3265360-2-SessionInterface.patch, failed testing. View results

tr’s picture

Assigned: Unassigned » tr

That fixed the initial problems, but exposed some new ones. I'll roll a new patch tomorrow.

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new6.11 KB

I believe this was broken by #3252757: Update Drupal 10 to depend on Symfony 6.0, but again no change notice from core for this huge API change.

Let's try this. I'm using some conditional code in the test to check the PHP version, because Drupal 10 now requires Symfony 6, and Symfony 6 uses features that are only available in PHP 8. Specifically, the 'mixed' return type hint. The conditional code is needed because using the hint is required for D10 but the hint can't be used in D9/PHP 7.

tr’s picture

StatusFileSize
new2.39 KB

Let me see if I can do this without the version_compare.

tr’s picture

StatusFileSize
new2.93 KB
tr’s picture

Assigned: tr » Unassigned

SessionInterface also uses a 'mixed' parameter type in some places, which will cause errors in PHP 7. While we can use #[ReturnTypeWillChange] to suppress the return type errors if we leave off the 'mixed' return type, there is no equivalent to suppress the errors from leaving off the parameter type, and no way to use the 'mixed' parameter type in PHP 7. We can't even get around that with the conditional code in #5.

Not sure what to try next, other than a new D10-specific branch ...

If someone else has some ideas, please offer a patch!

tr’s picture

tr’s picture

StatusFileSize
new5.35 KB
tr’s picture

StatusFileSize
new6.1 KB

Well, it's quite ugly, but it works. Now let me try to eliminate the coding standards messages.

tr’s picture

StatusFileSize
new6.1 KB

Just a few more.

tr’s picture

StatusFileSize
new6.11 KB

And it has to work for all test configurations ...

  • TR committed dffc7d7 on 8.x-3.x
    Issue #3265360 by TR: [D10] Test failure
    
tr’s picture

Status: Needs review » Fixed

Committed #13.

Status: Fixed » Closed (fixed)

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