Skip to content

Commit 76f92d2

Browse files
committed
fix: avoid throwing error if saveOptions undefined when invalidating subdoc cache
Fix Automattic#15062
1 parent f5f7be9 commit 76f92d2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/plugins/saveSubdocs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ module.exports = function saveSubdocs(schema) {
2727
cb(err);
2828
});
2929
}, function(error) {
30-
// Bust subdocs cache because subdoc pre hooks can add new subdocuments
31-
_this.$__.saveOptions.__subdocs = null;
30+
// Invalidate subdocs cache because subdoc pre hooks can add new subdocuments
31+
if (_this.$__.saveOptions) {
32+
_this.$__.saveOptions.__subdocs = null;
33+
}
3234
if (error) {
3335
return _this.$__schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) {
3436
next(error);

0 commit comments

Comments
 (0)