mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Fix more bugs
This commit is contained in:
parent
568b12600b
commit
19ab9df063
5 changed files with 30 additions and 1 deletions
|
@ -3,6 +3,8 @@ Version 0.9.2 (2021-??-??)
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
- Do not fail adding users to an empty database (regression since 0.9.0)
|
- Do not fail adding users to an empty database (regression since 0.9.0)
|
||||||
|
- Cleanly ignore unknown configuration properties
|
||||||
|
- Set access mode to rw-r---- when creating SQLite databases
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
- Packages for Arch Linux are now available (see manual for details)
|
- Packages for Arch Linux are now available (see manual for details)
|
||||||
|
|
|
@ -265,7 +265,7 @@ class Conf {
|
||||||
protected function propertyImport(string $key, $value, string $file = "") {
|
protected function propertyImport(string $key, $value, string $file = "") {
|
||||||
$typeName = $this->types[$key]['name'] ?? "mixed";
|
$typeName = $this->types[$key]['name'] ?? "mixed";
|
||||||
$typeConst = $this->types[$key]['const'] ?? Value::T_MIXED;
|
$typeConst = $this->types[$key]['const'] ?? Value::T_MIXED;
|
||||||
$nullable = (int) (bool) ($this->types[$key]['const'] & Value::M_NULL);
|
$nullable = (int) (bool) ($typeConst & Value::M_NULL);
|
||||||
try {
|
try {
|
||||||
if ($typeName === "\\DateInterval") {
|
if ($typeName === "\\DateInterval") {
|
||||||
// date intervals have special handling: if the existing value (ultimately, the default value)
|
// date intervals have special handling: if the existing value (ultimately, the default value)
|
||||||
|
|
|
@ -31,6 +31,12 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
||||||
$dbKey = Arsse::$conf->dbSQLite3Key;
|
$dbKey = Arsse::$conf->dbSQLite3Key;
|
||||||
$timeout = Arsse::$conf->dbSQLite3Timeout * 1000;
|
$timeout = Arsse::$conf->dbSQLite3Timeout * 1000;
|
||||||
try {
|
try {
|
||||||
|
// check whether the file exists; if it doesn't create the file and set its mode to rw-r-----
|
||||||
|
if ($dbFile !== ":memory:" && !file_exists($dbFile)) {
|
||||||
|
if (@touch($dbFile)) {
|
||||||
|
chmod($dbFile, 0640);
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->makeConnection($dbFile, $dbKey);
|
$this->makeConnection($dbFile, $dbKey);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
// if opening the database doesn't work, check various pre-conditions to find out what the problem might be
|
// if opening the database doesn't work, check various pre-conditions to find out what the problem might be
|
||||||
|
|
|
@ -108,6 +108,14 @@ class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$conf->import($arr);
|
$conf->import($arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportCustomProperty(): void {
|
||||||
|
$arr = [
|
||||||
|
'customProperty' => "I'm special!",
|
||||||
|
];
|
||||||
|
$conf = new Conf;
|
||||||
|
$this->assertSame($conf, $conf->import($arr));
|
||||||
|
}
|
||||||
|
|
||||||
public function testImportBogusDriver(): void {
|
public function testImportBogusDriver(): void {
|
||||||
$arr = [
|
$arr = [
|
||||||
'dbDriver' => "this driver does not exist",
|
'dbDriver' => "this driver does not exist",
|
||||||
|
|
|
@ -185,4 +185,17 @@ class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$this->assertException("fileCorrupt", "Db");
|
$this->assertException("fileCorrupt", "Db");
|
||||||
new Driver;
|
new Driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetFileMode(): void {
|
||||||
|
$f = tempnam(sys_get_temp_dir(), "arsse");
|
||||||
|
Arsse::$conf->dbSQLite3File = $f;
|
||||||
|
// delete the file PHP just created
|
||||||
|
unlink($f);
|
||||||
|
// recreate the file
|
||||||
|
new Driver;
|
||||||
|
// check the mode
|
||||||
|
clearstatcache();
|
||||||
|
$mode = base_convert((string) stat($f)['mode'], 10, 8);
|
||||||
|
$this->assertMatchesRegularExpression("/640$/", $mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue