Increase CSS scan to 200KB for font-face detection

PS 8.2 classic theme.css is 194KB with Material Icons font-face
at byte 85693 — the 50KB limit missed it entirely. Now reads
in 100KB chunks up to 200KB.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 09:58:13 +00:00
parent b75eb1454f
commit ddcc8093a0

View File

@@ -404,15 +404,31 @@ class MprIcons
if (!file_exists($cssFile)) { if (!file_exists($cssFile)) {
continue; continue;
} }
// Read first 50KB font-face is always near the top // Minified theme.css can be 200KB+; font-face may be at ~85KB
// Read in 100KB chunks, scan up to 200KB
$handle = fopen($cssFile, 'r'); $handle = fopen($cssFile, 'r');
if ($handle) { if ($handle) {
$chunk = fread($handle, 51200); $hasMaterial = false;
$hasFA = false;
$bytesRead = 0;
while (!feof($handle) && $bytesRead < 204800) {
$chunk = fread($handle, 102400);
$bytesRead += strlen($chunk);
if (!$hasMaterial && stripos($chunk, 'Material Icons') !== false) {
$hasMaterial = true;
}
if (!$hasFA && stripos($chunk, 'FontAwesome') !== false) {
$hasFA = true;
}
if ($hasMaterial || $hasFA) {
break;
}
}
fclose($handle); fclose($handle);
if (stripos($chunk, 'Material Icons') !== false) { if ($hasMaterial) {
return self::MATERIAL; return self::MATERIAL;
} }
if (stripos($chunk, 'FontAwesome') !== false) { if ($hasFA) {
return self::FA; return self::FA;
} }
} }
@@ -481,9 +497,18 @@ class MprIcons
} }
$handle = fopen($cssFile, 'r'); $handle = fopen($cssFile, 'r');
if ($handle) { if ($handle) {
$chunk = fread($handle, 51200); $found = false;
fclose($handle); $bytesRead = 0;
while (!feof($handle) && $bytesRead < 204800) {
$chunk = fread($handle, 102400);
$bytesRead += strlen($chunk);
if (stripos($chunk, $needle) !== false) { if (stripos($chunk, $needle) !== false) {
$found = true;
break;
}
}
fclose($handle);
if ($found) {
return true; return true;
} }
} }