File tree 1 file changed +17
-2
lines changed
1 file changed +17
-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
+ $ db_name = defined ( 'DB_NAME ' ) ? DB_NAME : 'wordpress ' ;
65
+
53
66
/*
54
67
* Debug: Cross-check with MySQL.
55
68
* This is for debugging purpose only and requires files
59
72
$ crosscheck_tests_file_path = dirname ( __DIR__ , 2 ) . '/tests/class-wp-sqlite-crosscheck-db.php ' ;
60
73
if ( defined ( 'SQLITE_DEBUG_CROSSCHECK ' ) && SQLITE_DEBUG_CROSSCHECK && file_exists ( $ crosscheck_tests_file_path ) ) {
61
74
require_once $ crosscheck_tests_file_path ;
62
- $ GLOBALS ['wpdb ' ] = new WP_SQLite_Crosscheck_DB ( DB_NAME );
75
+ $ GLOBALS ['wpdb ' ] = new WP_SQLite_Crosscheck_DB ( $ db_name );
63
76
} else {
64
- $ GLOBALS ['wpdb ' ] = new WP_SQLite_DB ( DB_NAME );
77
+ $ GLOBALS ['wpdb ' ] = new WP_SQLite_DB ( $ db_name );
65
78
}
79
+
80
+ unset( $ db_name );
You can’t perform that action at this time.
0 commit comments