Skip to content

Commit

Permalink
check if SQLite3 exists
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed May 8, 2023
1 parent 66338b7 commit a66569e
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/wp-admin/setup-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ function setup_config_display_header( $body_classes = array() ) {
_e( 'Before getting started' );
?>
</h1>
<p><?php _e( 'Welcome to WordPress. Before getting started, you will need to know whether you want to use a MySQL (default), or an SQLite database. If you choose to use MySQL, you will need to provide the following details:' ); ?></p>
<p>
<?php if ( class_exists( 'SQLite3' ) ) : ?>
<?php _e( 'Welcome to WordPress. Before getting started, you will need to know whether you want to use a MySQL (default), or an SQLite database. If you choose to use MySQL, you will need to provide the following details:' ); ?>
<?php else : ?>
<?php _e( 'Welcome to WordPress. Before getting started, you will need to know the following items.' ); ?>
<?php endif; ?>
</p>
<ol>
<li><?php _e( 'Database name' ); ?></li>
<li><?php _e( 'Database username' ); ?></li>
Expand Down Expand Up @@ -221,16 +227,18 @@ function setup_config_display_header( $body_classes = array() ) {
<form method="post" action="setup-config.php?step=2">
<p><?php _e( 'Below you should enter your database connection details. If you are not sure about these, contact your host.' ); ?></p>
<table class="form-table" role="presentation">
<tr id="table-row-dbtype">
<th scope="row"><label for="dbtype"><?php _e( 'Database Engine' ); ?></label></th>
<td>
<select name="dbtype" id="dbtype" aria-describedby="dbtype-desc" onChange="window.selectDBType( this );" style="width:26ch;">
<option value="mysql" selected><?php _e( 'MySQL' ); ?></option>
<option value="sqlite"><?php _e( 'SQLite' ); ?></option>
</select>
</td>
<td id="dbtype-desc"><?php _e( 'The type of database to use. SQLite is more suitable to personal blogs and smaller sites, while MySQL will allow your site to scale and grow easier.' ); ?></td>
</tr>
<?php if ( class_exists( 'SQLite3' ) ) : ?>
<tr id="table-row-dbtype">
<th scope="row"><label for="dbtype"><?php _e( 'Database Engine' ); ?></label></th>
<td>
<select name="dbtype" id="dbtype" aria-describedby="dbtype-desc" onChange="window.selectDBType( this );" style="width:26ch;">
<option value="mysql" selected><?php _e( 'MySQL' ); ?></option>
<option value="sqlite"><?php _e( 'SQLite' ); ?></option>
</select>
</td>
<td id="dbtype-desc"><?php _e( 'The type of database to use. SQLite is more suitable to personal blogs and smaller sites, while MySQL will allow your site to scale and grow easier.' ); ?></td>
</tr>
<?php endif; ?>
<tr id="table-row-dbname">
<th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th>
<td><input name="dbname" id="dbname" type="text" aria-describedby="dbname-desc" size="25" placeholder="wordpress"<?php echo $autofocus; ?>/></td>
Expand Down Expand Up @@ -287,7 +295,8 @@ function setup_config_display_header( $body_classes = array() ) {
$GLOBALS['wp_locale'] = new WP_Locale();

$dbtype = trim( wp_unslash( $_POST['dbtype'] ) );
$dbtype = 'sqlite' === $dbtype ? 'sqlite' : 'mysql';
$dbtype = class_exists( 'SQLite3' ) && 'sqlite' === $dbtype ? 'sqlite' : 'mysql';

$dbname = trim( wp_unslash( $_POST['dbname'] ) );
$uname = trim( wp_unslash( $_POST['uname'] ) );
$pwd = trim( wp_unslash( $_POST['pwd'] ) );
Expand Down

0 comments on commit a66569e

Please sign in to comment.