Files
VITEC-website/migrations/check_old_stubs.php
T
orascheandClaude Fable 5 80f6da7949 Retire the six old-taxonomy category stubs under /products
- diagnosis first (migrations/check_old_stubs.php, kept): the six
  old-taxonomy pages (#451-454, #456, #458) were completely empty - no
  content elements and NO family child pages (the family workbooks were
  deliberately never imported), so nothing needed moving
- migrations/retire_old_category_stubs.php (dry-run by default, guards
  against children/content) soft-deletes each stub and queues a 301
  sys_redirect onto its new-taxonomy equivalent; existing redirects for
  a path are kept
- applied and verified live: all six old paths answer with the 301
  redirect envelope onto the correct new category page, and the main
  navigation now shows exactly the nine new categories in sitemap order

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-10-27 15:19:38 +01:00

51 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* Diagnose: the six old-taxonomy category stubs under /products
* (#451-454, #456, #458) - their own content, their child pages (family
* level) and those children's content/state. Basis for the
* hide/move/redirect decision (2026-10-27).
*
* READ-ONLY. Usage: php migrations/check_old_stubs.php
*/
error_reporting(E_ALL);
ini_set('display_errors', '1');
$root = null;
$dir = __DIR__;
for ($i = 0; $i < 5; $i++) {
if (is_file($dir . '/config/system/settings.php')) { $root = $dir; break; }
$dir = dirname($dir);
}
if ($root === null) { exit("no project root\n"); }
$settings = require $root . '/config/system/settings.php';
$db = $settings['DB']['Connections']['Default'];
$pdo = new PDO(
sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8mb4', $db['host'] ?? 'localhost', $db['port'] ?? 3306, $db['dbname'] ?? ''),
$db['user'] ?? '', $db['password'] ?? '',
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]
);
function tree(PDO $pdo, int $pid, int $depth): void
{
$rows = $pdo->query("SELECT uid, title, slug, doktype, layout, hidden, nav_hide, sorting
FROM pages WHERE deleted = 0 AND pid = $pid ORDER BY sorting")->fetchAll();
foreach ($rows as $r) {
$ce = (int)$pdo->query("SELECT COUNT(*) FROM tt_content WHERE deleted = 0 AND hidden = 0 AND pid = {$r['uid']}")->fetchColumn();
printf("%s#%-5d dok=%d lay=%-2d hid=%d nav=%d ce=%-3d %-55s %s\n",
str_repeat(' ', $depth), $r['uid'], $r['doktype'], $r['layout'], $r['hidden'], $r['nav_hide'], $ce, $r['slug'], $r['title']);
tree($pdo, (int)$r['uid'], $depth + 1);
}
}
foreach ([451, 452, 453, 454, 456, 458] as $stub) {
$r = $pdo->query("SELECT uid, title, slug, hidden, nav_hide FROM pages WHERE uid = $stub")->fetch();
$ce = (int)$pdo->query("SELECT COUNT(*) FROM tt_content WHERE deleted = 0 AND hidden = 0 AND pid = $stub")->fetchColumn();
printf("STUB #%-4d hid=%d nav=%d ce=%-3d %-50s %s\n", $r['uid'], $r['hidden'], $r['nav_hide'], $ce, $r['slug'], $r['title']);
tree($pdo, $stub, 1);
echo "\n";
}