forked from laysense/laysite
Load site settings from dotenv and store OAuth credentials
This commit is contained in:
@@ -227,6 +227,9 @@ final class SiteBackup
|
||||
|
||||
private static function replaceTables(PDO $pdo, array $tables): void
|
||||
{
|
||||
$credentials = array_column($pdo->query("SELECT layout_id, revision, encrypted_secret, payload
|
||||
FROM layout_oauth_credentials JOIN design_presets ON id = layout_id
|
||||
WHERE kind = 'header' AND preset = 'member'")->fetchAll(), null, 'layout_id');
|
||||
$revisions = [];
|
||||
foreach (self::TABLES as $table) {
|
||||
$columns = array_column($pdo->query('PRAGMA table_info(' . $table . ')')->fetchAll(), 'name');
|
||||
@@ -250,6 +253,18 @@ final class SiteBackup
|
||||
$query->execute(array_values($row));
|
||||
}
|
||||
}
|
||||
|
||||
$insert = $pdo->prepare('INSERT INTO layout_oauth_credentials (layout_id, revision, encrypted_secret) VALUES (?, ?, ?)');
|
||||
foreach ($tables['design_presets'] as $layout) {
|
||||
$saved = $credentials[$layout['id']] ?? null;
|
||||
if (!$saved || $layout['kind'] !== 'header' || $layout['preset'] !== 'member') {
|
||||
continue;
|
||||
}
|
||||
$provider = self::decode($layout['payload'])['provider'] ?? [];
|
||||
if ($provider && $provider === (self::decode($saved['payload'])['provider'] ?? [])) {
|
||||
$insert->execute([$layout['id'], $saved['revision'], $saved['encrypted_secret']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function selection(array $designs, string $kind, mixed $id): ?int
|
||||
|
||||
Reference in New Issue
Block a user