Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0.3
    • Fix Version/s: 1.1.0-dp2, 1.1.0-dp4
    • Component/s: library
    • Security Level: Public
    • Labels:
      None

      Description

      The array's returned by getMulti() are not correctly keyed or are in some other way broken. When one tries to reference the key via it's name, an "undefined index" error is returned. array_key_exists() also returns false.

      This paste has some sample code:
      https://friendpaste.com/MJS2O8G5b7kRqslp2pMBo

      Both the top and bottom cases should end in bool(true).

      avsej mentioned in IRC that these two portions of code should be compared:
      https://github.com/couchbase/php-ext-couchbase/blob/master/couchbase.c#L940
      https://github.com/php-memcached-dev/php-memcached/blob/master/php_memcached.c#L828

      Thanks for digging into this issue.

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

        Activity

        Hide
        jan Jan Lehnardt (Inactive) added a comment -

        I replaced the line in question:

        • zend_hash_add((Z_ARRVAL_P(ctx->rv)), (char *)key, nkey + 1, (void **)&v, sizeof(zval *), NULL);
          + add_assoc_zval_ex(ctx->rv, key, nkey + 1, v);

        but the result is the same:

        Notice: Undefined index: couchbase_4fb511978ac8a in /Users/jan/Work/Couchbase/src/c/php-ext-couchbase/tests/007.php on line 32

        Even though a var_dump() shows:

        array(6)

        { ["couchbase_4fb511978ac8a"]=> string(29) "couchbase_value_4fb511978ac90" ["couchbase_4fb511978ac9c"]=> string(29) "couchbase_value_4fb511978aca1" ["couchbase_4fb511978aca7"]=> string(29) "couchbase_value_4fb511978acac" ["couchbase_4fb511978acb2"]=> string(29) "couchbase_value_4fb511978acb6" ["couchbase_4fb511978acbc"]=> string(29) "couchbase_value_4fb511978acc1" ["couchbase_4fb511978acc6"]=> string(29) "couchbase_value_4fb511978accb" }
        Show
        jan Jan Lehnardt (Inactive) added a comment - I replaced the line in question: zend_hash_add((Z_ARRVAL_P(ctx->rv)), (char *)key, nkey + 1, (void **)&v, sizeof(zval *), NULL); + add_assoc_zval_ex(ctx->rv, key, nkey + 1, v); but the result is the same: Notice: Undefined index: couchbase_4fb511978ac8a in /Users/jan/Work/Couchbase/src/c/php-ext-couchbase/tests/007.php on line 32 Even though a var_dump() shows: array(6) { ["couchbase_4fb511978ac8a"]=> string(29) "couchbase_value_4fb511978ac90" ["couchbase_4fb511978ac9c"]=> string(29) "couchbase_value_4fb511978aca1" ["couchbase_4fb511978aca7"]=> string(29) "couchbase_value_4fb511978acac" ["couchbase_4fb511978acb2"]=> string(29) "couchbase_value_4fb511978acb6" ["couchbase_4fb511978acbc"]=> string(29) "couchbase_value_4fb511978acc1" ["couchbase_4fb511978acc6"]=> string(29) "couchbase_value_4fb511978accb" }
        Hide
        jan Jan Lehnardt (Inactive) added a comment -
        Show
        jan Jan Lehnardt (Inactive) added a comment - A patch is for review at http://review.couchbase.org/#change,16144
        Hide
        laruence Xinchen Hui added a comment -

        the key parameter is not null-terminated string?

        Show
        laruence Xinchen Hui added a comment - the key parameter is not null-terminated string?
        Hide
        jan Jan Lehnardt (Inactive) added a comment -

        Correct.

        Show
        jan Jan Lehnardt (Inactive) added a comment - Correct.
        Hide
        laruence Xinchen Hui added a comment -

        then I think your fix is okey. thanks

        Show
        laruence Xinchen Hui added a comment - then I think your fix is okey. thanks
        Hide
        mnunberg Mark Nunberg added a comment -

        This issue is present in set_multi as well. A test and patch have been written for it, and will soon be submitted.

        Show
        mnunberg Mark Nunberg added a comment - This issue is present in set_multi as well. A test and patch have been written for it, and will soon be submitted.
        Show
        mnunberg Mark Nunberg added a comment - http://review.couchbase.org/#/c/20449/
        Hide
        farshid Farshid Ghods (Inactive) added a comment -

        needs to be part of the next php release.

        Show
        farshid Farshid Ghods (Inactive) added a comment - needs to be part of the next php release.

          People

          • Assignee:
            mnunberg Mark Nunberg
            Reporter:
            BigBlueHat Benjamin Young
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes