1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Work around possible MySQL bug

This commit is contained in:
J. King 2022-04-25 09:56:13 -04:00
parent 2acacd2647
commit e6505a5fda
4 changed files with 12 additions and 10 deletions

View file

@ -1,3 +1,9 @@
Version 0.1?.? (2022-??-??)
===========================
Bug fixes:
- Perform MySQL table maintenance more reliably
Version 0.10.2 (2022-04-04) Version 0.10.2 (2022-04-04)
=========================== ===========================

View file

@ -224,7 +224,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
public function maintenance(): bool { public function maintenance(): bool {
// with MySQL each table must be analyzed separately, so we first have to get a list of tables // with MySQL each table must be analyzed separately, so we first have to get a list of tables
foreach ($this->query("SHOW TABLES like 'arsse\\_%'") as $table) { foreach ($this->query("SHOW TABLES like 'arsse%'") as $table) {
$table = array_pop($table); $table = array_pop($table);
if (!preg_match("/^arsse_[a-z_]+$/D", $table)) { if (!preg_match("/^arsse_[a-z_]+$/D", $table)) {
// table is not one of ours // table is not one of ours

View file

@ -283,12 +283,8 @@ class ValueInfo {
} }
return $out->setTimezone(new \DateTimeZone("UTC")); return $out->setTimezone(new \DateTimeZone("UTC"));
} else { } else {
$out = new \DateTimeImmutable($value, new \DateTimeZone("UTC")); // if the string fails to parse it will produce an exception which is caught just below
if ($out) { return (new \DateTimeImmutable($value, new \DateTimeZone("UTC")))->setTimezone(new \DateTimeZone("UTC"));
return $out->setTimezone(new \DateTimeZone("UTC"));
} elseif ($strict && !$drop) {
throw new \Exception;
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
if ($strict && !$drop) { if ($strict && !$drop) {

View file

@ -600,7 +600,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[[], null, null, null, null, null, null, null, null, null, null, null], [[], null, null, null, null, null, null, null, null, null, null, null],
[$this->i("P1Y2D"), null, null, null, null, null, null, null, null, null, null, null], [$this->i("P1Y2D"), null, null, null, null, null, null, null, null, null, null, null],
["P1Y2D", null, null, null, null, null, null, null, null, null, null, null], ["P1Y2D", null, null, null, null, null, null, null, null, null, null, null],
] as $set) { ] as $k => $set) {
// shift the input value off the set // shift the input value off the set
$input = array_shift($set); $input = array_shift($set);
// generate a set of tests for each target date formats // generate a set of tests for each target date formats
@ -612,7 +612,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[false, true], [false, true],
[true, true], [true, true],
] as [$strict, $drop]) { ] as [$strict, $drop]) {
yield [$input, $formats[$format], $exp, $strict, $drop]; yield "Index #$k format \"$format\" strict:$strict drop:$drop" => [$input, $formats[$format], $exp, $strict, $drop];
} }
} }
} }