Dot notation in MongoDB InsertOne

467 Views Asked by At

While performing InsertOne in MongoDB (4.0.5) from PHP I get the following exception:

[0] Detected unsupported PHP type for field path "context.trace.1.args.2": 7

According to the MongoDB documentation one is allowed to use dot notation in update commands. The doc however talks about this fact with $set as context.

It seems to me that a simple Update does not allow for dot notation. (just guessing)

Can someone explain the nuance/edge cases here?

===== follow up on request:

The document is created by Monolog. And the document used in InsertOne looks like the following:

Array
(
    [message] => file_get_contents( ...obfuscated... ): failed to open stream: Connection timed out
    [context] => Array
        (
            [code] => 2
            [file] =>  ...obfuscated...
            [line] => 127
            [trace] => Array
                (
                    [0] => Array
                        (
                            [function] => handleError
                            [class] => Whoops\Run
                            [type] => ->
                            ...obfuscated...
                        )

                    [1] => Array
                        (
                            [function] => file_get_contents
                            [args] => Array
                                (
                                    [0] => https:// ...obfuscated...
                                    [1] =>
                                    [2] => 0
                                )

                        )

                    [2] => Array
                        (
                            [file] =>  ...obfuscated... .php
                            [line] => 127
                            [function] => file_get_contents
                            [args] => Array
                                (
                                    [0] => https:// ...obfuscated...
                                )

                        )

                    [3] => Array
                        (
                            [file] =>  ...obfuscated... .php
                            [line] => 91
                            [args] => Array
                                (
                                    [0] =>  ...obfuscated... .php
                                )

                            [function] => require_once
                        )

                )

            [notThrown] => 1
            [type] => Whoops\Exception\ErrorException
        )

    [level] => 500
    [level_name] => CRITICAL
    [channel] =>  ...obfuscated...
    [datetime] => MongoDB\BSON\UTCDateTime Object
        (
            [milliseconds] => 1551951362000
        )

    [extra] => Array
        (
            [cli] => Array
                (
                    [user] =>  ...obfuscated...
                    [script] =>  ...obfuscated... .php
                    [argv] => Array
                        (
                            [0] =>  ...obfuscated...
                        )

                )

            [server_name] =>  ...obfuscated...
            [server_ip] =>  ...obfuscated...
            [process_id] => 3273
            [memory_peak_usage] => 5.75 MB
            [memory_usage] => 5.75 MB
            [git] => Array
                (
                    [ ...obfuscated... ] => Array
                        (
                            [branch] =>  ...obfuscated...
                            [commit] =>  ...obfuscated...
                        )

                    [publisher] => Array
                        (
                            [branch] =>  ...obfuscated...
                            [commit] =>  ...obfuscated...
                        )

                )

        )

    [server_name] =>  ...obfuscated...
    [_id] => MongoDB\BSON\ObjectId Object
        (
            [oid] => 5c81e6029caba40cc96bd831
        )

)

I suspect Neil Lunn already answers the question.

But now I wonder whether this is a shortcoming of Monolog or not. And what approach to take to solve this issue.

0

There are 0 best solutions below