Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-66

Objects returned as arrays

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Works as Designed
    • Affects Version/s: 1.0.1
    • Fix Version/s: None
    • Component/s: pecl-mongo
    • Labels:
      None
    • Backwards Compatibility:
      Major Change
    • # Replies:
      5
    • Last comment by Customer:
      true

      Description

      As discussed on IRC.

      <?php
      $m = new mongo;

      $doc->foo->bar = 'baz';
      $collection = $m->selectDB('foo')->selectCollection('bar');
      $collection->drop();
      $collection->insert($doc);
      $restore = $collection->findOne();
      var_dump((object)$restore);

      object(stdClass)#7 (2) {
      ["_id"]=>
      object(MongoId)#9 (0) {
      }
      ["foo"]=>
      array(1)

      { ["bar"]=> string(3) "baz" }

      }
      ?>

      but $restore->foo should be an object. The (object) casting is not recursive – and it should not be, there is information lost here because this is the same as storing $doc->foo['bar'] = 'baz'; and PHP now does discern between arrays and objects even stdClasses.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                8 years, 32 weeks, 4 days ago
                Date of 1st Reply: