8000 Have weak_vendors ignore deprecations from outside by greg0ire · Pull Request #24864 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Have weak_vendors ignore deprecations from outside #24864

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

Merged
merged 1 commit into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Have weak_vendors ignore deprecations from outside
phar:// and eval() can execute code that may or may not come from the vendors.
  • Loading branch information
greg0ire committed Jan 21, 2018
commit 9ce0ae23aee0cc32bbedb0436a47f267900017c0
7 changes: 5 additions & 2 deletions src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ public static function register($mode = 0)
}
}
}
$path = realpath($path) ?: $path;
$realPath = realpath($path);
if (false === $realPath && '-' !== $path && 'Standard input code' !== $path) {
return true;
}
foreach ($vendors as $vendor) {
if (0 === strpos($path, $vendor) && false !== strpbrk(substr($path, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
return true;
}
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

@trigger_error('I come from… afar! :D', E_USER_DEPRECATED);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$phar = new Phar(__DIR__.DIRECTORY_SEPARATOR.'deprecation.phar', 0, 'deprecation.phar');
$phar->buildFromDirectory(__DIR__.DIRECTORY_SEPARATOR.'deprecation');
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
--FILE--
<?php

putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = dirname($vendor);
}
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
require_once __DIR__.'/../../bootstrap.php';
eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")

?>
--EXPECTF--

Other deprecation notices (1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
The phar can be regenerated by running php src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/generate_phar.php
--FILE--
<?php

putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = dirname($vendor);
}
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
require_once __DIR__.'/../../bootstrap.php';
\Phar::loadPhar(__DIR__.'/deprecation.phar', 'deprecation.phar');
include 'phar://deprecation.phar/deprecation.php';

?>
--EXPECTF--

Other deprecation notices (1)
0