CategoryDAOSQLite.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. declare(strict_types=1);
  3. class FreshRSS_CategoryDAOSQLite extends FreshRSS_CategoryDAO {
  4. #[\Override]
  5. public function sqlResetSequence(): bool {
  6. return true; // Nothing to do for SQLite
  7. }
  8. /** @param array{0:string,1:int,2:string} $errorInfo */
  9. #[\Override]
  10. protected function autoUpdateDb(array $errorInfo): bool {
  11. if (isset($errorInfo[0])) {
  12. $errorLines = explode("\n", $errorInfo[2], 2); // The relevant column name is on the first line, other lines are noise
  13. if (str_contains($errorLines[0], 'f.')) { // Coming from a feed sub-query
  14. $feedDao = FreshRSS_Factory::createFeedDao();
  15. if ($feedDao->autoUpdateDb($errorInfo)) {
  16. return true;
  17. }
  18. }
  19. }
  20. if (($tableInfo = $this->pdo->query("PRAGMA table_info('category')")) !== false) {
  21. $columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
  22. foreach (['kind', 'lastUpdate', 'error', 'attributes'] as $column) {
  23. if (!in_array($column, $columns, true)) {
  24. return $this->addColumn($column);
  25. }
  26. }
  27. }
  28. return false;
  29. }
  30. }