8000 Merge branch '2.8' into 3.4 · symfony/symfony@993c028 · GitHub
[go: up one dir, main page]

Skip to content

Commit 993c028

Browse files
Merge branch '2.8' into 3.4
* 2.8: [HttpFoundation] Fix perf issue during MimeTypeGuesser intialization
2 parents 46c2d4b + ca6cc78 commit 993c028

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"twig/twig": "~1.34|~2.4"
4747
},
4848
"conflict": {
49-
"symfony/security": "4.1.0-beta1,4.1.0-beta2",
49+
"symfony/security": "4.1.0-beta1|4.1.0-beta2",
5050
"symfony/var-dumper": "<3.3",
5151
"symfony/event-dispatcher": "<3.4",
5252
"symfony/framework-bundle": "<3.4",

src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,8 @@ public static function reset()
8080
*/
8181
private function __construct()
8282
{
83-
if (FileBinaryMimeTypeGuesser::isSupported()) {
84-
$this->register(new FileBinaryMimeTypeGuesser());
85-
}
86-
87-
if (FileinfoMimeTypeGuesser::isSupported()) {
88-
$this->register(new FileinfoMimeTypeGuesser());
89-
}
83+
$this->register(new FileBinaryMimeTypeGuesser());
84+
$this->register(new FileinfoMimeTypeGuesser());
9085
}
9186

9287
/**
@@ -125,18 +120,14 @@ public function guess($path)
125120
throw new AccessDeniedException($path);
126121
}
127122

128-
if (!$this->guessers) {
129-
$msg = 'Unable to guess the mime type as no guessers are available';
130-
if (!FileinfoMimeTypeGuesser::isSupported()) {
131-
$msg .= ' (Did you enable the php_fileinfo extension?)';
132-
}
133-
throw new \LogicException($msg);
134-
}
135-
136123
foreach ($this->guessers as $guesser) {
137124
if (null !== $mimeType = $guesser->guess($path)) {
138125
return $mimeType;
139126
}
140127
}
128+
129+
if (2 === \count($this->guessers) && !FileBinaryMimeTypeGuesser::isSupported() && !FileinfoMimeTypeGuesser::isSupported()) {
130+
throw new \LogicException('Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)');
131+
}
141132
}
142133
}

0 commit comments

Comments
 (0)
0