3 namespace MediaWiki\Installer
;
5 use MediaWiki\Html\Html
;
6 use MediaWiki\Status\Status
;
11 class PostgresConnectForm
extends DatabaseConnectForm
{
13 public function getHtml() {
14 return $this->getTextBox(
18 $this->webInstaller
->getHelpBox( 'config-db-host-help' )
20 $this->getTextBox( 'wgDBport', 'config-db-port' ) .
21 $this->getCheckBox( 'wgDBssl', 'config-db-ssl' ) .
22 "<span class=\"cdx-card\"><span class=\"cdx-card__text\">" .
25 [ 'class' => 'cdx-card__text__title' ],
26 wfMessage( 'config-db-wiki-settings' )->text()
32 $this->webInstaller
->getHelpBox( 'config-db-name-help' )
38 $this->webInstaller
->getHelpBox( 'config-db-schema-help' )
40 "</span></span></span>" .
41 $this->getInstallUserBox();
44 public function submit() {
45 // Get variables from the request
46 $newValues = $this->setVarsFromRequest( [
55 $status = Status
::newGood();
56 if ( !strlen( $newValues['wgDBname'] ) ) {
57 $status->fatal( 'config-missing-db-name' );
58 } elseif ( !preg_match( '/^[a-zA-Z0-9_]+$/', $newValues['wgDBname'] ) ) {
59 $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
61 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBmwschema'] ) ) {
62 $status->fatal( 'config-invalid-schema', $newValues['wgDBmwschema'] );
66 if ( $status->isOK() ) {
67 $status->merge( $this->submitInstallUserBox() );
69 if ( !$status->isOK() ) {
73 $status = $this->getPostgresInstaller()->getConnection( DatabaseInstaller
::CONN_CREATE_DATABASE
);
74 if ( !$status->isOK() ) {
78 $conn = $status->getDB();
81 $status = PostgresInstaller
::meetsMinimumRequirement( $conn );
82 if ( !$status->isOK() ) {
86 $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
87 $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
89 return Status
::newGood();
93 * Downcast the DatabaseInstaller
95 private function getPostgresInstaller(): PostgresInstaller
{
96 // @phan-suppress-next-line PhanTypeMismatchReturnSuperType
97 return $this->dbInstaller
;