Uploaded image for project: 'Couchbase PHP client library'
  1. Couchbase PHP client library
  2. PCBC-363

Issue passing non-string as a key

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.1.0
    • 2.0.5
    • library
    • Security Level: Public
    • None

    Description

      When passing a non-string as the key to any CRUD operation (insert, upsert or get) the return value is

       array(0) { } 

      .

      This seems incorrect to me, there should be some sort of error returned within a CouchbaseMetaDoc, which is the expected output which specifies why the operation failed.

      Alternatively, if a string must be used for the key, then the SDK should try and convert the value passed to it to a string before performing the operation.

      Example code to reproduce:

      <?php
       
      $cluster = new CouchbaseCluster('http://localhost:8091');
      $bucket = $cluster->openBucket('default');
      for ($i = 1; $i <= 10000; $i++) {
        $result = $bucket->upsert($i, '');
        var_dump($result);
      }
      

      This returns 10000 of the following:

      array(0) {
      }
      

      When the key is converted to a string before being passed to the SDK, there is no issue.

      Example:

      <?php
       
      $cluster = new CouchbaseCluster('http://localhost:8091');
      $bucket = $cluster->openBucket('default');
      for ($i = 1; $i <= 10000; $i++) {
        $result = $bucket->upsert("$i", '');
        var_dump($result);
      }
      

      Output:

      object(CouchbaseMetaDoc)#4 (4) {
        ["error"]=>
        NULL
        ["value"]=>
        string(0) ""
        ["flags"]=>
        int(0)
        ["cas"]=>
        resource(10002) of type (CouchbaseCAS)
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              brett19 Brett Lawson
              matt.carabine Matt Carabine (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty