Skip to content

Commit 8d5dc93

Browse files
authored
Merge branch 'release-5.x.x' into fix-lts
2 parents d1d89d6 + e9ae435 commit 8d5dc93

File tree

5 files changed

+39
-18
lines changed

5 files changed

+39
-18
lines changed

changelogs/CHANGELOG_release.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [5.4.3](https://github.com/parse-community/parse-server/compare/5.4.2...5.4.3) (2023-03-22)
2+
3+
4+
### Bug Fixes
5+
6+
* Unable to create new role if `beforeSave` hook exists ([#8474](https://github.com/parse-community/parse-server/issues/8474)) ([4f0f0ec](https://github.com/parse-community/parse-server/commit/4f0f0ec4bb7334adf64fcbfb80589727dc46906d))
7+
18
## [5.4.2](https://github.com/parse-community/parse-server/compare/5.4.1...5.4.2) (2023-02-16)
29

310

package-lock.json

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse-server",
3-
"version": "5.4.2",
3+
"version": "5.4.3",
44
"description": "An express module providing a Parse-compatible API server",
55
"main": "lib/index.js",
66
"repository": {
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@graphql-yoga/node": "2.6.0",
2323
"@graphql-tools/utils": "8.12.0",
24-
"@graphql-tools/merge": "8.3.6",
24+
"@graphql-tools/merge": "8.3.17",
2525
"@graphql-tools/schema": "9.0.4",
2626
"@parse/fs-files-adapter": "1.2.2",
2727
"@parse/push-adapter": "4.1.2",

spec/ParseRole.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,4 +601,12 @@ describe('Parse Role testing', () => {
601601
});
602602
});
603603
});
604+
605+
it('should save role when beforeSave hook for _Role is present.', async done => {
606+
Parse.Cloud.beforeSave('_Role', () => {});
607+
const role = new Parse.Role('roleName', new Parse.ACL());
608+
await role.save({}, { useMasterKey: true });
609+
expect(role.id).toBeDefined();
610+
done();
611+
});
604612
});

src/RestWrite.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ function RestWrite(config, auth, className, query, data, originalData, clientSDK
8787
// Shared SchemaController to be reused to reduce the number of loadSchema() calls per request
8888
// Once set the schemaData should be immutable
8989
this.validSchemaController = null;
90-
this.pendingOps = {};
90+
this.pendingOps = {
91+
operations: null,
92+
identifier: null,
93+
};
9194
}
9295

9396
// A convenient method to perform all the steps of processing the
@@ -219,10 +222,13 @@ RestWrite.prototype.runBeforeSaveTrigger = function () {
219222
}
220223

221224
const { originalObject, updatedObject } = this.buildParseObjects();
222-
225+
const identifier = updatedObject._getStateIdentifier();
223226
const stateController = Parse.CoreManager.getObjectStateController();
224-
const [pending] = stateController.getPendingOps(updatedObject._getStateIdentifier());
225-
this.pendingOps = { ...pending };
227+
const [pending] = stateController.getPendingOps(identifier);
228+
this.pendingOps = {
229+
operations: { ...pending },
230+
identifier,
231+
};
226232

227233
return Promise.resolve()
228234
.then(() => {
@@ -1569,7 +1575,7 @@ RestWrite.prototype.runAfterSaveTrigger = function () {
15691575
.then(result => {
15701576
const jsonReturned = result && !result._toFullJSON;
15711577
if (jsonReturned) {
1572-
this.pendingOps = {};
1578+
this.pendingOps.operations = {};
15731579
this.response.response = result;
15741580
} else {
15751581
this.response.response = this._updateResponseWithData(
@@ -1673,10 +1679,9 @@ RestWrite.prototype.cleanUserAuthData = function () {
16731679
};
16741680

16751681
RestWrite.prototype._updateResponseWithData = function (response, data) {
1676-
const { updatedObject } = this.buildParseObjects();
16771682
const stateController = Parse.CoreManager.getObjectStateController();
1678-
const [pending] = stateController.getPendingOps(updatedObject._getStateIdentifier());
1679-
for (const key in this.pendingOps) {
1683+
const [pending] = stateController.getPendingOps(this.pendingOps.identifier);
1684+
for (const key in this.pendingOps.operations) {
16801685
if (!pending[key]) {
16811686
data[key] = this.originalData ? this.originalData[key] : { __op: 'Delete' };
16821687
this.storage.fieldsChangedByTrigger.push(key);

0 commit comments

Comments
 (0)