|
13 | 13 | } |
14 | 14 |
|
15 | 15 | /** |
16 | | - * Notice: |
17 | | - * Your scripts have the permission to create directories or files on your server. |
18 | | - * If you write in your wp-config.php like below, we take these definitions. |
19 | | - * define('DB_DIR', '/full_path_to_the_database_directory/'); |
20 | | - * define('DB_FILE', 'database_file_name'); |
| 16 | + * DB_PATH is the absolute database file path, or ":memory:" for an in-memory database. |
| 17 | + * |
| 18 | + * Cannot be combined with explicit DB_DIR, DB_FILE, FQDBDIR, or FQDB definitions. |
| 19 | + * The database directory is also used for storage locks and must be writable by PHP. |
| 20 | + * When not configured, the drop-in defines DB_PATH after initializing the storage. |
| 21 | + * |
| 22 | + * Example: define( 'DB_PATH', '/private/wordpress/database.sqlite' ); |
| 23 | + */ |
| 24 | +if ( 'sqlite' === DB_ENGINE && defined( 'DB_PATH' ) ) { |
| 25 | + if ( defined( 'DB_DIR' ) || defined( 'DB_FILE' ) || defined( 'FQDBDIR' ) || defined( 'FQDB' ) ) { |
| 26 | + throw new RuntimeException( 'DB_PATH cannot be combined with DB_DIR, DB_FILE, FQDBDIR, or FQDB. Remove the legacy definitions.' ); |
| 27 | + } |
| 28 | + |
| 29 | + if ( ! is_string( DB_PATH ) ) { |
| 30 | + throw new RuntimeException( 'DB_PATH must be a string.' ); |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | + * DB_DIR selects the database directory when DB_PATH is not configured. |
| 36 | + * Must not be configured together with DB_PATH. |
| 37 | + * |
| 38 | + * @deprecated 3.1.0 Define DB_PATH instead. |
| 39 | + */ |
| 40 | + |
| 41 | +/** |
| 42 | + * DB_FILE selects a filename inside DB_DIR or FQDBDIR. |
| 43 | + * Must not be configured together with DB_PATH. |
| 44 | + * |
| 45 | + * @deprecated 3.1.0 Define DB_PATH instead. |
21 | 46 | */ |
22 | 47 |
|
23 | 48 | /** |
24 | 49 | * FQDBDIR is a directory where the sqlite database file is placed. |
25 | | - * If DB_DIR is defined, it is used as FQDBDIR. |
| 50 | + * Defaults to the directory containing DB_PATH, or the legacy directory setting. |
| 51 | + * Must not be configured together with DB_PATH. |
26 | 52 | * |
27 | | - * @deprecated 3.0.0 Define DB_DIR instead of overriding FQDBDIR. |
| 53 | + * @deprecated 3.0.0 Define DB_PATH instead of overriding FQDBDIR. |
28 | 54 | */ |
29 | 55 | if ( ! defined( 'FQDBDIR' ) ) { |
30 | | - if ( defined( 'DB_DIR' ) ) { |
| 56 | + if ( defined( 'DB_PATH' ) && is_string( DB_PATH ) ) { |
| 57 | + define( 'FQDBDIR', rtrim( dirname( DB_PATH ), '/\\' ) . '/' ); |
| 58 | + } elseif ( defined( 'DB_DIR' ) ) { |
31 | 59 | define( 'FQDBDIR', rtrim( DB_DIR, '/\\' ) . '/' ); |
32 | 60 | } elseif ( defined( 'WP_CONTENT_DIR' ) ) { |
33 | 61 | define( 'FQDBDIR', WP_CONTENT_DIR . '/database/' ); |
|
39 | 67 | /** |
40 | 68 | * FQDB is the absolute path to the SQLite database file. |
41 | 69 | * |
42 | | - * If DB_FILE is defined, FQDB is defined here using FQDBDIR. When SQLite is |
43 | | - * used without DB_FILE, managed storage defines FQDB after resolving the |
44 | | - * randomized database path. |
| 70 | + * Defaults to DB_PATH, or FQDBDIR combined with DB_FILE. For managed storage, |
| 71 | + * the drop-in defines FQDB after resolving the randomized database path. |
| 72 | + * Must not be configured together with DB_PATH. |
45 | 73 | * |
46 | | - * @deprecated 3.0.0 Define DB_DIR and DB_FILE instead of overriding FQDB. |
| 74 | + * @deprecated 3.0.0 Define DB_PATH instead of overriding FQDB. |
47 | 75 | */ |
48 | | -if ( ! defined( 'FQDB' ) && defined( 'DB_FILE' ) ) { |
49 | | - define( 'FQDB', FQDBDIR . DB_FILE ); |
| 76 | +if ( ! defined( 'FQDB' ) ) { |
| 77 | + if ( defined( 'DB_PATH' ) ) { |
| 78 | + define( 'FQDB', DB_PATH ); |
| 79 | + } elseif ( defined( 'DB_FILE' ) ) { |
| 80 | + define( 'FQDB', FQDBDIR . DB_FILE ); |
| 81 | + } |
50 | 82 | } |
0 commit comments