mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
🐛 Fixed importer duplicate detection for posts
closes #8717 - this is now required, because we run import queries sequentiell - this code protects two cases: - you have duplicate slugs in the JSON file (the first get's inserted, the second get's ignored) - you have an existing slug in the database and you try to import the same slug, get's ignored
This commit is contained in:
parent
29e143fa9a
commit
02bd71d0f5
@ -42,6 +42,7 @@ DataImporter = {
|
||||
if (importOptions && importOptions.importPersistUser) {
|
||||
modelOptions.importPersistUser = importOptions.importPersistUser;
|
||||
}
|
||||
|
||||
this.init(importData);
|
||||
|
||||
return models.Base.transaction(function (transacting) {
|
||||
|
@ -774,6 +774,12 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
|
||||
if (!slug) {
|
||||
slug = baseName;
|
||||
}
|
||||
|
||||
// CASE: no slug generation on import, see https://github.com/TryGhost/Ghost/issues/8717
|
||||
if (options.importing) {
|
||||
return slug;
|
||||
}
|
||||
|
||||
// Test for duplicate slugs.
|
||||
return checkIfSlugExists(slug);
|
||||
});
|
||||
|
@ -394,6 +394,8 @@ describe('Import', function () {
|
||||
exportData = exported;
|
||||
return dataImporter.doImport(exportData);
|
||||
}).then(function (importedData) {
|
||||
importedData.data.posts.length.should.eql(1);
|
||||
|
||||
importedData.problems.length.should.eql(3);
|
||||
importedData.problems[0].message.should.eql('Entry was not imported and ignored. Detected duplicated entry.');
|
||||
importedData.problems[0].help.should.eql('Tag');
|
||||
|
Loading…
Reference in New Issue
Block a user