File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 50
50
require_once __DIR__ . '/class-wp-sqlite-db.php ' ;
51
51
require_once __DIR__ . '/install-functions.php ' ;
52
52
53
+ /*
54
+ * Fallback to a default database name if "DB_NAME" is not defined.
55
+ *
56
+ * This can happen when importing a WordPress backup that doesn't include the
57
+ * "DB_NAME" constant definition.
58
+ *
59
+ * TODO: Remove this once addressed in WordPress Playground, which is a more
60
+ * appropriate place to fix this. In the SQLite integration plugin, it is
61
+ * better to require the "DB_NAME" constant to be defined to avoid issues
62
+ * such as storing an incorrect database name in the information schema.
63
+ */
64
+ // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledInText
65
+ $ db_name = defined ( 'DB_NAME ' ) ? DB_NAME : 'wordpress ' ;
66
+
53
67
/*
54
68
* Debug: Cross-check with MySQL.
55
69
* This is for debugging purpose only and requires files
59
73
$ crosscheck_tests_file_path = dirname ( __DIR__ , 2 ) . '/tests/class-wp-sqlite-crosscheck-db.php ' ;
60
74
if ( defined ( 'SQLITE_DEBUG_CROSSCHECK ' ) && SQLITE_DEBUG_CROSSCHECK && file_exists ( $ crosscheck_tests_file_path ) ) {
61
75
require_once $ crosscheck_tests_file_path ;
62
- $ GLOBALS ['wpdb ' ] = new WP_SQLite_Crosscheck_DB ( DB_NAME );
76
+ $ GLOBALS ['wpdb ' ] = new WP_SQLite_Crosscheck_DB ( $ db_name );
63
77
} else {
64
- $ GLOBALS ['wpdb ' ] = new WP_SQLite_DB ( DB_NAME );
78
+ $ GLOBALS ['wpdb ' ] = new WP_SQLite_DB ( $ db_name );
65
79
}
80
+
81
+ unset( $ db_name );
You can’t perform that action at this time.
0 commit comments