Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions Parse/PFObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,32 +233,32 @@ + (void)collectDirtyChildren:(id)node
if ([node isKindOfClass:[NSArray class]]) {
for (id elem in node) {
@autoreleasepool {
[PFObject collectDirtyChildren:elem
children:dirtyChildren
files:dirtyFiles
seen:seen
seenNew:seenNew
currentUser:currentUser];
}
}
} else if ([node isKindOfClass:[NSDictionary class]]) {
[node enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[PFObject collectDirtyChildren:obj
[self collectDirtyChildren:elem
children:dirtyChildren
files:dirtyFiles
seen:seen
seenNew:seenNew
currentUser:currentUser];
}
}
} else if ([node isKindOfClass:[NSDictionary class]]) {
[node enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[self collectDirtyChildren:obj
children:dirtyChildren
files:dirtyFiles
seen:seen
seenNew:seenNew
currentUser:currentUser];
}];
} else if ([node isKindOfClass:[PFACL class]]) {
PFACL *acl = (PFACL *)node;
if ([acl hasUnresolvedUser]) {
[PFObject collectDirtyChildren:currentUser
children:dirtyChildren
files:dirtyFiles
seen:seen
seenNew:seenNew
currentUser:currentUser];
[self collectDirtyChildren:currentUser
children:dirtyChildren
files:dirtyFiles
seen:seen
seenNew:seenNew
currentUser:currentUser];
}

} else if ([node isKindOfClass:[PFObject class]]) {
Expand Down Expand Up @@ -288,12 +288,12 @@ + (void)collectDirtyChildren:(id)node
// Recurse into this object's children looking for dirty children.
// We only need to look at the child object's current estimated data,
// because that's the only data that might need to be saved now.
[PFObject collectDirtyChildren:object->_estimatedData.dictionaryRepresentation
children:dirtyChildren
files:dirtyFiles
seen:seen
seenNew:seenNew
currentUser:currentUser];
[self collectDirtyChildren:object->_estimatedData.dictionaryRepresentation
children:dirtyChildren
files:dirtyFiles
seen:seen
seenNew:seenNew
currentUser:currentUser];

if ([object isDirty:NO]) {
[dirtyChildren addObject:object];
Expand All @@ -314,12 +314,12 @@ + (void)collectDirtyChildren:(id)child
children:(NSMutableSet *)dirtyChildren
files:(NSMutableSet *)dirtyFiles
currentUser:(PFUser *)currentUser {
[PFObject collectDirtyChildren:child
children:dirtyChildren
files:dirtyFiles
seen:[NSSet set]
seenNew:[NSSet set]
currentUser:currentUser];
[self collectDirtyChildren:child
children:dirtyChildren
files:dirtyFiles
seen:[NSSet set]
seenNew:[NSSet set]
currentUser:currentUser];
}

// Returns YES if the given object can be serialized for saving as a value
Expand All @@ -335,7 +335,7 @@ + (BOOL)canBeSerializedAsValue:(id)value
if (!object.objectId && ![saved containsObject:object]) {
if (error) {
*error = [PFErrorUtilities errorWithCode:kPFErrorInvalidPointer
message:@"Pointer to an unsaved object."];
message:@"Pointer to an unsaved object."];
}
return NO;
}
Expand Down Expand Up @@ -385,7 +385,7 @@ - (BOOL)canBeSerializedAfterSaving:(NSMutableArray *)saved withCurrentUser:(PFUs
![saved containsObject:user]) {
if (error) {
*error = [PFErrorUtilities errorWithCode:kPFErrorInvalidACL
message:@"User associated with ACL must be signed up."];
message:@"User associated with ACL must be signed up."];
}
return NO;
}
Expand All @@ -402,15 +402,15 @@ + (BFTask *)_deepSaveAsync:(id)object withCurrentUser:(PFUser *)currentUser sess

NSMutableSet *uniqueObjects = [NSMutableSet set];
NSMutableSet *uniqueFiles = [NSMutableSet set];
[PFObject collectDirtyChildren:object children:uniqueObjects files:uniqueFiles currentUser:currentUser];
[self collectDirtyChildren:object children:uniqueObjects files:uniqueFiles currentUser:currentUser];
for (PFFile *file in uniqueFiles) {
task = [task continueAsyncWithSuccessBlock:^id(BFTask *task) {
return [[file saveInBackground] continueAsyncWithBlock:^id(BFTask *task) {
// This is a stupid hack because our current behavior is to fail file
// saves with an error when a file save inside it is cancelled.
if (task.isCancelled) {
NSError *newError = [PFErrorUtilities errorWithCode:kPFErrorUnsavedFile
message:@"A file save was cancelled."];
message:@"A file save was cancelled."];
return [BFTask taskWithError:newError];
}
return task;
Expand Down Expand Up @@ -470,7 +470,7 @@ + (BFTask *)_deepSaveAsync:(id)object withCurrentUser:(PFUser *)currentUser sess
NSMutableArray *tasks = [NSMutableArray arrayWithCapacity:[objectBatches count]];

for (NSArray *objectBatch in objectBatches) {
BFTask *batchTask = [PFObject _enqueue:^BFTask *(BFTask *toAwait) {
BFTask *batchTask = [self _enqueue:^BFTask *(BFTask *toAwait) {
return [toAwait continueAsyncWithBlock:^id(BFTask *task) {
NSMutableArray *commands = [NSMutableArray arrayWithCapacity:[objectBatch count]];
for (PFObject *object in objectBatch) {
Expand Down Expand Up @@ -571,7 +571,7 @@ + (BFTask *)_enqueueSaveEventuallyChildrenOfObject:(PFObject *)object
return [BFTask taskFromExecutor:[BFExecutor defaultExecutor] withBlock:^id{
NSMutableSet *uniqueObjects = [NSMutableSet set];
NSMutableSet *uniqueFiles = [NSMutableSet set];
[PFObject collectDirtyChildren:object children:uniqueObjects files:uniqueFiles currentUser:currentUser];
[self collectDirtyChildren:object children:uniqueObjects files:uniqueFiles currentUser:currentUser];
for (PFFile *file in uniqueFiles) {
if (!file.url) {
NSException *exception = [NSException exceptionWithName:NSInternalInconsistencyException
Expand Down Expand Up @@ -641,9 +641,9 @@ + (BFTask *)_enqueueSaveEventuallyChildrenOfObject:(PFObject *)object

- (BFTask *)_saveChildrenInBackgroundWithCurrentUser:(PFUser *)currentUser sessionToken:(NSString *)sessionToken {
@synchronized (lock) {
return [PFObject _deepSaveAsync:_estimatedData.dictionaryRepresentation
withCurrentUser:currentUser
sessionToken:sessionToken];
return [[self class] _deepSaveAsync:_estimatedData.dictionaryRepresentation
withCurrentUser:currentUser
sessionToken:sessionToken];
}
}

Expand Down Expand Up @@ -1136,7 +1136,7 @@ - (BFTask *)_enqueueSaveEventuallyWithChildren:(BOOL)saveChildren {

BFTask *saveChildrenTask = nil;
if (saveChildren) {
saveChildrenTask = [PFObject _enqueueSaveEventuallyChildrenOfObject:self currentUser:currentUser];
saveChildrenTask = [[self class] _enqueueSaveEventuallyChildrenOfObject:self currentUser:currentUser];
} else {
saveChildrenTask = [BFTask taskWithResult:nil];
}
Expand Down Expand Up @@ -2608,7 +2608,7 @@ - (BOOL)unpinWithName:(NSString *)name error:(NSError **)error {
}

- (BFTask *)unpinInBackgroundWithName:(NSString *)name {
return [PFObject unpinAllInBackground:@[ self ] withName:name];
return [[self class] unpinAllInBackground:@[ self ] withName:name];
}

- (void)unpinInBackgroundWithName:(NSString *)name block:(PFBooleanResultBlock)block {
Expand Down
10 changes: 5 additions & 5 deletions Parse/PFUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ - (void)synchronizeAllAuthData {

+ (BFTask *)_logInWithAuthTypeInBackground:(NSString *)authType authData:(NSDictionary *)authData {
// Handle claiming of user.
PFUser *currentUser = [PFUser currentUser];
PFUser *currentUser = [self currentUser];
if (currentUser && [PFAnonymousUtils isLinkedWithUser:currentUser]) {
if ([currentUser isLazy]) {
PFUser *user = currentUser;
Expand Down Expand Up @@ -521,7 +521,7 @@ - (BFTask *)_unlinkWithAuthTypeInBackground:(NSString *)authType {
}

+ (instancetype)logInLazyUserWithAuthType:(NSString *)authType authData:(NSDictionary *)authData {
PFUser *user = [PFUser user];
PFUser *user = [self user];
@synchronized ([user lock]) {
[user setIsCurrentUser:YES];
user.isLazy = YES;
Expand All @@ -532,7 +532,7 @@ + (instancetype)logInLazyUserWithAuthType:(NSString *)authType authData:(NSDicti
}

- (BFTask *)signUpAsync:(BFTask *)toAwait {
PFUser *currentUser = [PFUser currentUser];
PFUser *currentUser = [[self class] currentUser];
NSString *token = currentUser.sessionToken;
@synchronized ([self lock]) {
if (self.objectId) {
Expand Down Expand Up @@ -1058,7 +1058,7 @@ - (NSMutableSet *)linkedServiceNames {
}

+ (instancetype)user {
return (PFUser *)[PFUser object];
return [self object];
}

- (BFTask *)saveAsync:(BFTask *)toAwait {
Expand Down Expand Up @@ -1140,7 +1140,7 @@ - (void)signUpInBackgroundWithTarget:(id)target selector:(SEL)selector {
}

- (BOOL)isAuthenticated {
PFUser *currentUser = [PFUser currentUser];
PFUser *currentUser = [[self class] currentUser];
return [self _isAuthenticatedWithCurrentUser:currentUser];
}

Expand Down