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

Commitcc3fb70

Browse files
bug#58492 [MonologBridge] Fix PHP deprecation withpreg_match() (simoheinonen)
This PR was merged into the 5.4 branch.Discussion----------[MonologBridge] Fix PHP deprecation with `preg_match()`| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues || License | MIT```preg_match(): Passing null to parameter#2 ($subject) of type string is deprecated```Commits-------4d7a6f6 Passing null to parameter#2 ($subject) of type string is deprecated
2 parentsdf81a1a +4d7a6f6 commitcc3fb70

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

‎src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function onKernelResponse(ResponseEvent $event)
4040
return;
4141
}
4242

43-
if (!preg_match(static::USER_AGENT_REGEX,$event->getRequest()->headers->get('User-Agent'))) {
43+
if (!preg_match(static::USER_AGENT_REGEX,$event->getRequest()->headers->get('User-Agent',''))) {
4444
self::$sendHeaders =false;
4545
$this->headers = [];
4646

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Bridge\Monolog\Tests\Handler;
13+
14+
usePHPUnit\Framework\TestCase;
15+
useSymfony\Bridge\Monolog\Handler\ChromePhpHandler;
16+
useSymfony\Component\HttpFoundation\Request;
17+
useSymfony\Component\HttpFoundation\Response;
18+
useSymfony\Component\HttpKernel\Event\ResponseEvent;
19+
useSymfony\Component\HttpKernel\HttpKernelInterface;
20+
21+
class ChromePhpHandlerTestextends TestCase
22+
{
23+
publicfunctiontestOnKernelResponseShouldNotTriggerDeprecation()
24+
{
25+
$request = Request::create('/');
26+
$request->headers->remove('User-Agent');
27+
28+
$response =newResponse('foo');
29+
$event =newResponseEvent($this->createMock(HttpKernelInterface::class),$request, HttpKernelInterface::MAIN_REQUEST,$response);
30+
31+
$error =null;
32+
set_error_handler(function ($type,$message)use (&$error) {$error =$message; }, \E_DEPRECATED);
33+
34+
$listener =newChromePhpHandler();
35+
$listener->onKernelResponse($event);
36+
restore_error_handler();
37+
38+
$this->assertNull($error);
39+
}
40+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp