[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] [doc-en] master: Warning about duplicate keys in BSON documents
From:       Jeremy Mikola <noreply () php ! net>
Date:       2022-01-15 0:58:43
Message-ID: ACCNIp6ZOkJFH161bU392hpD9Hp6HE09uPpGLX1qJQ () main ! php ! net
[Download RAW message or body]

Author: Jeremy Mikola (jmikola)
Date: 2022-01-14T19:58:21-05:00

Commit: https://github.com/php/doc-en/commit/33d23851b05574b9ad0b2adcceb9d9ba713e9c6b
Raw diff: https://github.com/php/doc-en/commit/33d23851b05574b9ad0b2adcceb9d9ba713e9c6b.diff


Warning about duplicate keys in BSON documents

https://jira.mongodb.org/browse/PHPC-1342

Changed paths:
  M  language-snippets.ent
  M  reference/mongodb/architecture.xml
  M  reference/mongodb/functions/bson/tophp.xml


Diff:

diff --git a/language-snippets.ent b/language-snippets.ent
index c43b4abcb4..1ef1f5f785 100644
--- a/language-snippets.ent
+++ b/language-snippets.ent
@@ -2992,6 +2992,18 @@ local: {
   </note>
 '>
 
+<!ENTITY mongodb.warning.duplicate-keys '
+   <warning xmlns="http://docbook.org/ns/docbook">
+    <simpara>
+     BSON documents can technically contain duplicate keys because documents are
+     stored as a list of key-value pairs; however, applications should refrain
+     from generating documents with duplicate keys as server and driver behavior
+     may be undefined. Since PHP objects and arrays cannot have duplicate keys,
+     data could also be lost when decoding a BSON document with duplicate keys.
+    </simpara>
+   </warning>
+'>
+
 <!-- Radius -->
 <!ENTITY radius.request.required '<note \
xmlns="http://docbook.org/ns/docbook"><para>A request must be created via \
<function>radius_create_request</function> before this function can be \
called.</para></note>'>  <!ENTITY radius.parameter.attribute-type '<varlistentry \
xmlns="http://docbook.org/ns/docbook"><term><parameter>type</parameter></term><listitem><para>The \
                attribute type.</para></listitem></varlistentry>'>
diff --git a/reference/mongodb/architecture.xml b/reference/mongodb/architecture.xml
index 6034cd8a2a..2183e95a44 100644
--- a/reference/mongodb/architecture.xml
+++ b/reference/mongodb/architecture.xml
@@ -513,6 +513,8 @@ class UpperClass implements MongoDB\BSON\Persistable {
   <section xml:id="mongodb.persistence.deserialization">
    <title>Deserialization from BSON</title>
 
+   &mongodb.warning.duplicate-keys;
+
    <para>
     The legacy <code>mongo</code> extension deserialized
     both BSON documents and arrays as PHP arrays. While PHP arrays are
diff --git a/reference/mongodb/functions/bson/tophp.xml \
b/reference/mongodb/functions/bson/tophp.xml index 940a89b0b1..b75d878d1e 100644
--- a/reference/mongodb/functions/bson/tophp.xml
+++ b/reference/mongodb/functions/bson/tophp.xml
@@ -19,6 +19,7 @@
    The <parameter>typeMap</parameter> paramater may be used to control the PHP
    types used for converting BSON arrays and documents (both root and embedded).
   </para>
+  &mongodb.warning.duplicate-keys;
  </refsect1>
 
  <refsect1 role="parameters">

-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic