diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php
index 6078a5934a65df2dfbb14226556b4f431c3de318..f8cbd2ec725f65e887412048c886556ff031d93c 100644
--- a/lib/private/Files/Type/Detection.php
+++ b/lib/private/Files/Type/Detection.php
@@ -122,8 +122,14 @@ class Detection implements IMimeTypeDetector {
 		$this->mimetypes = array_merge($this->mimetypes, $types);
 
 		// Update the alternative mimetypes to avoid having to look them up each time.
-		foreach ($this->mimetypes as $mimeType) {
+		foreach ($this->mimetypes as $extension => $mimeType) {
+			if (strpos($extension, '_comment') === 0) {
+				continue;
+			}
 			$this->secureMimeTypes[$mimeType[0]] = $mimeType[1] ?? $mimeType[0];
+			if (isset($mimeType[1])) {
+				$this->secureMimeTypes[$mimeType[1]] = $mimeType[1];
+			}
 		}
 	}
 
diff --git a/resources/config/mimetypemapping.dist.json b/resources/config/mimetypemapping.dist.json
index c59dfaefd30ddf119e463bce4012cd949a1ba460..97b2f74ff0e7c62544995c85900ad596c00e54a7 100644
--- a/resources/config/mimetypemapping.dist.json
+++ b/resources/config/mimetypemapping.dist.json
@@ -134,7 +134,7 @@
 	"pdf": ["application/pdf"],
 	"pfb": ["application/x-font"],
 	"pef": ["image/x-dcraw"],
-	"php": ["application/x-php"],
+	"php": ["application/x-php", "text/x-php"],
 	"pl": ["application/x-perl"],
 	"pls": ["audio/x-scpls"],
 	"png": ["image/png"],