Skip to content

Make bson-enum_error resilient to PHP 8.6 interface handler order#1953

Merged
GromNaN merged 1 commit intomongodb:v2.xfrom
GromNaN:fix/bson-enum-error-003-php86-resilience
Mar 13, 2026
Merged

Make bson-enum_error resilient to PHP 8.6 interface handler order#1953
GromNaN merged 1 commit intomongodb:v2.xfrom
GromNaN:fix/bson-enum-error-003-php86-resilience

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Mar 13, 2026

PHP is calling the interface_gets_implemented handlers in a different order since php/php-src#18622

Build failure detected in #1952 (comment)

The Persistable interface extends Unserializable which is the one that cannot be implemented.

@GromNaN GromNaN requested review from alcaeus and paulinevos March 13, 2026 15:02
@GromNaN GromNaN requested a review from a team as a code owner March 13, 2026 15:03
Copilot AI review requested due to automatic review settings March 13, 2026 15:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates a BSON enum error PHPT to be resilient to PHP 8.6’s changed interface_gets_implemented handler order, which can alter which interface name appears in the fatal error message.

Changes:

  • Switches the test expectation from --EXPECTF-- to --EXPECTREGEX--.
  • Allows either MongoDB\BSON\Persistable or MongoDB\BSON\Unserializable to appear in the fatal error output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread tests/bson/bson-enum_error-003.phpt
PHP is calling the interface_gets_implemented handlers in a different order
@GromNaN GromNaN force-pushed the fix/bson-enum-error-003-php86-resilience branch from 5130bc0 to bacbd5b Compare March 13, 2026 15:18
@GromNaN GromNaN changed the title Make bson-enum_error-003 resilient to PHP 8.6 interface handler order Make bson-enum_error resilient to PHP 8.6 interface handler order Mar 13, 2026
@alcaeus
Copy link
Copy Markdown
Member

alcaeus commented Mar 13, 2026

The Persistable interface extends Unserializable which is the one that cannot be implemented.

Small correction: Persistable also cannot be implemented directly, independent from Unserializable:

static int php_phongo_implement_persistable(zend_class_entry* interface, zend_class_entry* class_type)
{
if (class_type->ce_flags & ZEND_ACC_ENUM) {
zend_error_noreturn(E_ERROR, "Enum class %s cannot implement interface %s", ZSTR_VAL(class_type->name), ZSTR_VAL(interface->name));
return FAILURE;
}
return SUCCESS;
}

@GromNaN
Copy link
Copy Markdown
Member Author

GromNaN commented Mar 13, 2026

Since the check is done in both interfaces, and that's Unserializable that is mentioned in the exception message anyway, we can remove php_phongo_implement_persistable.

Or we can try to improve the exception message in php_phongo_implement_unserializable if the enum also implements Persistable. That would keep the existing exception message, which is better.

@GromNaN GromNaN merged commit 15e343c into mongodb:v2.x Mar 13, 2026
43 checks passed
@GromNaN GromNaN deleted the fix/bson-enum-error-003-php86-resilience branch March 13, 2026 16:09
GromNaN added a commit to GromNaN/mongo-php-driver that referenced this pull request Apr 8, 2026
…ngodb#1953)

PHP is calling the interface_gets_implemented handlers in a different order
GromNaN added a commit that referenced this pull request Apr 8, 2026
) (#1977)

Backport of 15e343c to v2.2.

PHP is calling the interface_gets_implemented handlers in a different order
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