This repository was archived by the owner on Feb 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -708,6 +708,10 @@ PHP_METHOD(MongoCursor, explain)
708
708
zval_ptr_dtor (& yes );
709
709
php_mongocursor_next (cursor , return_value TSRMLS_CC );
710
710
711
+ if (php_mongo_handle_error (cursor TSRMLS_CC )) {
712
+ return ;
713
+ }
714
+
711
715
/* reset cursor to original state */
712
716
cursor -> limit = temp_limit ;
713
717
zend_hash_del (HASH_P (cursor -> query ), "$explain" , strlen ("$explain" ) + 1 );
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Test for PHP-1425: explain() does not raise appropriate exception for $err conditions
3
+ --SKIPIF--
4
+ <?php require_once "tests/utils/standalone.inc " ; ?>
5
+ --FILE--
6
+ <?php
7
+ require_once "tests/utils/server.inc " ;
8
+
9
+ $ host = MongoShellServer::getStandaloneInfo ();
10
+ $ m = new MongoClient ($ host );
11
+
12
+ $ m ->admin ->command ( array ( 'setParameter ' => 1 , 'notablescan ' => 1 ) );
13
+
14
+ $ c = $ m ->selectCollection (dbname (), collname (__FILE__ ));
15
+
16
+ $ c ->drop ();
17
+ $ c ->insert ( array ( 'foo ' => 'bar ' ) );
18
+ try
19
+ {
20
+ $ c ->find ( array ( 'foo ' => 'bar ' ) )->explain ();
21
+ echo "FAILED: MongoCursorException should have been thrown \n" ;
22
+ }
23
+ catch ( MongoCursorException $ e )
24
+ {
25
+ // Error message and code vary between server versions, so don't assert their values
26
+ echo "MongoCursorException was thrown \n" ;
27
+ }
28
+
29
+ ?>
30
+ ===DONE===
31
+ --CLEAN--
32
+ <?php
33
+ require_once "tests/utils/server.inc " ;
34
+
35
+ $ host = MongoShellServer::getStandaloneInfo ();
36
+ $ m = new MongoClient ($ host );
37
+ $ m ->admin ->command (array ('setParameter ' => 1 , 'notablescan ' => 0 ));
38
+
39
+ ?>
40
+ --EXPECTF--
41
+ MongoCursorException was thrown
42
+ ===DONE===
You can’t perform that action at this time.
0 commit comments