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();
|
PatchedContent patchedContent = post.getContentOfNullable();
|
||||||
if (patchedContent == null) {
|
if (patchedContent == null) {
|
||||||
Content postContent = contentService.getById(post.getId());
|
Content postContent = contentService.getByIdOfNullable(post.getId());
|
||||||
|
if (postContent != null) {
|
||||||
postVo.setSummary(generateSummary(postContent.getContent()));
|
postVo.setSummary(generateSummary(postContent.getContent()));
|
||||||
|
} else {
|
||||||
|
postVo.setSummary(StringUtils.EMPTY);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
postVo.setSummary(generateSummary(patchedContent.getContent()));
|
postVo.setSummary(generateSummary(patchedContent.getContent()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,6 +518,7 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
||||||
log.debug("Removed post content: [{}]", postContent);
|
log.debug("Removed post content: [{}]", postContent);
|
||||||
|
|
||||||
Post deletedPost = super.removeById(postId);
|
Post deletedPost = super.removeById(postId);
|
||||||
|
deletedPost.setContent(PatchedContent.of(postContent));
|
||||||
|
|
||||||
// Log it
|
// Log it
|
||||||
eventPublisher.publishEvent(new LogEvent(this, postId.toString(), LogType.POST_DELETED,
|
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);
|
log.debug("Removed sheet content: [{}]", sheetContent);
|
||||||
|
|
||||||
Sheet sheet = super.removeById(id);
|
Sheet sheet = super.removeById(id);
|
||||||
|
sheet.setContent(PatchedContent.of(sheetContent));
|
||||||
|
|
||||||
// Log it
|
// Log it
|
||||||
eventPublisher.publishEvent(
|
eventPublisher.publishEvent(
|
||||||
|
|
Loading…
Reference in New Issue