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

PHPLIB-1502: Test with PHP 8.4 #1484

Merged
merged 5 commits into from
Oct 16, 2024
Merged

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Oct 15, 2024

PHPLIB-1502

This adds testing with PHP 8.4 on evergreen. Due to an implicit nullable parameter in PHPUnit, I had to skip a single test. This test can be re-enabled when we merge this up to v1.x.

@alcaeus alcaeus requested a review from GromNaN October 15, 2024 13:01
@alcaeus alcaeus requested a review from a team as a code owner October 15, 2024 13:01
@@ -325,9 +325,9 @@ functions:
working_dir: "src"
script: |
${PREPARE_SHELL}
file="${PROJECT_DIRECTORY}/.evergreen/install-composer.sh"
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
[ -f "$file" ] && DEPENDENCIES=${DEPENDENCIES} bash $file || echo "$file not available, skipping"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was responsible for Evergreen not exiting with a setup failure when something went wrong. With this change, any error while installing dependencies will cause a setup failure.

$latestPhpVersion = max($supportedPhpVersions);
// TODO: use max() once PHP 8.4 is stable
//$latestPhpVersion = max($supportedPhpVersions);
$latestPhpVersion = '8.3';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since PHP 8.4 isn't stable yet, I figured that the extra tests that run on the latest PHP version should continue to run on 8.3

@@ -38,4 +38,9 @@ php --ri mongodb

install_composer

# Remove psalm as it's not compatible with PHP 8.4: https:/vimeo/psalm/pull/10928
if [ "$PHP_VERSION" == "8.4" ]; then
php composer.phar remove --no-update --dev vimeo/psalm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only run PHPUnit, I decided to explicitly remove the psalm dependency instead of ignoring any upper bounds for PHP version constraints, as that may result in actually incompatible packages being pulled in.

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how the GridFS tests relates to an "implicit nullable parameter", so I'll defer to you if I'm mistaken in thinking that disableMD5 was to blame.

@@ -860,6 +860,9 @@ public function testDanglingOpenWritableStream(): void
$code = <<<'PHP'
require '%s';
require '%s';
// Don't report deprecations - if the issue exists this code will
// result in a fatal error
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this due to disableMD5 being used below? Is that even relevant to what's being tested here? Why not remove it and allow deprecation notices to fail the test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation in question is about implicit nullable args in a PHPUnit class, which is loaded when we call createTestClient as it's in the inheritance chain. The issue is that checking for no output is the only way to test this behaviour. It goes back to #779 which fixed PHPLIB-345 - without the fix PHP fails with an autoloading failure as it already started unloading things when open resources (including streams with custom stream wrappers) are closed, leading to an autoload failure that doesn't find a class.

@alcaeus alcaeus enabled auto-merge (squash) October 16, 2024 06:46
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

My comment is irrelevant since the skip code will be removed in the next minor 1.x release with the PHPUnit upgrade.

Comment on lines +74 to +77
if (version_compare(phpversion(), '8.4', '>=')) {
$this->markTestIncomplete('Test fails on PHP 8.4 due to deprecations');
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I prefer using the PHP_VERSION_ID for performance reason.

Suggested change
if (version_compare(phpversion(), '8.4', '>=')) {
$this->markTestIncomplete('Test fails on PHP 8.4 due to deprecations');
}
if (PHP_VERSION_ID >= 8_04_00) {
$this->markTestIncomplete('Test fails on PHP 8.4 due to deprecations');
}

But the best is to use the #[RequiresPhp('>= 8.4')] attribute.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point. There's also #[RequiresPhpExtension] that we can use in another tests that depends on the extension version. I wonder if we can also leverage this mechanism for server version checks - I'll look into it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be tricky for server version checks as it'd need to use a persistent client connection. But there may be an opportunity there to streamline everything with a service that captures all of that information when PHPUnit is first loaded (fetching the URI from environment variables).

@alcaeus alcaeus merged commit e1cef70 into mongodb:v1.20 Oct 16, 2024
36 checks passed
@alcaeus alcaeus deleted the phplib-1502-test-php-8.4 branch October 16, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants