mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: #11519, clear parent cache all the way to root
This commit is contained in:
@@ -95,11 +95,9 @@ module.exports = function (Categories) {
|
|||||||
await privileges.categories.give(result.modPrivileges, category.cid, ['administrators', 'Global Moderators']);
|
await privileges.categories.give(result.modPrivileges, category.cid, ['administrators', 'Global Moderators']);
|
||||||
await privileges.categories.give(result.guestPrivileges, category.cid, ['guests', 'spiders']);
|
await privileges.categories.give(result.guestPrivileges, category.cid, ['guests', 'spiders']);
|
||||||
|
|
||||||
cache.del([
|
cache.del('categories:cid');
|
||||||
'categories:cid',
|
await clearParentCategoryCache(parentCid);
|
||||||
`cid:${parentCid}:children`,
|
|
||||||
`cid:${parentCid}:children:all`,
|
|
||||||
]);
|
|
||||||
if (data.cloneFromCid && parseInt(data.cloneFromCid, 10)) {
|
if (data.cloneFromCid && parseInt(data.cloneFromCid, 10)) {
|
||||||
category = await Categories.copySettingsFrom(data.cloneFromCid, category.cid, !data.parentCid);
|
category = await Categories.copySettingsFrom(data.cloneFromCid, category.cid, !data.parentCid);
|
||||||
}
|
}
|
||||||
@@ -112,6 +110,22 @@ module.exports = function (Categories) {
|
|||||||
return category;
|
return category;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function clearParentCategoryCache(parentCid) {
|
||||||
|
while (parseInt(parentCid, 10) >= 0) {
|
||||||
|
cache.del([
|
||||||
|
`cid:${parentCid}:children`,
|
||||||
|
`cid:${parentCid}:children:all`,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (parseInt(parentCid, 10) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// clear all the way to root
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
parentCid = await Categories.getCategoryField(parentCid, 'parentCid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function duplicateCategoriesChildren(parentCid, cid, uid) {
|
async function duplicateCategoriesChildren(parentCid, cid, uid) {
|
||||||
let children = await Categories.getChildren([cid], uid);
|
let children = await Categories.getChildren([cid], uid);
|
||||||
if (!children.length) {
|
if (!children.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user