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:
@@ -404,15 +404,31 @@ class MprIcons
|
||||
if (!file_exists($cssFile)) {
|
||||
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');
|
||||
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);
|
||||
if (stripos($chunk, 'Material Icons') !== false) {
|
||||
if ($hasMaterial) {
|
||||
return self::MATERIAL;
|
||||
}
|
||||
if (stripos($chunk, 'FontAwesome') !== false) {
|
||||
if ($hasFA) {
|
||||
return self::FA;
|
||||
}
|
||||
}
|
||||
@@ -481,9 +497,18 @@ class MprIcons
|
||||
}
|
||||
$handle = fopen($cssFile, 'r');
|
||||
if ($handle) {
|
||||
$chunk = fread($handle, 51200);
|
||||
$found = false;
|
||||
$bytesRead = 0;
|
||||
while (!feof($handle) && $bytesRead < 204800) {
|
||||
$chunk = fread($handle, 102400);
|
||||
$bytesRead += strlen($chunk);
|
||||
if (stripos($chunk, $needle) !== false) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
if (stripos($chunk, $needle) !== false) {
|
||||
if ($found) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user