@@ -847,7 +847,7 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
847847
848848 // Must be called first so we don't
849849 // strip out created_at values.
850- $ row = $ this ->doProtectFields ($ row );
850+ $ row = $ this ->doProtectFieldsForInsert ($ row );
851851
852852 // Set created_at and updated_at with same time
853853 $ date = $ this ->setDate ();
@@ -1222,11 +1222,11 @@ public function protect(bool $protect = true)
12221222 }
12231223
12241224 /**
1225- * Ensures that only the fields that are allowed to be updated
1226- * are in the data array.
1225+ * Ensures that only the fields that are allowed to be updated are
1226+ * in the data array.
12271227 *
1228- * Used by insert(), insertBatch(), update(), and updateBatch() to protect
1229- * against mass assignment vulnerabilities.
1228+ * Used by update() and updateBatch() to protect against mass assignment
1229+ * vulnerabilities.
12301230 *
12311231 * @param array $data Data
12321232 *
@@ -1251,6 +1251,22 @@ protected function doProtectFields(array $data): array
12511251 return $ data ;
12521252 }
12531253
1254+ /**
1255+ * Ensures that only the fields that are allowed to be inserted are in
1256+ * the data array.
1257+ *
1258+ * Used by insert() and insertBatch() to protect against mass assignment
1259+ * vulnerabilities.
1260+ *
1261+ * @param array $data Data
1262+ *
1263+ * @throws DataException
1264+ */
1265+ protected function doProtectFieldsForInsert (array $ data ): array
1266+ {
1267+ return $ this ->doProtectFields ($ data );
1268+ }
1269+
12541270 /**
12551271 * Sets the date or current date if null value is passed.
12561272 *
0 commit comments