Skip to content

Commit 1623347

Browse files
authored
Retire the SQLite backend (#455)
mdi-native is the only backend. Delete the SQLite mirror and primary runtimes (inc/sqlite, WP_Markdown_DB, loader, search, mutation impact, primary storage runtime), SQLite Database Integration discovery and SQLite path detection in db.php, MARKDOWN_DB_MODE and index settings, primary-index health and recovery, the SQLite-backed native shadow verifier and authoritative snapshot runtime, native-vs-SQLite differential harnesses and rigs, and SQLite-only tests. Backend selection no longer inspects the filesystem: a leftover SQLite database is ignored and an unknown MARKDOWN_DB_BACKEND fails closed. Fixes #451
1 parent 86aab4f commit 1623347

97 files changed

Lines changed: 693 additions & 15420 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 157 additions & 843 deletions
Large diffs are not rendered by default.

‎bench/native-sqlite-differential.workload.json‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎db.php‎

Lines changed: 28 additions & 471 deletions
Large diffs are not rendered by default.

‎fuzz/mdi-native-sqlite-differential.json‎

Lines changed: 0 additions & 106 deletions
This file was deleted.

‎inc/class-wp-markdown-backend-adapter.php‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎inc/class-wp-markdown-backend-capabilities.php‎

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ public function __construct( string $backend, array $capabilities = array() ) {
8686
}
8787
}
8888

89-
/**
90-
* SQLite is the shipped reference backend. Keep this declaration complete
91-
* while future backends are extracted behind this contract.
92-
*/
93-
public static function sqlite(): self {
94-
$capabilities = array_fill_keys( self::KNOWN, true );
95-
$capabilities['canonical_option_select'] = false;
96-
return new self( 'sqlite', $capabilities );
97-
}
98-
9989
/** mdi-native executes canonical options, persisted schema, and generic snapshot tables. */
10090
public static function mdi_native(): self {
10191
return new self(
@@ -180,14 +170,11 @@ public static function configure_from_globals(): WP_Markdown_Backend_Capabilitie
180170
}
181171
}
182172

183-
$id = defined( 'MARKDOWN_DB_BACKEND' ) ? (string) MARKDOWN_DB_BACKEND : 'sqlite';
184-
if ( 'sqlite' === $id && ! isset( self::$declarations['sqlite'] ) ) {
185-
self::register( WP_Markdown_Backend_Capabilities::sqlite() );
186-
}
173+
$id = defined( 'MARKDOWN_DB_BACKEND' ) ? (string) MARKDOWN_DB_BACKEND : 'mdi-native';
187174
if ( 'mdi-native' === $id && ! isset( self::$declarations['mdi-native'] ) ) {
188175
self::register( WP_Markdown_Backend_Capabilities::mdi_native() );
189176
}
190-
if ( ! isset( self::$declarations[ $id ] ) ) {
177+
if ( 'mdi-native' !== $id || ! isset( self::$declarations[ $id ] ) ) {
191178
throw new WP_Markdown_Unknown_Backend( array(
192179
'code' => 'markdown_db_unknown_backend',
193180
'backend' => $id,
@@ -199,36 +186,14 @@ public static function configure_from_globals(): WP_Markdown_Backend_Capabilitie
199186
return self::$declarations[ $id ];
200187
}
201188

202-
/** Fail bootstrap before wpdb exists when its configured backend is incomplete. */
203-
public static function require_runtime_capabilities( WP_Markdown_Backend_Capabilities $backend, string $mode ): void {
204-
$required = array(
205-
'content_mutation_capture',
206-
'table_mutation_capture',
207-
'schema_persistence',
208-
'lazy_post_content_resolution',
209-
'explicit_flush',
210-
'changed_path_receipts',
211-
);
212-
if ( 'primary' === $mode ) {
213-
$required[] = 'disposable_index_operation';
214-
$required[] = 'cold_reconstruction';
215-
}
216-
foreach ( $required as $capability ) {
217-
$backend->require( $capability );
218-
}
219-
}
220-
221-
/**
222-
* SQLite is the only shipped runtime backend. A supplied declaration is used
223-
* by tests and future backend adapters without coupling feature code to one.
224-
*/
189+
/** Resolve the native capability contract, or an explicitly supplied contract. */
225190
public static function resolve( ?WP_Markdown_Backend_Capabilities $backend = null ): WP_Markdown_Backend_Capabilities {
226191
if ( null !== $backend ) {
227192
return $backend;
228193
}
229194
if ( null !== self::$active_backend ) {
230195
return self::$declarations[ self::$active_backend ];
231196
}
232-
return WP_Markdown_Backend_Capabilities::sqlite();
197+
return WP_Markdown_Backend_Capabilities::mdi_native();
233198
}
234199
}

‎inc/class-wp-markdown-canonical-persistence.php‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ class WP_Markdown_Canonical_Persistence {
5757
*
5858
* Stored as a callable instead of a baked string so callers in boot
5959
* paths where `$table_prefix` is unset at construct time still get
60-
* the canonical prefix at query time. See WP_Markdown_DB::
61-
* boot_connection() for the deferral rationale and issue #77 for
62-
* the underlying boot-order bug.
60+
* the canonical prefix at query time. See issue #77 for the underlying
61+
* boot-order bug.
6362
*
6463
* @var callable
6564
*/
@@ -1539,7 +1538,7 @@ private function remove_inactive_partition_generations( string $directory, strin
15391538
}
15401539

15411540
/**
1542-
* Determine whether a table should be mirrored to disk.
1541+
* Determine whether a table should be persisted to disk.
15431542
*
15441543
* Existing behavior remains the default: core tables and plugin tables are
15451544
* persistent unless a site-level policy explicitly disables a table.
@@ -1831,7 +1830,7 @@ private function update_json_manifest( string $path, int $mtime, int $size ): vo
18311830
try {
18321831
$this->operations->update_manifest( '_tables/' . basename( $path ), $mtime, $size );
18331832
} catch ( \Throwable $e ) {
1834-
// Isolated and non-primary callers may not have the manifest table.
1833+
// Isolated callers may not have the manifest table.
18351834
}
18361835
}
18371836

‎inc/class-wp-markdown-cli.php‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static function register_db_command_boundary(): void {
4646
/** Stop WP-CLI's MySQL-only check before it reads MySQL connection constants. */
4747
public static function guard_db_check( string $command ): string {
4848
$backend = self::database_backend();
49-
if ( defined( 'MARKDOWN_DB_DROPIN' ) && MARKDOWN_DB_DROPIN && 'sqlite' === $backend ) {
49+
if ( defined( 'MARKDOWN_DB_DROPIN' ) && MARKDOWN_DB_DROPIN && 'mdi-native' === $backend ) {
5050
$error = new WP_Markdown_Unsupported_WP_CLI_DB_Command( $backend, 'wp ' . $command );
5151
WP_CLI::error( $error );
5252
throw $error;
@@ -56,13 +56,7 @@ public static function guard_db_check( string $command ): string {
5656
}
5757

5858
private static function database_backend(): string {
59-
if ( defined( 'DB_ENGINE' ) ) {
60-
return strtolower( (string) DB_ENGINE );
61-
}
62-
if ( defined( 'DATABASE_TYPE' ) ) {
63-
return strtolower( (string) DATABASE_TYPE );
64-
}
65-
return defined( 'MARKDOWN_DB_BACKEND' ) ? strtolower( (string) MARKDOWN_DB_BACKEND ) : '';
59+
return defined( 'MARKDOWN_DB_BACKEND' ) ? (string) MARKDOWN_DB_BACKEND : 'mdi-native';
6660
}
6761

6862
/**

0 commit comments

Comments
 (0)