aboutsummaryrefslogtreecommitdiff
path: root/app/Models/DatabaseDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-09-27 15:11:55 +0200
committerGravatar GitHub <noreply@github.com> 2025-09-27 15:11:55 +0200
commit5e8c964f6cc735c49e686022700144307e903dd1 (patch)
tree2b288fb84b316c1fda90759f4e1e921b508ad1c2 /app/Models/DatabaseDAO.php
parentfdbdd118bfd48332443af83e29a34396595f2668 (diff)
Stable IDs during SQL import (#7988)
* Stable IDs during SQL import Follow-up of https://github.com/FreshRSS/FreshRSS/pull/7949 Make sure that the original category IDs, feed IDs, and label IDs are kept identical during an SQL import. Avoid breaking everything referring to categories, feeds, labels by their IDs such as searches and third-party extensions. * Fix export of default category
Diffstat (limited to 'app/Models/DatabaseDAO.php')
-rw-r--r--app/Models/DatabaseDAO.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php
index a33d38e76..3cd76ea0a 100644
--- a/app/Models/DatabaseDAO.php
+++ b/app/Models/DatabaseDAO.php
@@ -409,19 +409,17 @@ SQL;
$userTo->createUser();
$catTo->beginTransaction();
+ $catTo->deleteCategory(FreshRSS_CategoryDAO::DEFAULTCATEGORYID);
+ $catTo->sqlResetSequence();
foreach ($catFrom->selectAll() as $category) {
- $cat = $catTo->searchByName($category['name']); //Useful for the default category
- if ($cat != null) {
- $catId = $cat->id();
- } else {
- $catId = $catTo->addCategory($category);
- if ($catId == false) {
- $error = 'Error during SQLite copy of categories!';
- return self::stdError($error);
- }
+ $catId = $catTo->addCategory($category);
+ if ($catId === false) {
+ $error = 'Error during SQLite copy of categories!';
+ return self::stdError($error);
}
$idMaps['c' . $category['id']] = $catId;
}
+ $catTo->sqlResetSequence();
foreach ($feedFrom->selectAll() as $feed) {
$feed['category'] = empty($idMaps['c' . $feed['category']]) ? FreshRSS_CategoryDAO::DEFAULTCATEGORYID : $idMaps['c' . $feed['category']];
$feedId = $feedTo->addFeed($feed);
@@ -431,6 +429,7 @@ SQL;
}
$idMaps['f' . $feed['id']] = $feedId;
}
+ $feedTo->sqlResetSequence();
$catTo->commit();
$nbEntries = $entryFrom->count();
@@ -483,6 +482,7 @@ SQL;
}
}
}
+ $tagTo->sqlResetSequence();
$tagTo->commit();
return true;