#!/usr/bin/env php cleanupOrphanedDrafts(24, $dryRun); } catch (Exception $e) { error_log('[cleanup-drafts] Error: ' . $e->getMessage()); exit(1); } $count = count($result['candidates']); if ($count === 0) { exit(0); // nothing to do — quiet exit } if ($dryRun) { foreach ($result['candidates'] as $row) { printf( "DRY-RUN → #%d %s \"%s\" (submitted %s)\n", $row['id'], $row['identifier'], $row['title'], $row['submitted_at'] ); } echo "Found {$count} orphaned draft(s). Re-run with --no-dry-run to delete.\n"; exit(0); } printf("Deleted %d orphaned draft(s).\n", $result['deleted']); exit(0);