|
|
@@ -18,6 +18,7 @@ import {
|
|
|
} from '~/server/models';
|
|
|
import type { PageDocument, PageModel } from '~/server/models/page';
|
|
|
import { preNotifyService } from '~/server/service/pre-notify';
|
|
|
+import { normalizeLatestRevisionIfBroken } from '~/server/service/revision/normalize-latest-revision-if-broken';
|
|
|
import { getYjsService } from '~/server/service/yjs';
|
|
|
import { generalXssFilter } from '~/services/general-xss-filter';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
@@ -132,6 +133,16 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
|
|
|
// check revision
|
|
|
const currentPage = await Page.findByIdAndViewer(pageId, req.user);
|
|
|
|
|
|
+ if (currentPage != null) {
|
|
|
+ // Normalize the latest revision which was borken by the migration script '20211227060705-revision-path-to-page-id-schema-migration--fixed-7549.js'
|
|
|
+ try {
|
|
|
+ await normalizeLatestRevisionIfBroken(pageId);
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error('Error occurred in normalizing the latest revision');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (currentPage != null && !await currentPage.isUpdatable(sanitizeRevisionId, origin)) {
|
|
|
const latestRevision = await Revision.findById(currentPage.revision).populate('author');
|
|
|
const returnLatestRevision = {
|