From 21a279179a5e496082f4e43c5a2a5e10d90c0bdb Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 30 Oct 2023 21:10:09 +0100 Subject: Ready for year 2038 (#5570) * Ready for year 2038 Fix https://github.com/FreshRSS/FreshRSS/discussions/5569 Requires PHP on a 64-bit platform to take advantage of it. https://en.wikipedia.org/wiki/Year_2038_problem * Allows dates past 2038 Rework of https://github.com/FreshRSS/FreshRSS/pull/3259 https://github.com/FreshRSS/FreshRSS/issues/3258 * Auto alter columns * Changelog --- app/Models/DatabaseDAO.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'app/Models/DatabaseDAO.php') diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index f9d2859e8..45fc1967c 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -20,7 +20,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { public const LENGTH_INDEX_UNICODE = 191; public function create(): string { - require(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'); + require_once(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'); $db = FreshRSS_Context::$system_conf->db; try { @@ -214,9 +214,22 @@ SQL; return $ok; } + private function ensureYear2038Compatible(): bool { + if ($this->pdo->dbType() !== 'sqlite') { + include_once(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'); + if ($this->pdo->exec($GLOBALS['SQL_UPDATE_YEAR_2038']) === false) { //FreshRSS 1.23 + Minz_Log::error('SQL error ' . __METHOD__ . json_encode($this->pdo->errorInfo())); + return false; + } + } + return true; + } + public function minorDbMaintenance(): void { $catDAO = FreshRSS_Factory::createCategoryDao(); $catDAO->resetDefaultCategoryName(); + + $this->ensureYear2038Compatible(); } private static function stdError(string $error): bool { -- cgit v1.2.3