From 38932ee3bb3ccd41c0e2d79329e2d77fb5995256 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 5 Oct 2019 10:37:15 +0200 Subject: MySQL entry content MEDIUMBLOB (#2551) Fix https://github.com/FreshRSS/FreshRSS/issues/2448 --- app/Models/EntryDAO.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'app/Models/EntryDAO.php') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 6e5d00a93..b7ce89094 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -38,6 +38,25 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $ok; } + private function updateToMediumBlob() { + if ($this->pdo->dbType() !== 'mysql') { + return false; + } + Minz_Log::warning('Update MySQL table to use MEDIUMBLOB...'); + + $sql = <<<'SQL' +ALTER TABLE `_entry` MODIFY `content_bin` MEDIUMBLOB; +ALTER TABLE `_entrytmp` MODIFY `content_bin` MEDIUMBLOB; +SQL; + try { + $ok = $this->pdo->exec($sql) !== false; + } catch (Exception $e) { + $ok = false; + Minz_Log::error(__method__ . ' error: ' . $e->getMessage()); + } + return $ok; + } + //TODO: Move the database auto-updates to DatabaseDAO protected function autoUpdateDb($errorInfo) { if (isset($errorInfo[0])) { @@ -50,6 +69,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { } } } + if (isset($errorInfo[1])) { + if ($errorInfo[1] == FreshRSS_DatabaseDAO::ER_DATA_TOO_LONG) { + if (stripos($errorInfo[2], 'content_bin') !== false) { + return $this->updateToMediumBlob(); //v1.15.0 + } + } + } return false; } -- cgit v1.2.3