diff -u b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php --- b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -144,29 +144,34 @@ } } - if (in_array($main_profile->getName(), $uninstalls, TRUE)) { - // Ensure that the active profile is not being uninstalled. - $profile_name = $main_profile->info['name']; - $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the main install profile.', ['%profile' => $profile_name])); - } + // Don't allow profiles to be uninstalled. It's possible for no profile to + // be set yet if the config is being imported during initial site install. + if (isset($main_profile)) { + if (in_array($main_profile->getName(), $uninstalls, TRUE)) { + // Ensure that the active profile is not being uninstalled. + $profile_name = $main_profile->info['name']; + $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the main install profile.', ['%profile' => $profile_name])); + } - $profile_names = []; - if ($profile_uninstalls = array_intersect_key($profiles, array_flip($uninstalls))) { - // Ensure that none of the parent profiles are being uninstalled. - foreach ($profile_uninstalls as $profile) { - if ($profile->getName() !== $main_profile->getName()) { - $profile_names[] = $module_data[$profile->getName()]->info['name']; + if ($profile_uninstalls = array_intersect_key($profiles, array_flip($uninstalls))) { + // Ensure that none of the parent profiles are being uninstalled. + $profile_names = []; + foreach ($profile_uninstalls as $profile) { + if ($profile->getName() !== $main_profile->getName()) { + $profile_names[] = $module_data[$profile->getName()]->info['name']; + } + } + if (!empty($profile_names)) { + $message = $this->formatPlural(count($profile_names), + 'Unable to uninstall the :profile profile since it is a parent of another installed profile.', + 'Unable to uninstall the :profile profiles since they are parents of another installed profile.', + [':profile' => implode(', ', $profile_names)] + ); + $config_importer->logError($message); } - } - if (!empty($profile_names)) { - $message = $this->formatPlural(count($profile_names), - 'Unable to uninstall the :profile profile since it is a parent of another installed profile.', - 'Unable to uninstall the :profile profiles since they are parents of another installed profile.', - [':profile' => implode(', ', $profile_names)] - ); - $config_importer->logError($message); } } + } /**