Skip to content

Commit

Permalink
Merge pull request #191 from wp-cli/must-use-sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Nov 10, 2023
2 parents 560ed5c + 61d8caf commit 4123df6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/Context/FeatureContext.php
Expand Up @@ -371,18 +371,20 @@ private static function download_sqlite_plugin( $dir ) {
* configure it to use SQLite as the database by placing the db.php dropin file
*/
private static function configure_sqlite( $dir ) {
$db_copy = $dir . '/wp-content/plugins/sqlite-database-integration/db.copy';
$db_copy = $dir . '/wp-content/mu-plugins/sqlite-database-integration/db.copy';
$db_dropin = $dir . '/wp-content/db.php';

/* similar to https://github.com/WordPress/sqlite-database-integration/blob/3306576c9b606bc23bbb26c15383fef08e03ab11/activate.php#L95 */
$file_contents = str_replace(
array(
'\'{SQLITE_IMPLEMENTATION_FOLDER_PATH}\'',
'{SQLITE_PLUGIN}',
'/plugins/',
),
array(
'__DIR__ . \'plugins/sqlite-database-integration\'',
'__DIR__ . \'mu-plugins/sqlite-database-integration\'',
'sqlite-database-integration/load.php',
'/mu-plugins/',
),
file_get_contents( $db_copy )
);
Expand Down Expand Up @@ -949,7 +951,7 @@ public function download_wp( $subdir = '' ) {
copy( dirname( dirname( __DIR__ ) ) . '/utils/polyfills.php', $dest_dir . '/wp-content/mu-plugins/polyfills.php' );

if ( 'sqlite' === self::$db_type ) {
self::copy_dir( self::$sqlite_cache_dir, $dest_dir . '/wp-content/plugins' );
self::copy_dir( self::$sqlite_cache_dir, $dest_dir . '/wp-content/mu-plugins' );
self::configure_sqlite( $dest_dir );
}
}
Expand Down Expand Up @@ -1090,7 +1092,7 @@ public function install_wp_with_composer( $vendor_directory = 'vendor' ) {
];

if ( 'sqlite' === self::$db_type ) {
self::copy_dir( self::$sqlite_cache_dir, $this->variables['RUN_DIR'] . '/WordPress/wp-content/plugins' );
self::copy_dir( self::$sqlite_cache_dir, $this->variables['RUN_DIR'] . '/WordPress/wp-content/mu-plugins' );
self::configure_sqlite( $this->variables['RUN_DIR'] . '/WordPress' );
}

Expand Down
10 changes: 8 additions & 2 deletions src/Context/GivenStepDefinitions.php
Expand Up @@ -175,15 +175,21 @@ public function given_a_custom_wp_directory() {
"define( 'WP_PLUGIN_DIR', __DIR__ . '/my-plugins' );"
);

$this->move_files( 'my-content/mu-plugins', 'my-mu-plugins' );
$this->add_line_to_wp_config(
$wp_config_code,
"define( 'WPMU_PLUGIN_DIR', __DIR__ . '/my-mu-plugins' );"
);

file_put_contents( $wp_config_path, $wp_config_code );

if ( 'sqlite' === self::$db_type ) {
$db_dropin = $this->variables['RUN_DIR'] . '/my-content/db.php';

/* similar to https://github.com/WordPress/sqlite-database-integration/blob/3306576c9b606bc23bbb26c15383fef08e03ab11/activate.php#L95 */
$file_contents = str_replace(
'plugins/',
'../my-plugins/',
'mu-plugins/',
'../my-mu-plugins/',
file_get_contents( $db_dropin )
);

Expand Down

0 comments on commit 4123df6

Please sign in to comment.