Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export const WP_CLI_IMPORT_EXPORT_RESPONSE_TIMEOUT =
WP_CLI_IMPORT_EXPORT_RESPONSE_TIMEOUT_IN_HRS * 60 * 60 * 1000; // 6hr

// SQLite
export const SQLITE_DATABASE_INTEGRATION_VERSION = 'v2.1.17-alpha.1';
export const SQLITE_DATABASE_INTEGRATION_VERSION = 'v2.2.3';

export const SQLITE_DATABASE_INTEGRATION_RELEASE_URL = `https://github.com/Automattic/sqlite-database-integration/archive/refs/tags/${ SQLITE_DATABASE_INTEGRATION_VERSION }.zip`;
export const SQLITE_DATABASE_INTEGRATION_RELEASE_URL = `https://github.com/WordPress/sqlite-database-integration/archive/refs/tags/${ SQLITE_DATABASE_INTEGRATION_VERSION }.zip`;

// IPC handlers that don't return anything (i.e. that are called with `ipcRenderer.send`)
export const IPC_VOID_HANDLERS = < const >[
Expand Down
6 changes: 3 additions & 3 deletions src/lib/import-export/export/export-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function exportDatabaseToFile(

// Execute the command to export directly to the temp file
const { stderr, exitCode } = await server.executeWpCliCommand(
`sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php`,
`sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php --enable-ast-driver`,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We set the parameter to enable the AST driver for CLI actions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We probably won't add more commands, but I wonder if we should opt-in to use the AST driver more broadly. Like enable it by default, or auto-append the parameter in the wp-cli-process, similarly to how we increase the timeout:

const timeout =
args[ 0 ] === 'sqlite' && [ 'import', 'export' ].includes( args[ 1 ] )
? IMPORT_EXPORT_RESPONSE_TIMEOUT
: DEFAULT_RESPONSE_TIMEOUT;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could, but we should remove this parameter as soon as the SQLite driver enables it by default. What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then, let's leave it as it is. There is no risk that we'll introduce more SQLite commands and forget to add the parameter in the meantime. 👍

{
skipPluginsAndThemes: true,
}
Expand Down Expand Up @@ -50,7 +50,7 @@ export async function exportDatabaseToMultipleFiles(
}

const tablesResult = await server.executeWpCliCommand(
`sqlite tables --format=json --require=/tmp/sqlite-command/command.php`,
`sqlite tables --format=json --require=/tmp/sqlite-command/command.php --enable-ast-driver`,
{
skipPluginsAndThemes: true,
}
Expand Down Expand Up @@ -85,7 +85,7 @@ export async function exportDatabaseToMultipleFiles(

// Execute the command to export directly to a temporary file in the project directory
const { stderr, exitCode } = await server.executeWpCliCommand(
`sqlite export ${ fileName } --tables=${ table } --require=/tmp/sqlite-command/command.php`,
`sqlite export ${ fileName } --tables=${ table } --require=/tmp/sqlite-command/command.php --enable-ast-driver`,
{
skipPluginsAndThemes: true,
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/import-export/import/importers/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class BaseImporter extends EventEmitter implements Importer {
await move( sqlFile, tmpPath );
await this.prepareSqlFile( tmpPath );
const { stderr, exitCode } = await server.executeWpCliCommand(
`sqlite import ${ sqlTempFile } --require=/tmp/sqlite-command/command.php`,
`sqlite import ${ sqlTempFile } --require=/tmp/sqlite-command/command.php --enable-ast-driver`,
// SQLite plugin requires PHP 8+
{ targetPhpVersion: DEFAULT_PHP_VERSION, skipPluginsAndThemes: true }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ platformTestSuite( 'SqlExporter', ( { normalize } ) => {

const siteServer = SiteServer.get( '123' );
expect( siteServer?.executeWpCliCommand ).toHaveBeenCalledWith(
'sqlite export studio-backup-db-export-2024-08-01-12-00-00.sql --require=/tmp/sqlite-command/command.php',
'sqlite export studio-backup-db-export-2024-08-01-12-00-00.sql --require=/tmp/sqlite-command/command.php --enable-ast-driver',
{ skipPluginsAndThemes: true }
);
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ platformTestSuite( 'JetpackImporter', ( { normalize } ) => {
const siteServer = SiteServer.get( mockStudioSiteId );

const expectedCommand =
'sqlite import studio-backup-sql-2024-08-01-12-00-00.sql --require=/tmp/sqlite-command/command.php';
'sqlite import studio-backup-sql-2024-08-01-12-00-00.sql --require=/tmp/sqlite-command/command.php --enable-ast-driver';
expect( siteServer?.executeWpCliCommand ).toHaveBeenNthCalledWith( 1, expectedCommand, {
targetPhpVersion: '8.3',
skipPluginsAndThemes: true,
Expand Down
4 changes: 3 additions & 1 deletion vendor/wp-now/src/wp-now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ async function initWordPress( php: PHP, wordPressVersion: string, vfsDocumentRoo
initializeDefaultDatabase = true;
}

const wpConfigConsts = {};
const wpConfigConsts = {
WP_SQLITE_AST_DRIVER: true,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We set the constant to enable the new driver for the site's WP admin and frontend.

};

if ( wordPressVersion !== 'user-provided' ) {
wpConfigConsts[ 'WP_AUTO_UPDATE_CORE' ] = wordPressVersion === 'latest';
Expand Down
Loading