1
1
Fork 0
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:
J. King 2021-05-18 18:42:42 -04:00
parent 568b12600b
commit 19ab9df063
5 changed files with 30 additions and 1 deletions

View file

@ -3,6 +3,8 @@ Version 0.9.2 (2021-??-??)
Bug fixes:
- 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:
- Packages for Arch Linux are now available (see manual for details)

View file

@ -265,7 +265,7 @@ class Conf {
protected function propertyImport(string $key, $value, string $file = "") {
$typeName = $this->types[$key]['name'] ?? "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 {
if ($typeName === "\\DateInterval") {
// date intervals have special handling: if the existing value (ultimately, the default value)

View file

@ -31,6 +31,12 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
$dbKey = Arsse::$conf->dbSQLite3Key;
$timeout = Arsse::$conf->dbSQLite3Timeout * 1000;
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);
} catch (\Throwable $e) {
// if opening the database doesn't work, check various pre-conditions to find out what the problem might be

View file

@ -108,6 +108,14 @@ class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
$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 {
$arr = [
'dbDriver' => "this driver does not exist",

View file

@ -185,4 +185,17 @@ class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertException("fileCorrupt", "Db");
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);
}
}