Skip to content

Commit aef7adb

Browse files
committed
PHPLIB-103: bulkWrite() updateMany should require update operators
1 parent 1497182 commit aef7adb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ public function bulkWrite(array $ops, array $options = array())
232232
throw new InvalidArgumentException(sprintf("Missing argument#2 for '%s' (operation#%d)", $opname, $n));
233233
}
234234
$options = array_merge($this->getWriteOptions(), isset($args[2]) ? $args[2] : array(), array("multi" => true));
235+
$firstKey = key($args[1]);
236+
if (!isset($firstKey[0]) || $firstKey[0] != '$') {
237+
throw new InvalidArgumentException("First key in \$update must be a \$operator");
238+
}
235239

236240
$bulk->update($args[0], $args[1], $options);
237241
break;

0 commit comments

Comments
 (0)