@@ -120,10 +120,10 @@ private static function get_initial_locale() {
120120 *
121121 * ## OPTIONS
122122 *
123- * --dbname=<dbname>
123+ * [ --dbname=<dbname>]
124124 * : Set the database name.
125125 *
126- * --dbuser=<dbuser>
126+ * [ --dbuser=<dbuser>]
127127 * : Set the database user.
128128 *
129129 * [--dbpass=<dbpass>]
@@ -219,6 +219,18 @@ public function create( $_, $assoc_args ) {
219219 'ssl ' => false ,
220220 ];
221221 $ assoc_args = array_merge ( $ defaults , $ assoc_args );
222+
223+ $ is_sqlite = self ::is_sqlite_integration_active ();
224+
225+ if ( ! $ is_sqlite ) {
226+ if ( empty ( $ assoc_args ['dbname ' ] ) ) {
227+ WP_CLI ::error ( 'Parameter errors: ' . PHP_EOL . 'missing --dbname parameter (Set the database name.) ' );
228+ }
229+ if ( empty ( $ assoc_args ['dbuser ' ] ) ) {
230+ WP_CLI ::error ( 'Parameter errors: ' . PHP_EOL . 'missing --dbuser parameter (Set the database user.) ' );
231+ }
232+ }
233+
222234 if ( empty ( $ assoc_args ['dbprefix ' ] ) ) {
223235 WP_CLI ::error ( '--dbprefix cannot be empty ' );
224236 }
@@ -228,7 +240,7 @@ public function create( $_, $assoc_args ) {
228240
229241 // Check DB connection. To make command more portable, we are not using MySQL CLI and using
230242 // mysqli directly instead, as $wpdb is not accessible in this context.
231- if ( ! Utils \get_flag_value ( $ assoc_args , 'skip-check ' ) ) {
243+ if ( ! $ is_sqlite && ! Utils \get_flag_value ( $ assoc_args , 'skip-check ' ) ) {
232244 // phpcs:disable WordPress.DB.RestrictedFunctions
233245 $ mysql = mysqli_init ();
234246
@@ -1480,6 +1492,25 @@ private function print_dotenv( array $value ) {
14801492 WP_CLI ::line ( "{$ name }= {$ variable_value }" );
14811493 }
14821494
1495+ /**
1496+ * Check if the SQLite integration drop-in is active.
1497+ *
1498+ * @return bool True if SQLite integration is detected, false otherwise.
1499+ */
1500+ private static function is_sqlite_integration_active () {
1501+ $ wp_content_dir = defined ( 'WP_CONTENT_DIR ' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content ' ;
1502+ $ db_dropin_path = $ wp_content_dir . '/db.php ' ;
1503+
1504+ if ( file_exists ( $ db_dropin_path ) ) {
1505+ $ db_dropin_contents = file_get_contents ( $ db_dropin_path , false , null , 0 , 8192 );
1506+ if ( false !== $ db_dropin_contents && false !== strpos ( $ db_dropin_contents , 'SQLITE_DB_DROPIN_VERSION ' ) ) {
1507+ return true ;
1508+ }
1509+ }
1510+
1511+ return false ;
1512+ }
1513+
14831514 /**
14841515 * Escape a config value so it can be safely used within single quotes.
14851516 *
0 commit comments