@@ -797,16 +797,16 @@ public function destroy($useMasterKey = false)
797797 *
798798 * @param array $objects Objects to destroy.
799799 * @param bool $useMasterKey Whether to use the master key or not.
800+ * @param int $batchSize Number of objects to process per request
800801 *
801802 * @throws ParseAggregateException
802803 */
803- public static function destroyAll (array $ objects , $ useMasterKey = false )
804+ public static function destroyAll (array $ objects , $ useMasterKey = false , $ batchSize = 40 )
804805 {
805806 $ errors = [];
806807 $ objects = array_values ($ objects ); // To support non-ordered arrays
807808 $ count = count ($ objects );
808809 if ($ count ) {
809- $ batchSize = 40 ;
810810 $ processed = 0 ;
811811 $ currentBatch = [];
812812 $ currentcount = 0 ;
@@ -1153,23 +1153,25 @@ public function save($useMasterKey = false)
11531153 *
11541154 * @param array $list
11551155 * @param bool $useMasterKey Whether to use the Master Key.
1156+ * @param int $batchSize Number of objects to process per request
11561157 */
1157- public static function saveAll ($ list , $ useMasterKey = false )
1158+ public static function saveAll ($ list , $ useMasterKey = false , $ batchSize = 40 )
11581159 {
1159- static ::deepSave ($ list , $ useMasterKey );
1160+ static ::deepSave ($ list , $ useMasterKey, $ batchSize );
11601161 }
11611162
11621163 /**
11631164 * Save object and unsaved children within.
11641165 *
11651166 * @param ParseObject|array $target
11661167 * @param bool $useMasterKey Whether to use the Master Key.
1168+ * @param int $batchSize Number of objects to process per request
11671169 *
11681170 * @throws Exception
11691171 * @throws ParseAggregateException
11701172 * @throws ParseException
11711173 */
1172- private static function deepSave ($ target , $ useMasterKey = false )
1174+ private static function deepSave ($ target , $ useMasterKey = false , $ batchSize = 40 )
11731175 {
11741176 $ unsavedChildren = [];
11751177 $ unsavedFiles = [];
@@ -1197,7 +1199,7 @@ private static function deepSave($target, $useMasterKey = false)
11971199 $ newRemaining = [];
11981200
11991201 foreach ($ remaining as $ key => &$ object ) {
1200- if (count ($ batch ) > 40 ) {
1202+ if (count ($ batch ) > $ batchSize ) {
12011203 $ newRemaining [] = $ object ;
12021204 continue ;
12031205 }
0 commit comments