Skip to content

Instantly share code, notes, and snippets.

@mcuadros
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcuadros/9717737 to your computer and use it in GitHub Desktop.
Save mcuadros/9717737 to your computer and use it in GitHub Desktop.
void bsonToMongoId(bson_iter_t* iter, Array* output) {
    const bson_oid_t* oid = bson_iter_oid(iter);
    char id[25];

    bson_oid_to_string(oid, id);
   
    TypedValue ret;
    Class* cls = Unit::loadClass(s_MongoId.get());
    ObjectData* obj = ObjectData::newInstance(cls);

    g_context->invokeFunc(
        &ret, 
        cls->getCtor(), 
        make_packed_array(String(id)),
        obj
    );
    
    printf("After: %s\n", id);

    output->add(
        String(bson_iter_key(iter)),
        obj
    ); 
}
Inner PHP: 000000000000000000000002
After: 000000000000000000000002
Inner PHP: 4af9f23d8ead0e1d32000000
After: 4af9f23d8ead0e1d32000000

Notice: Array to string conversion in /workspace/mongator/bson-hni/encode.php on line 23
Core dumped: Segmentation fault
Segmentation fault
Program received signal SIGSEGV, Segmentation fault.
0x00000000011475c0 in HPHP::FixedStringMap<unsigned int, false, unsigned int>::find(HPHP::StringData const*) const ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment