diff options
| author | 2023-10-30 21:10:09 +0100 | |
|---|---|---|
| committer | 2023-10-30 21:10:09 +0100 | |
| commit | 21a279179a5e496082f4e43c5a2a5e10d90c0bdb (patch) | |
| tree | e4cf86f096eba2b2f4b65d53203d06533979d5f4 /app/Models/DatabaseDAO.php | |
| parent | f72a5a43b3a85cc1b4596ed6eb447ac17395eca7 (diff) | |
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
Diffstat (limited to 'app/Models/DatabaseDAO.php')
| -rw-r--r-- | app/Models/DatabaseDAO.php | 15 |
1 files changed, 14 insertions, 1 deletions
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 { |
