8000 bug #25685 Use triggering file to determine weak vendors if when the … · symfony/symfony@228453b · GitHub
[go: up one dir, main page]

Skip to content

Commit 228453b

Browse files
bug #25685 Use triggering file to determine weak vendors if when the test is run in a separate process (alexpott)
This PR was squashed before being merged into the 3.4 branch (closes #25685). Discussion ---------- Use triggering file to determine weak vendors if when the test is run in a separate process | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | I think so | Fixed tickets | #25684 | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. - Replace this comment by a description of what your PR is solving. --> Commits ------- 3830577 Use triggering file to determine weak vendors if when the test is run in a separate process
2 parents dd28a32 + 3830577 commit 228453b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static function register($mode = 0)
107107

108108
$trace = debug_backtrace(true);
109109
$group = 'other';
110-
110+
$isVendor = false;
111111
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file));
112112

113113
$i = count($trace);
@@ -121,6 +121,11 @@ public static function register($mode = 0)
121121
$msg = $parsedMsg['deprecation'];
122122
$class = $parsedMsg['class'];
123123
$method = $parsedMsg['method'];
124+
// If the deprecation has been triggered via
125+
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
126+
// then we need to use the serialized information to determine
127+
// if the error has been triggered from vendor code.
128+
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($parsedMsg['triggering_file']));
124129
} else {
125130
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
126131
$method = $trace[$i]['function'];
@@ -261,7 +266,7 @@ public static function collectDeprecations($outputFile)
261266

262267
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
263268
}
264-
$deprecations[] = array(error_reporting(), $msg);
269+
$deprecations[] = array(error_reporting(), $msg, $file);
265270
});
266271

267272
register_shutdown_function(function () use ($outputFile, &$deprecations) {

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ public function endTest($test, $time)
272272
unlink($this->runsInSeparateProcess);
273273
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
274274
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
275+
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => $deprecation[2]));
275276
if ($deprecation[0]) {
276-
trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
277+
trigger_error($error, E_USER_DEPRECATED);
277278
} else {
278-
@trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
279+
@trigger_error($error, E_USER_DEPRECATED);
279280
}
280281
}
281282
$this->runsInSeparateProcess = false;

0 commit comments

Comments
 (0)
0