Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf33382d

Browse files
bug#24864 Have weak_vendors ignore deprecations from outside (greg0ire)
This PR was merged into the 3.3 branch.Discussion----------Have weak_vendors ignore deprecations from outsidephar:// and eval() can execute code that may or may not come from the vendors.| Q | A| ------------- | ---| Branch? | 3.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | not yet| Fixed tickets |#24853| License | MITI haven't managed to get the phar test to pass yet, but before I do, is it ok for me to commit a test phar in Symfony? I'm thinking trust issues? Although the phar is almost plain text.~~Next, I'm stuck because it looks like symfony does not know how to load classes anymore... should I somehow load `vendor/autoload.php` from the phar or something like that?~~ solved, had nothing to do with that.Commits-------9ce0ae2 Have weak_vendors ignore deprecations from outside
2 parents02e5c67 +9ce0ae2 commitf33382d

File tree

6 files changed

+60
-2
lines changed

6 files changed

+60
-2
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ public static function register($mode = 0)
7575
}
7676
}
7777
}
78-
$path =realpath($path) ?:$path;
78+
$realPath =realpath($path);
79+
if (false ===$realPath &&'-' !==$path &&'Standard input code' !==$path) {
80+
returntrue;
81+
}
7982
foreach ($vendorsas$vendor) {
80-
if (0 ===strpos($path,$vendor) &&false !==strpbrk(substr($path,strlen($vendor),1),'/'.DIRECTORY_SEPARATOR)) {
83+
if (0 ===strpos($realPath,$vendor) &&false !==strpbrk(substr($realPath,strlen($vendor),1),'/'.DIRECTORY_SEPARATOR)) {
8184
returntrue;
8285
}
8386
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
@trigger_error('I come from… afar! :D',E_USER_DEPRECATED);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
$phar =newPhar(__DIR__.DIRECTORY_SEPARATOR.'deprecation.phar',0,'deprecation.phar');
4+
$phar->buildFromDirectory(__DIR__.DIRECTORY_SEPARATOR.'deprecation');
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
3+
--FILE--
4+
<?php
5+
6+
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
7+
putenv('ANSICON');
8+
putenv('ConEmuANSI');
9+
putenv('TERM');
10+
11+
$vendor =__DIR__;
12+
while (!file_exists($vendor.'/vendor')) {
13+
$vendor =dirname($vendor);
14+
}
15+
define('PHPUNIT_COMPOSER_INSTALL',$vendor.'/vendor/autoload.php');
16+
requirePHPUNIT_COMPOSER_INSTALL;
17+
require_once__DIR__.'/../../bootstrap.php';
18+
eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")
19+
20+
?>
21+
--EXPECTF--
22+
23+
Other deprecation notices (1)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
3+
The phar can be regenerated by running php src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/generate_phar.php
4+
--FILE--
5+
<?php
6+
7+
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
8+
putenv('ANSICON');
9+
putenv('ConEmuANSI');
10+
putenv('TERM');
11+
12+
$vendor =__DIR__;
13+
while (!file_exists($vendor.'/vendor')) {
14+
$vendor =dirname($vendor);
15+
}
16+
define('PHPUNIT_COMPOSER_INSTALL',$vendor.'/vendor/autoload.php');
17+
requirePHPUNIT_COMPOSER_INSTALL;
18+
require_once__DIR__.'/../../bootstrap.php';
19+
\Phar::loadPhar(__DIR__.'/deprecation.phar','deprecation.phar');
20+
include'phar://deprecation.phar/deprecation.php';
21+
22+
?>
23+
--EXPECTF--
24+
25+
Other deprecation notices (1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp