Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite: fix wp-config.php creation #187

Merged
merged 13 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions features/testing.feature
Original file line number Diff line number Diff line change
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
"""
13 changes: 10 additions & 3 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
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,9 @@ public function create_config( $subdir = '', $extra_php = false ) {

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

// Do not check database connection as we might be running SQLite and the check would fail.
schlessera marked this conversation as resolved.
Show resolved Hide resolved
$params['skip-check'] = true;

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved because it's otherwise not always defined

$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 +1032,12 @@ public function install_wp( $subdir = '' ) {
}
} else {
$this->proc( 'wp core install', $install_args, $subdir )->run_check();

if ( $install_cache_path ) {
mkdir( $install_cache_path );
if ( ! file_exists( $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
Loading