Felder leeren. * * Usage: php migrations/fix_story_placeholder_quotes.php (inspect) * php migrations/fix_story_placeholder_quotes.php --apply */ error_reporting(E_ALL); ini_set('display_errors', '1'); const SLUGS = ['africa-hall', 'bayer-uk', 'meydan-racecourse']; $apply = in_array('--apply', $argv, true); $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("Could not locate project root above " . __DIR__ . "\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] ); echo ($apply ? 'APPLY' : 'INSPECT') . "\n"; $in = implode(',', array_fill(0, count(SLUGS), '?')); $stmt = $pdo->prepare("SELECT uid, slug, LEFT(quote,60) q, quote_person, quote_role FROM tx_vitec_domain_model_usecase WHERE deleted = 0 AND slug IN ($in)"); $stmt->execute(SLUGS); $rows = $stmt->fetchAll(); foreach ($rows as $row) { printf("#%-4d %-20s quote=\"%s\" person=\"%s\" role=\"%s\" -> leeren\n", $row['uid'], $row['slug'], $row['q'], $row['quote_person'], $row['quote_role']); if ($apply) { $pdo->prepare("UPDATE tx_vitec_domain_model_usecase SET quote = '', quote_person = '', quote_role = '', tstamp = UNIX_TIMESTAMP() WHERE uid = ?") ->execute([(int)$row['uid']]); } } echo count($rows) . " Record(s)" . ($apply ? " geleert. Danach cache:flush." : ". Mit --apply leeren.") . "\n";