File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PHPC-705: Do not unnecessarily wrap filters in $query (profiled query)
3
+ --SKIPIF--
4
+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ; CLEANUP (STANDALONE_30 ) ?>
5
+ --FILE--
6
+ <?php
7
+ require_once __DIR__ . "/../utils/basic.inc " ;
8
+
9
+ $ manager = new MongoDB \Driver \Manager (STANDALONE_30 );
10
+
11
+ $ command = new MongoDB \Driver \Command (['profile ' => 2 ]);
12
+ $ cursor = $ manager ->executeCommand (DATABASE_NAME , $ command );
13
+ $ result = current ($ cursor ->toArray ());
14
+
15
+ printf ("Set profile level to 2 successfully: %s \n" , (empty ($ result ->ok ) ? 'no ' : 'yes ' ));
16
+
17
+ $ manager ->executeQuery (NS , new MongoDB \Driver \Query (["x " => 1 ]));
18
+
19
+ $ query = new MongoDB \Driver \Query (
20
+ [
21
+ 'op ' => 'query ' ,
22
+ 'ns ' => NS ,
23
+ ],
24
+ [
25
+ 'sort ' => ['ts ' => -1 ],
26
+ 'limit ' => 1 ,
27
+ ]
28
+ );
29
+ $ cursor = $ manager ->executeQuery (DATABASE_NAME . '.system.profile ' , $ query );
30
+ $ profileEntry = current ($ cursor ->toArray ());
31
+
32
+ var_dump ($ profileEntry ->query );
33
+
34
+ $ command = new MongoDB \Driver \Command (array ('profile ' => 0 ));
35
+ $ cursor = $ manager ->executeCommand (DATABASE_NAME , $ command );
36
+ $ result = current ($ cursor ->toArray ());
37
+
38
+ printf ("Set profile level to 0 successfully: %s \n" , (empty ($ result ->ok ) ? 'no ' : 'yes ' ));
39
+
40
+ ?>
41
+ ===DONE===
42
+ <?php exit (0 ); ?>
43
+ --EXPECTF--
44
+ Set profile level to 2 successfully: yes
45
+ object(stdClass)#%d (%d) {
46
+ ["x"]=>
47
+ int(1)
48
+ }
49
+ Set profile level to 0 successfully: yes
50
+ ===DONE===
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PHPC-705: Do not unnecessarily wrap filters in $query (currentOp query)
3
+ --SKIPIF--
4
+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ; CLEANUP (STANDALONE_30 ) ?>
5
+ --FILE--
6
+ <?php
7
+ require_once __DIR__ . "/../utils/basic.inc " ;
8
+
9
+ $ manager = new MongoDB \Driver \Manager (STANDALONE_30 );
10
+ $ cursor = $ manager ->executeQuery ('admin.$cmd.sys.inprog ' , new MongoDB \Driver \Query ([]));
11
+ var_dump ($ cursor ->toArray ());
12
+
13
+ ?>
14
+ ===DONE===
15
+ <?php exit (0 ); ?>
16
+ --EXPECTF--
17
+ array(1) {
18
+ [0]=>
19
+ object(stdClass)#%d (%d) {
20
+ ["inprog"]=>
21
+ array(0) {
22
+ }
23
+ }
24
+ }
25
+ ===DONE===
You can’t perform that action at this time.
0 commit comments