Skip to content

Commit

Permalink
Merge pull request #187 from wp-cli/fix/debug-sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Oct 23, 2023
2 parents b4e030a + 32e9f5e commit b452014
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
24 changes: 12 additions & 12 deletions features/testing.feature
Expand Up @@ -26,18 +26,18 @@ Feature: Test that WP-CLI loads.

@require-sqlite
Scenario: Uses SQLite
Given a WP install
When I run `wp eval 'echo DB_ENGINE;'`
Then STDOUT should contain:
"""
sqlite
"""
Given a WP install
When I run `wp eval 'echo DB_ENGINE;'`
Then STDOUT should contain:
"""
sqlite
"""

@require-mysql
Scenario: Uses MySQL
Given a WP install
When I run `wp eval 'var_export( defined("DB_ENGINE") );'`
Then STDOUT should be:
"""
false
"""
Given a WP install
When I run `wp eval 'var_export( defined("DB_ENGINE") );'`
Then STDOUT should be:
"""
false
"""
11 changes: 9 additions & 2 deletions src/Context/FeatureContext.php
Expand Up @@ -951,7 +951,6 @@ public function download_wp( $subdir = '' ) {
if ( 'sqlite' === self::$db_type ) {
self::copy_dir( self::$sqlite_cache_dir, $dest_dir . '/wp-content/plugins' );
self::configure_sqlite( $dest_dir );

}
}

Expand All @@ -963,6 +962,11 @@ public function create_config( $subdir = '', $extra_php = false ) {

$params['skip-salts'] = true;

// Do not check database connection if running SQLite as the check would fail.
if ( 'sqlite' === self::$db_type ) {
$params['skip-check'] = true;
}

if ( false !== $extra_php ) {
$params['extra-php'] = $extra_php;
}
Expand Down Expand Up @@ -1012,10 +1016,11 @@ public function install_wp( $subdir = '' ) {
'skip-email' => true,
];

$run_dir = '' !== $subdir ? ( $this->variables['RUN_DIR'] . "/$subdir" ) : $this->variables['RUN_DIR'];
$install_cache_path = '';

if ( self::$install_cache_dir ) {
$install_cache_path = self::$install_cache_dir . '/install_' . md5( implode( ':', $install_args ) . ':subdir=' . $subdir );
$run_dir = '' !== $subdir ? ( $this->variables['RUN_DIR'] . "/$subdir" ) : $this->variables['RUN_DIR'];
}

if ( $install_cache_path && file_exists( $install_cache_path ) ) {
Expand All @@ -1029,8 +1034,10 @@ public function install_wp( $subdir = '' ) {
}
} else {
$this->proc( 'wp core install', $install_args, $subdir )->run_check();

if ( $install_cache_path ) {
mkdir( $install_cache_path );

self::dir_diff_copy( $run_dir, self::$cache_dir, $install_cache_path );

if ( 'mysql' === self::$db_type ) {
Expand Down

0 comments on commit b452014

Please sign in to comment.