Skip to content

Commit 288a774

Browse files
committed
Merge pull request #420
2 parents 0c62e64 + 8d70686 commit 288a774

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

tests/query/bug0705-001.phpt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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===

tests/query/bug0705-002.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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===

0 commit comments

Comments
 (0)