-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Fix serialization of ComparisionFailure with PDO in stacktrace. #47
base: main
Are you sure you want to change the base?
Conversation
This fix implements a custom serialize/deserialize method on the ComparisionFailure class, which means it loses the stack trace during serialization. This allows PHPUnit to run in process isolation mode when the stack trace may contain references to non-serializable objects such as the PDO.
5266136
to
3fdfacd
Compare
Codecov Report
@@ Coverage Diff @@
## master #47 +/- ##
============================================
+ Coverage 99.07% 99.09% +0.02%
- Complexity 123 125 +2
============================================
Files 15 15
Lines 325 333 +8
============================================
+ Hits 322 330 +8
Misses 3 3
Continue to review full report at Codecov.
|
@sebastianbergmann I've re based on the current master branch. Is there any chance of getting this merged? Also I think the codecov-io report is for the previous version against the current master; rather than the current version of this PR |
@DomBlack The problem still exists so I wrote the patch: mpyw/phpunit-patch-serializable-comparison |
@sebastianbergmann @DomBlack We've been running into this issue in the Drupal community as well. I see this PR does need an update to use the __serialize and __unserialize magic methods introduced in php 7.4, rather than implementing the Serializable interface. If we can get an updated PR, I'd like to know the chances of being able to get it merged, as we could definitely use it downstream. Related Drupal Core issue: https://www.drupal.org/project/drupal/issues/3197324 |
The only thing I can promise that I would review such a pull request. |
I am running into similar issue as well with having object as args on the stack trace that cannot be serialized when running in isolation. Which is related to issue: sebastianbergmann/phpunit/issues/1351 and pull: sebastianbergmann/phpunit/issues/1352 In that PR, instead of trying to override serialization methods, the constructor just unset the Relevant code from Framework/Exception.php in that PR: public function __construct($message = '', $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
$this->serializableTrace = $this->getTrace();
foreach ($this->serializableTrace as $i => $call) {
unset($this->serializableTrace[$i]['args']);
}
} maybe a similar approach could be utilized in ComparisonFailure? -- edit/update to my own message... |
Added a (very naive) first stab at updating the old PR in #106. |
edit permissions
This fix implements a custom serialize/deserialize method on the
ComparisionFailure class, which means it loses the stack trace
during serialization.
This allows PHPUnit to run in process isolation mode when the stack
trace may contain references to non-serializable objects such as
the PDO.