diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 6eae0bb05095cedf6b1958f930132c4d5fd6b875..88d30e538711170c8b5132026eae1b4046643b8f 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -393,7 +393,7 @@ function system_requirements($phase) {
   // Verify there are no database entries in settings.php with table prefix in
   // array format.
   if ($phase === 'runtime' || $phase === 'update') {
-    if (_system_check_array_table_prefixes(\Drupal::getContainer()->getParameter('app.root'), \Drupal::getContainer()->getParameter('site.path')) === TRUE) {
+    if (_system_check_array_table_prefixes() === TRUE) {
       $requirements['database_table_prefixes'] = [
         'title' => t('Database table prefixes'),
         'value' => t("There is at least one database entry in the \$database array in settings.php that has a 'prefix' value in the format of an array. Per-table prefixes are no longer supported. Change your settings.php file to ensure the value of every 'prefix' entry is a single string."),
@@ -1540,16 +1540,10 @@ function _system_advisories_requirements(array &$requirements): void {
 /**
  * Checks if there are 'prefix' entries in array format for tables.
  */
-function _system_check_array_table_prefixes($app_root, $site_path) {
-  if (is_readable($app_root . '/' . $site_path . '/settings.php')) {
-    include $app_root . '/' . $site_path . '/settings.php';
-  }
-  if (empty($databases)) {
-    return FALSE;
-  }
-  foreach ($databases as $database) {
-    foreach ($database as $target) {
-      if (isset($target['prefix']) && is_array($target['prefix'])) {
+function _system_check_array_table_prefixes() {
+  foreach (Database::getAllConnectionInfo() as $targets) {
+    foreach ($targets as $target) {
+      if (isset($target['extra_prefix']) && is_array($target['extra_prefix'])) {
         return TRUE;
       }
     }