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

Appearance settings

Commit cc3fb70

Browse filesBrowse files
bug #58492 [MonologBridge] Fix PHP deprecation with preg_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 parents df81a1a + 4d7a6f6 commit cc3fb70
Copy full SHA for cc3fb70

File tree

2 files changed

+41
-1
lines changed
Filter options

2 files changed

+41
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php
+1-1Lines 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

+40Lines 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+
namespace Symfony\Bridge\Monolog\Tests\Handler;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\Monolog\Handler\ChromePhpHandler;
16+
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\HttpFoundation\Response;
18+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
19+
use Symfony\Component\HttpKernel\HttpKernelInterface;
20+
21+
class ChromePhpHandlerTest extends TestCase
22+
{
23+
public function testOnKernelResponseShouldNotTriggerDeprecation()
24+
{
25+
$request = Request::create('/');
26+
$request->headers->remove('User-Agent');
27+
28+
$response = new Response('foo');
29+
$event = new ResponseEvent($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 = new ChromePhpHandler();
35+
$listener->onKernelResponse($event);
36+
restore_error_handler();
37+
38+
$this->assertNull($error);
39+
}
40+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.