3 namespace MediaWiki\Installer
;
5 use MediaWiki\Html\Html
;
6 use MediaWiki\Status\Status
;
11 class MysqlConnectForm
extends DatabaseConnectForm
{
15 public function getHtml() {
16 return $this->getTextBox(
20 $this->webInstaller
->getHelpBox( 'config-db-host-help' )
22 $this->getCheckBox( 'wgDBssl', 'config-db-ssl' ) .
23 "<span class=\"cdx-card\"><span class=\"cdx-card__text\">" .
26 [ 'class' => 'cdx-card__text__title' ],
27 wfMessage( 'config-db-wiki-settings' )->text()
29 "<span class=\"cdx-card__text__description\">" .
30 $this->getTextBox( 'wgDBname', 'config-db-name', [ 'dir' => 'ltr' ],
31 $this->webInstaller
->getHelpBox( 'config-db-name-help' ) ) .
32 $this->getTextBox( 'wgDBprefix', 'config-db-prefix', [ 'dir' => 'ltr' ],
33 $this->webInstaller
->getHelpBox( 'config-db-prefix-help' ) ) .
34 "</span></span></span>" .
35 $this->getInstallUserBox();
38 public function submit() {
39 // Get variables from the request.
40 $newValues = $this->setVarsFromRequest( [ 'wgDBserver', 'wgDBname', 'wgDBprefix', 'wgDBssl' ] );
43 $status = Status
::newGood();
44 if ( !strlen( $newValues['wgDBserver'] ) ) {
45 $status->fatal( 'config-missing-db-host' );
47 if ( !strlen( $newValues['wgDBname'] ) ) {
48 $status->fatal( 'config-missing-db-name' );
49 } elseif ( !preg_match( '/^[a-z0-9+_-]+$/i', $newValues['wgDBname'] ) ) {
50 $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
52 if ( !preg_match( '/^[a-z0-9_-]*$/i', $newValues['wgDBprefix'] ) ) {
53 $status->fatal( 'config-invalid-db-prefix', $newValues['wgDBprefix'] );
55 if ( !$status->isOK() ) {
60 $status = $this->submitInstallUserBox();
61 if ( !$status->isOK() ) {
66 $status = $this->dbInstaller
->getConnection( DatabaseInstaller
::CONN_CREATE_DATABASE
);
67 if ( !$status->isOK() ) {
72 return MysqlInstaller
::meetsMinimumRequirement( $status->getDB() );