Bug #74848 [NEW]: the parameter fields does not work
| From: | blackpanther dot online at gmx dot de | Date: | Mon, 03 Jul 2017 14:09:18 +0000 |
| Subject: | Bug #74848 [NEW]: the parameter fields does not work | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-14699@lists.php.net to get a copy of this message | ||
From: blackpanther dot online at gmx dot de
Operating system:
PHP version: 7.1.6
Package: mongodb
Bug Type: Bug
Bug description:the parameter fields does not work
Description:
------------
---
From manual page: http://www.php.net/mongocollection.find
---
If you pass the second parameter fields, you should receive only the
fields given, but actually you receive all.
You can pass ["field_a" => true] and get all fields. The same then you
pass ["field_a" => false].
So it's not working.
(If you check the mongodb's find method directly on the database without
php by collection.find({},{"field_a":1}) it works properly)
Test script:
---------------
require '../vendor/autoload.php';
$mongodb = new MongoDB\Client("mongodb://xx:xx@localhost:27017/test");
// needs an existing mongodb server
$collection = $mongodb->test->phpfind; // needs an existing database
// create a new record
$collection->insertOne(['field_a' => 'A', 'field_b' =>
'B']);
// should return a entry with only _id and field_a as fields
print_r($collection->findOne([], ['field_a' => true]));
// should return a entry with only _id and field_b as fields
print_r($collection->findOne([], ['field_a' => false]));
Expected result:
----------------
MongoDB\Model\BSONDocument Object
(
[storage:ArrayObject:private] => Array
(
[_id] => MongoDB\BSON\ObjectID Object
(
[oid] => 595a4cd3a1b69920b0003641
)
[field_a] => A
)
)
MongoDB\Model\BSONDocument Object
(
[storage:ArrayObject:private] => Array
(
[_id] => MongoDB\BSON\ObjectID Object
(
[oid] => 595a4cd3a1b69920b0003641
)
[field_b] => B
)
)
Actual result:
--------------
MongoDB\Model\BSONDocument Object
(
[storage:ArrayObject:private] => Array
(
[_id] => MongoDB\BSON\ObjectID Object
(
[oid] => 595a4cd3a1b69920b0003641
)
[field_a] => A
[field_b] => B
)
)
MongoDB\Model\BSONDocument Object
(
[storage:ArrayObject:private] => Array
(
[_id] => MongoDB\BSON\ObjectID Object
(
[oid] => 595a4cd3a1b69920b0003641
)
[field_a] => A
[field_b] => B
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=74848&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74848&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74848&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74848&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74848&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74848&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74848&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74848&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74848&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74848&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74848&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74848&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74848&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74848&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74848&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74848&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74848&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74848&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74848&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74848&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74848&r=mysqlcfg