From 99d4a473bf0721f3b0e54368b8c89e9588ecfb0d Mon Sep 17 00:00:00 2001 From: Eric Green Date: Tue, 16 Sep 2014 18:16:14 -0400 Subject: [PATCH 1/2] Allow saving Parse Objects with Master Key --- src/Parse/ParseObject.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Parse/ParseObject.php b/src/Parse/ParseObject.php index ce704ae4..c9f817be 100755 --- a/src/Parse/ParseObject.php +++ b/src/Parse/ParseObject.php @@ -818,24 +818,27 @@ private function getSaveJSON() /** * Save Object to Parse * + * @param bool $useMasterKey Whether to use the Master Key. + * * @return null */ - public function save() + public function save($useMasterKey = false) { if (!$this->isDirty()) { return; } - static::deepSave($this); + static::deepSave($this, $useMasterKey); } /** * Save all the objects in the provided array * * @param array $list + * @param bool $useMasterKey Whether to use the Master Key. * * @return null */ - public static function saveAll($list) + public static function saveAll($list, $useMasterKey = false) { static::deepSave($list); } @@ -844,12 +847,13 @@ public static function saveAll($list) * Save Object and unsaved children within. * * @param $target + * @param bool $useMasterKey Whether to use the Master Key. * * @return null * * @throws ParseException */ - private static function deepSave($target) + private static function deepSave($target, $useMasterKey = false) { $unsavedChildren = array(); $unsavedFiles = array(); @@ -916,7 +920,7 @@ private static function deepSave($target) $batch[0]->mergeAfterSave($result); } else { $result = ParseClient::_request('POST', '/1/batch', $sessionToken, - json_encode(array("requests" => $requests))); + json_encode(array("requests" => $requests)), $useMasterKey); $errorCollection = array(); From a780976c7eb6709279d971c1a449547462da6103 Mon Sep 17 00:00:00 2001 From: Eric Green Date: Tue, 16 Sep 2014 18:20:41 -0400 Subject: [PATCH 2/2] Pass useMasterKey to deepSave on saveAll --- src/Parse/ParseObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parse/ParseObject.php b/src/Parse/ParseObject.php index c9f817be..c93505d2 100755 --- a/src/Parse/ParseObject.php +++ b/src/Parse/ParseObject.php @@ -840,7 +840,7 @@ public function save($useMasterKey = false) */ public static function saveAll($list, $useMasterKey = false) { - static::deepSave($list); + static::deepSave($list, $useMasterKey); } /**