function Tasks::validateDatabaseSettings

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Install/Tasks.php \Drupal\Core\Database\Install\Tasks::validateDatabaseSettings()
  2. 8.9.x core/lib/Drupal/Core/Database/Install/Tasks.php \Drupal\Core\Database\Install\Tasks::validateDatabaseSettings()
  3. 11.x core/lib/Drupal/Core/Database/Install/Tasks.php \Drupal\Core\Database\Install\Tasks::validateDatabaseSettings()

Validates driver specific configuration settings.

Checks to ensure correct basic database settings and that a proper connection to the database can be established.

Parameters

string[] $database: An array of driver specific configuration options.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup[] An array of driver configuration errors, keyed by form element name.

File

core/lib/Drupal/Core/Database/Install/Tasks.php, line 344

Class

Tasks
Database installer structure.

Namespace

Drupal\Core\Database\Install

Code

public function validateDatabaseSettings(array $database) {
    $errors = [];
    // Verify the table prefix.
    if (!empty($database['prefix']) && is_string($database['prefix']) && !preg_match('/^[A-Za-z0-9_.]+$/', $database['prefix'])) {
        $errors[$database['driver'] . '][prefix'] = t('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', [
            '%prefix' => $database['prefix'],
        ]);
    }
    return $errors;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.