PDO::ERRMODE_EXCEPTION] ); $stmt = $pdo->prepare('SELECT uid FROM pages WHERE deleted = 0 AND slug = ? AND sys_language_uid IN (0,-1)'); $stmt->execute([PAGE_SLUG]); $pid = (int)$stmt->fetchColumn(); if ($pid === 0) { exit("Seite " . PAGE_SLUG . " nicht gefunden.\n"); } echo ($apply ? 'APPLY' : 'INSPECT') . " ยท Seite #$pid " . PAGE_SLUG . "\n\n"; $stmt = $pdo->prepare( 'SELECT uid, colPos, sorting, CType, header, tx_container_parent, hidden FROM tt_content WHERE deleted = 0 AND pid = ? ORDER BY colPos, sorting' ); $stmt->execute([$pid]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $delete = []; printf("%-7s %-7s %-8s %-28s %-9s %-7s %s\n", 'uid', 'colPos', 'parent', 'CType', 'hidden', 'aktion', 'header'); foreach ($rows as $row) { $keep = in_array((int)$row['uid'], KEEP, true); if (!$keep) { $delete[] = (int)$row['uid']; } printf("%-7d %-7d %-8d %-28s %-9s %-7s %s\n", $row['uid'], $row['colPos'], $row['tx_container_parent'], $row['CType'], $row['hidden'] ? 'hidden' : '-', $keep ? 'KEEP' : 'DELETE', mb_substr((string)$row['header'], 0, 45)); } echo "\n" . count($rows) . " Element(e), davon " . count($delete) . " zu loeschen, " . (count($rows) - count($delete)) . " bleiben.\n"; $missing = array_diff(KEEP, array_map(static fn(array $r): int => (int)$r['uid'], $rows)); if ($missing !== []) { echo "WARNUNG: Whitelist-Elemente fehlen auf der Seite: " . implode(', ', $missing) . " - NICHT anwenden, erst klaeren.\n"; exit(1); } if (!$apply) { echo "\nInspect only - mit --apply soft-loeschen.\n"; exit(0); } if ($delete === []) { echo "Nichts zu tun.\n"; exit(0); } $in = implode(',', array_fill(0, count($delete), '?')); $stmt = $pdo->prepare("UPDATE tt_content SET deleted = 1, tstamp = UNIX_TIMESTAMP() WHERE uid IN ($in)"); $stmt->execute($delete); echo "Soft-geloescht: " . $stmt->rowCount() . " Element(e). Danach: vendor/bin/typo3 cache:flush\n";