Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$collection->find(); bson error, new Query() fails #52

Closed
MarkisLt opened this issue Nov 25, 2015 · 8 comments
Closed

$collection->find(); bson error, new Query() fails #52

MarkisLt opened this issue Nov 25, 2015 · 8 comments
Assignees

Comments

@MarkisLt
Copy link

Collection.php
Line: 1139: $query = new Query($filter, $options); silently fails.

For now just to get working: i replaced this line with: $query = new Query($filter);

I'll try to find a write way to fix this and will update the information.

@bjori
Copy link
Contributor

bjori commented Nov 25, 2015

What do you mean "silently fails"?
Does PHP just stop execution and nothing happen? That'd indicate it segfaults..

@MarkisLt
Copy link
Author

Code example:

<?php
    ini_set("display_errors",1);
    require_once 'vendor/autoload.php'; // include Composer goodies
    $manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
    $collection = new MongoDB\Collection($manager, "my_db.my_table");
    //$result = $collection->insertOne( [ 'name' => 'Hinterland', 'brewery' => 'BrewDog' ] );
    $cursor = $collection->find([ 'name' => 'Hinterland']); 
        echo "Searching for citizen => Iceland, verify Hayley is now Icelandic\n";
        foreach($cursor as $document) {
            var_dump($document);
        }
?>

/var/tmp/mongodb/src/libbson/src/bson/bson.c:1825 bson_init_static(): precondition failed: data
Aborted

@bjori
Copy link
Contributor

bjori commented Nov 26, 2015

Can you run the example in debug mode?
For example, say the PHP code above is in the filename example.php you'd run:

php -dmongodb.debug=stderr example.php

This would print out a lot of debug information.
If you could save it all to a file and upload/paste it here, it would help a lot, thanks!

@MarkisLt
Copy link
Author

[2015-11-26T06:59:57+00:00] PHONGO: DEBUG > Connection string: 'mongodb://localhost:27017'
[2015-11-26T06:59:57+00:00] PHONGO: TRACE > ENTRY: php_phongo_make_mongo_client():1729
[2015-11-26T06:59:57+00:00] PHONGO: DEBUG > Creating Manager, phongo-1.0.0[stable] - mongoc-1.2.0(bundled), libbson-1.2.0(bundled), php-5.6.14
[2015-11-26T06:59:57+00:00] mongoc: TRACE > ENTRY: mongoc_topology_description_init():51
[2015-11-26T06:59:57+00:00] mongoc: TRACE > EXIT: mongoc_topology_description_init():67
[2015-11-26T06:59:57+00:00] mongoc: TRACE > ENTRY: mongoc_server_description_init():88
[2015-11-26T06:59:57+00:00] mongoc: TRACE > EXIT: mongoc_server_description_init():122
[2015-11-26T06:59:57+00:00] cluster: TRACE > ENTRY: mongoc_cluster_init():1523
[2015-11-26T06:59:57+00:00] cluster: TRACE > EXIT: mongoc_cluster_init():1546
[2015-11-26T06:59:57+00:00] client: DEBUG > Using custom stream initiator.
[2015-11-26T06:59:57+00:00] PHONGO: TRACE > EXIT: php_phongo_make_mongo_client():1797
/var/tmp/mongodb/src/libbson/src/bson/bson.c:1825 bson_init_static(): precondition failed: data
Aborted

@MarkisLt
Copy link
Author

As I see $options is invalid, $query = new Query($filter, $options),
because when I do $query = new Query($filter) it works.

Output from $options:

Array
(
    [allowPartialResults] =>
    [batchSize] => 101
    [comment] =>
    [cursorType] => 0
    [limit] => 0
    [maxTimeMS] => 0
    [modifiers] => Array
        (
        )

    [noCursorTimeout] =>
    [oplogReplay] =>
    [projection] => Array
        (
        )

    [skip] => 0
    [sort] => Array
        (
        )

    [cursorFlags] => 0
)

@bjori bjori assigned bjori and jmikola and unassigned bjori Nov 26, 2015
@ooglek
Copy link

ooglek commented Dec 8, 2015

I'm having the exact same problem with 0.2.0 of the library.

    "mongodb/mongodb": "^0.2.0"

mongodb

mongodb support => enabled
mongodb version => 1.0.1
mongodb stability => stable
libmongoc version => 1.2.0
libbson version => 1.2.0

Directive => Local Value => Master Value
mongodb.debug => no value => no value

I tried commenting out all of the variables returned by getFindOptions() method one by one, and re-running my Find(), but it still failed. As the OP said, if you modify _buildQuery to remove passing in the $options array, things succeed.

If I upgraded to v1.0.0-beta1, the problem went away.

Using > db.version() 3.0.7

@bjori
Copy link
Contributor

bjori commented Dec 21, 2015

Sorry for the lack of updates here.

I'm pretty sure this is fixed in the latest pecl/mongodb release, 1.1.0.

Could you confirm?

1.1.1 is also being released any moment now with PHP7 support, if you'd like to wait and try that out -- it has rewritten lot of this code path to simplify certain things.

@jmikola
Copy link
Member

jmikola commented Jan 6, 2016

Closing this out due to inactivity. Please follow-up if the issue still persists in the more recent releases of the library and driver (1.1.1 is the latest and includes PHP 7 support, and we should have a 1.1.2 release out soon).

@jmikola jmikola closed this as completed Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants