debug: Add detailed pattern matching logging

This commit is contained in:
FrankZamora
2025-11-27 13:53:56 -06:00
parent eeacfdb284
commit acdfeffd75

View File

@@ -47,8 +47,13 @@ final class YoutubeFacadeContentFilter
// More flexible: allows any attributes in any order, whitespace variations
$pattern = '/<iframe\s+[^>]*src=["\']https?:\/\/(?:www\.)?(?:youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9_-]+)[^"\']*["\'][^>]*>\s*<\/iframe>/is';
// Debug: test pattern
$matchCount = preg_match_all($pattern, $content, $testMatches);
file_put_contents('/tmp/yt-debug.log', date('H:i:s') . " Pattern matches: " . $matchCount . " videos: " . implode(',', $testMatches[1] ?? []) . "\n", FILE_APPEND);
$result = preg_replace_callback($pattern, function ($matches) {
$videoId = $matches[1];
file_put_contents('/tmp/yt-debug.log', date('H:i:s') . " Replacing video: " . $videoId . "\n", FILE_APPEND);
return $this->renderer->render($videoId);
}, $content);