diff options
| author | 2021-03-24 19:04:51 +0100 | |
|---|---|---|
| committer | 2021-03-24 19:04:51 +0100 | |
| commit | de40f3ad56b99b6128e8d9d207f5c5304ae97393 (patch) | |
| tree | 7755eac081f32ba87445ec82a2a740ea4a1865eb /app/Models | |
| parent | 06fa51448336d8ad95d70e7cd96e4c3f4e30907a (diff) | |
Fix TT-RSS import (#3553)
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/DatabaseDAO.php | 5 | ||||
| -rw-r--r-- | app/Models/EntryDAO.php | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index 4bda44268..86f72b14c 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -10,6 +10,11 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { const ER_BAD_TABLE_ERROR = '42S02'; const ER_DATA_TOO_LONG = '1406'; + /** + * Based on SQLite SQLITE_MAX_VARIABLE_NUMBER + */ + const MAX_VARIABLE_NUMBER = 998; + //MySQL InnoDB maximum index length for UTF8MB4 //https://dev.mysql.com/doc/refman/8.0/en/innodb-restrictions.html const LENGTH_INDEX_UNICODE = 191; diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index c641878ad..9ed1d564d 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -989,8 +989,16 @@ SQL; } public function listHashForFeedGuids($id_feed, $guids) { + $result = []; if (count($guids) < 1) { - return array(); + return $result; + } elseif (count($guids) > FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER) { + // Split a query with too many variables parameters + $guidsChunks = array_chunk($guids, FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER, true); + foreach ($guidsChunks as $guidsChunk) { + $result += $this->listHashForFeedGuids($id_feed, $guidsChunk); + } + return $result; } $guids = array_unique($guids); $sql = 'SELECT guid, ' . $this->sqlHexEncode('hash') . @@ -999,7 +1007,6 @@ SQL; $values = array($id_feed); $values = array_merge($values, $guids); if ($stm && $stm->execute($values)) { - $result = array(); $rows = $stm->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $result[$row['guid']] = $row['hex_hash']; |
