chore(php): add toc debug logging for guest visibility issue

Temporary debug logging to diagnose why TOC shows for logged users
but not for guests. Logs visibility checks at each layer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-12-06 23:03:42 -06:00
parent 5333531be4
commit 0c1908e7d1
5 changed files with 67 additions and 3 deletions

View File

@@ -28,15 +28,27 @@ final class EvaluatePageVisibilityUseCase
{
$config = $this->visibilityRepository->getVisibilityConfig($componentName);
// DEBUG: Log for TOC only
$debugToc = ($componentName === 'table-of-contents');
$usingDefaults = false;
if (empty($config)) {
// Usar defaults especificos por componente si existen
$config = VisibilityDefaults::getForComponent($componentName);
$usingDefaults = true;
}
$pageType = $this->pageTypeDetector->detect();
$visibilityField = $pageType->toVisibilityField();
$fieldValue = $config[$visibilityField] ?? true;
$result = $this->toBool($fieldValue);
return $this->toBool($config[$visibilityField] ?? true);
if ($debugToc) {
error_log("EvaluatePageVisibility [{$componentName}]: pageType=" . $pageType->value() . ", field={$visibilityField}, fieldValue=" . var_export($fieldValue, true) . ", result=" . ($result ? "true" : "false") . ", usingDefaults=" . ($usingDefaults ? "true" : "false"));
error_log("EvaluatePageVisibility [{$componentName}]: config=" . json_encode($config));
}
return $result;
}
private function toBool(mixed $value): bool