Browse Source

Fix MySQL failure and shore up coverage

This marks the end of the feed reduplication effort
redup
J. King 1 year ago
parent
commit
bbdc4f7672
  1. 2
      lib/AbstractException.php
  2. 23
      lib/Database.php
  3. 2
      locale/en.php
  4. 2
      tests/cases/Database/SeriesArticle.php
  5. 1
      tests/cases/Misc/TestValueInfo.php

2
lib/AbstractException.php

@ -38,7 +38,7 @@ abstract class AbstractException extends \Exception {
"Db/Exception.updateFileUnreadable" => 10216,
"Db/Exception.updateFileError" => 10217,
"Db/Exception.updateFileIncomplete" => 10218,
"Db/Exception.updateSchemaChange" => 10219,
"Db/Exception.updateSchemaDowngrade" => 10219,
"Db/Exception.paramTypeInvalid" => 10221,
"Db/Exception.paramTypeUnknown" => 10222,
"Db/Exception.paramTypeMissing" => 10223,

23
lib/Database.php

@ -84,8 +84,9 @@ class Database {
if ($initialize) {
if ($ver < self::SCHEMA_VERSION) {
$this->db->schemaUpdate(self::SCHEMA_VERSION);
} elseif ($ver != self::SCHEMA_VERSION) {
throw new Db\Exception("updateSchemaChange");
} elseif ($ver != self::SCHEMA_VERSION) {// @codeCoverageIgnore
// This will only occur if an old version of the software is used with a newer database schema
throw new Db\Exception("updateSchemaDowngrade"); // @codeCoverageIgnore
}
}
}
@ -1151,7 +1152,6 @@ class Database {
try {
$keep = Rule::prep($sub['keep']);
$block = Rule::prep($sub['block']);
$feed = $sub['id'];
} catch (RuleException $e) { // @codeCoverageIgnore
// invalid rules should not normally appear in the database, but it's possible
// in this case we should halt evaluation and just leave things as they are
@ -1277,13 +1277,17 @@ class Database {
// prepare the keep and block rules
try {
$keep = Rule::prep($f['keep_rule'] ?? "");
} catch (RuleException $e) {
$keep = "";
} catch (RuleException $e) { // @codeCoverageIgnore
// invalid rules should not normally appear in the database, but it's possible
// in this case we act as if the rule were not defined
$keep = ""; // @codeCoverageIgnore
}
try {
$block = Rule::prep($f['block_rule'] ?? "");
} catch (RuleException $e) {
$block = "";
} catch (RuleException $e) { // @codeCoverageIgnore
// invalid rules should not normally appear in the database, but it's possible
// in this case we act as if the rule were not defined
$block = ""; // @codeCoverageIgnore
}
// determine if the feed icon needs to be updated, and update it if appropriate
$tr = $this->db->begin();
@ -2473,10 +2477,13 @@ class Database {
* @param boolean $includeEmpty Whether to include (true) or supress (false) tags which have no subscriptions assigned to them
*/
public function tagList(string $user, bool $includeEmpty = true): Db\Result {
$integerType = $this->db->sqlToken("integer");
return $this->db->prepareArray(
"SELECT * FROM (
SELECT
id,name,coalesce(subscriptions,0) as subscriptions
id,
name,
cast(coalesce(subscriptions,0) as $integerType) as subscriptions -- this cast is required for MySQL for unclear reasons
from arsse_tags
left join (
SELECT

2
locale/en.php

@ -147,7 +147,7 @@ return [
0 {Automatic updating of the {driver_name} database failed because it is already up to date with the requested version, {target}}
other {Automatic updating of the {driver_name} database failed because its version, {current}, is newer than the requested version, {target}}
}',
'Exception.JKingWeb/Arsse/Db/Exception.updateSchemaChange' => 'Database schema version is newer than the application schema version',
'Exception.JKingWeb/Arsse/Db/Exception.updateSchemaDowngrade' => 'Database schema version is newer than the application schema version',
'Exception.JKingWeb/Arsse/Db/Exception.engineErrorGeneral' => '{0}',
// indicates programming error
'Exception.JKingWeb/Arsse/Db/Exception.savepointStatusUnknown' => 'Savepoint status code {0} not implemented',

2
tests/cases/Database/SeriesArticle.php

@ -815,7 +815,7 @@ trait SeriesArticle {
}
public function testMarkMultipleMissingEditions(): void {
$this->assertSame(0, Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([500,501])));
$this->assertSame(0, Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([56458, 1851855])));
$state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state);
}

1
tests/cases/Misc/TestValueInfo.php

@ -531,6 +531,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[$this->i("P2DT1H"), [null,true], [true, false], [(48 + 1) * 60 * 60, false], [1.0 * (48 + 1) * 60 * 60, false], ["P2DT1H", true], [[$this->i("P2DT1H")], false], [$this->i("P2DT1H"), true]],
[$this->i("PT0H"), [null,true], [true, false], [0, false], [0.0, false], ["PT0S", true], [[$this->i("PT0H")], false], [$this->i("PT0H"), true]],
[$dateDiff, [null,true], [true, false], [366 * 24 * 60 * 60, false], [1.0 * 366 * 24 * 60 * 60, false], ["P366D", true], [[$dateDiff], false], [$dateNorm, true]],
["1 year, 2 days", [null,true], [true, false], [0, false], [0.0, false], ["1 year, 2 days", true], [["1 year, 2 days"], false], [\DateInterval::createFromDateString("1 year, 2 days"), false]],
["P1Y2D", [null,true], [true, false], [0, false], [0.0, false], ["P1Y2D", true], [["P1Y2D"], false], [$this->i("P1Y2D"), true]],
] as $set) {
// shift the input value off the set

Loading…
Cancel
Save