'true']; $protectedBefore = $settings; $protectedAfter = $after; unset($protectedBefore['SGC_GEOGRAPHY_ENABLED'], $protectedAfter['SGC_GEOGRAPHY_ENABLED']); if ($protectedBefore !== $protectedAfter) { throw new LogicException('Unrelated setting change.'); } $backup = dirname($installation['backup']).'/settings-before.json'; if (file_put_contents($backup, $before, LOCK_EX) !== strlen($before)) { throw new RuntimeException('Settings backup failed.'); } $encoded = json_encode($after, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR).PHP_EOL; $temporary = $settingsFile.'.geography-'.bin2hex(random_bytes(4)).'.tmp'; if (file_put_contents($temporary, $encoded, LOCK_EX) !== strlen($encoded)) { throw new RuntimeException('Settings preparation failed.'); } if (hash_file('sha256', $settingsFile) !== hash('sha256', $before)) { unlink($temporary); throw new LogicException('Concurrent setting modification.'); } if (! rename($temporary, $settingsFile)) { throw new RuntimeException('Settings activation failed; prepared copy retained privately.'); } $confirmed = json_decode(file_get_contents($settingsFile), true, 32, JSON_THROW_ON_ERROR); if ($confirmed !== $after) { throw new RuntimeException('Settings verification failed.'); } $result = ['checked_at' => gmdate('c'), 'result' => 'passed', 'environment' => 'http://127.0.0.1:8005', 'authorization' => 'administrative-geography-installation-authorization.json', 'installation' => 'administrative-geography-installation.json', 'changed_setting' => 'SGC_GEOGRAPHY_ENABLED', 'selection_enabled' => true, 'other_settings_preserved' => true, 'settings_backup' => $backup, 'mfa_enabled' => false, 'business_commands' => false, 'automatic_classification' => false]; file_put_contents($root.'/docs/proofs/administrative-geography-activation.json', json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL); echo 'Geographic selection enabled only in the local pilot; all other settings preserved.'.PHP_EOL;