diff --git a/.gitignore b/.gitignore index c96bb6c371fa..e129e409c0a4 100644 --- a/.gitignore +++ b/.gitignore @@ -60,11 +60,11 @@ writable/session/* writable/uploads/* !writable/uploads/index.html -writable/data/* -!writable/data/index.html - writable/debugbar/* +writable/*.db +writable/*.sqlite + php_errors.log #------------------------- diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index 5cef2243ad76..92a06558679c 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -85,11 +85,10 @@ public function connect(bool $persistent = false) } try { - $this->database = ($this->database === ':memory:') - ? $this->database - : (strpos($this->database, DIRECTORY_SEPARATOR) === false - ? WRITEPATH . 'data' . DIRECTORY_SEPARATOR . $this->database - : $this->database); + if ($this->database !== ':memory:' && strpos($this->database, DIRECTORY_SEPARATOR) === false) + { + $this->database = WRITEPATH . $this->database; + } return (! $this->password) ? new \SQLite3($this->database) diff --git a/tests/system/Database/Live/SQLite/AlterTableTest.php b/tests/system/Database/Live/SQLite/AlterTableTest.php index 39196ebcae2c..15ebb43e9faa 100644 --- a/tests/system/Database/Live/SQLite/AlterTableTest.php +++ b/tests/system/Database/Live/SQLite/AlterTableTest.php @@ -32,7 +32,7 @@ public function setUp(): void $config = [ 'DBDriver' => 'SQLite3', - 'database' => ':memory:', + 'database' => 'database.db', ]; $this->db = db_connect($config); diff --git a/tests/system/Database/Migrations/MigrationRunnerTest.php b/tests/system/Database/Migrations/MigrationRunnerTest.php index 5f4a65212de0..95dd5fc34c27 100644 --- a/tests/system/Database/Migrations/MigrationRunnerTest.php +++ b/tests/system/Database/Migrations/MigrationRunnerTest.php @@ -37,7 +37,10 @@ public function testLoadsDefaultDatabaseWhenNoneSpecified() $db = $this->getPrivateProperty($runner, 'db'); $this->assertInstanceOf(BaseConnection::class, $db); - $this->assertEquals($dbConfig->tests['database'], $this->getPrivateProperty($db, 'database')); + $this->assertEquals( + ($dbConfig->tests['DBDriver'] === 'SQLite3' ? WRITEPATH : '' ) . $dbConfig->tests['database'], + $this->getPrivateProperty($db, 'database') + ); $this->assertEquals($dbConfig->tests['DBDriver'], $this->getPrivateProperty($db, 'DBDriver')); } diff --git a/tests/travis/Database.php b/tests/travis/Database.php index d497ffb4dace..943e70bc51b1 100644 --- a/tests/travis/Database.php +++ b/tests/travis/Database.php @@ -49,7 +49,7 @@ 'hostname' => 'localhost', 'username' => '', 'password' => '', - 'database' => ':memory:', + 'database' => 'database.db', 'DBDriver' => 'SQLite3', 'DBPrefix' => 'db_', 'pConnect' => false, diff --git a/user_guide_src/source/changelogs/v4.0.4.rst b/user_guide_src/source/changelogs/v4.0.4.rst index c7598516b684..cad8828bbdd0 100644 --- a/user_guide_src/source/changelogs/v4.0.4.rst +++ b/user_guide_src/source/changelogs/v4.0.4.rst @@ -5,11 +5,11 @@ Release Date: Unreleased **4.0.4 release of CodeIgniter4** -The location for the SQLite3 database has changed and by default will be now located in a ``writable/data`` folder instead of the ``public`` folder. +The location for the SQLite3 database has changed and by default will be now located in a ``writable`` folder instead of the ``public`` folder. Enhancements: Bugs Fixed: -- Fixed location for the SQLite3 database which by default will be now located in a ``writable/data`` folder instead of the ``public`` folder. +- Fixed location for the SQLite3 database which by default will be now located in a ``writable`` folder instead of the ``public`` folder. diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 1f43139a8580..7edff86b7ccf 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -38,7 +38,7 @@ prototype:: The name of the class property is the connection name, and can be used while connecting to specify a group name. -.. note:: The default location of the SQLite3 database is in the ``writable/data/`` folder. +.. note:: The default location of the SQLite3 database is in the ``writable`` folder. If you want to change the location, you must set the full path to the new folder. Some database drivers (such as PDO, PostgreSQL, Oracle, ODBC) might diff --git a/writable/data/index.html b/writable/data/index.html deleted file mode 100644 index b702fbc3967b..000000000000 --- a/writable/data/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - 403 Forbidden - - - -

Directory access is forbidden.

- - -