mirror of https://github.com/halo-dev/halo
fix: Content not found exception when empty sheet deleted (#1715)
parent
03006e8f35
commit
f43fa562d7
|
@ -179,8 +179,12 @@ public class BasePostAssembler<POST extends BasePost> {
|
|||
|
||||
PatchedContent patchedContent = post.getContentOfNullable();
|
||||
if (patchedContent == null) {
|
||||
Content postContent = contentService.getById(post.getId());
|
||||
postVo.setSummary(generateSummary(postContent.getContent()));
|
||||
Content postContent = contentService.getByIdOfNullable(post.getId());
|
||||
if (postContent != null) {
|
||||
postVo.setSummary(generateSummary(postContent.getContent()));
|
||||
} else {
|
||||
postVo.setSummary(StringUtils.EMPTY);
|
||||
}
|
||||
} else {
|
||||
postVo.setSummary(generateSummary(patchedContent.getContent()));
|
||||
}
|
||||
|
|
|
@ -518,6 +518,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
log.debug("Removed post content: [{}]", postContent);
|
||||
|
||||
Post deletedPost = super.removeById(postId);
|
||||
deletedPost.setContent(PatchedContent.of(postContent));
|
||||
|
||||
// Log it
|
||||
eventPublisher.publishEvent(new LogEvent(this, postId.toString(), LogType.POST_DELETED,
|
||||
|
|
|
@ -275,6 +275,7 @@ public class SheetServiceImpl extends BasePostServiceImpl<Sheet>
|
|||
log.debug("Removed sheet content: [{}]", sheetContent);
|
||||
|
||||
Sheet sheet = super.removeById(id);
|
||||
sheet.setContent(PatchedContent.of(sheetContent));
|
||||
|
||||
// Log it
|
||||
eventPublisher.publishEvent(
|
||||
|
|
Loading…
Reference in New Issue