File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -401,13 +401,16 @@ public function drop()
401
401
* @see http://docs.mongodb.org/manual/reference/method/db.collection.dropIndex/
402
402
* @param string $indexName
403
403
* @return Cursor
404
- * @throws InvalidArgumentException if "*" is specified, since dropIndexes()
405
- * should be used to drop multiple indexes
404
+ * @throws InvalidArgumentException if $indexName is an empty string or "*"
406
405
*/
407
406
public function dropIndex ($ indexName )
408
407
{
409
408
$ indexName = (string ) $ indexName ;
410
409
410
+ if ($ indexName === '' ) {
411
+ throw new InvalidArgumentException ('Index name cannot be empty ' );
412
+ }
413
+
411
414
if ($ indexName === '* ' ) {
412
415
throw new InvalidArgumentException ('dropIndexes() must be used to drop multiple indexes ' );
413
416
}
Original file line number Diff line number Diff line change @@ -150,6 +150,16 @@ public function testDropIndex()
150
150
}
151
151
}
152
152
153
+ /**
154
+ * @expectedException MongoDB\Exception\InvalidArgumentException
155
+ */
156
+ public function testDropIndexShouldNotAllowEmptyIndexName ()
157
+ {
158
+ $ this ->assertSame ('x_1 ' , $ this ->collection ->createIndex (array ('x ' => 1 )));
159
+ $ this ->assertIndexExists ('x_1 ' );
160
+ $ this ->collection ->dropIndex ('' );
161
+ }
162
+
153
163
/**
154
164
* @expectedException MongoDB\Exception\InvalidArgumentException
155
165
*/
You can’t perform that action at this time.
0 commit comments