New release for PHP SDK?

#1

Hi,

It looks like the current version of PHP SDK does not work with prepared statement.

I get the following error with 2.1 version

“Unrecognized parameter in request: 0”

When I clone the master branch from github and build it myself, everything works just fine.

When do we expect to see a new version for PHP SDK? or is there a way get around the error message in v2.1?

Update: It looks like there is no way to get around it.

It should be $data[’$’.$key] = $value; I see that this fix is already in the master branch.

#2

hey @brett19 can you advise ? Thanks

#3

Hey moon0326,
We currently have a PHP release targeted for the beginning of March.
Cheers, Brett

#4

Hey @brett19

I understand that we can build the master manually for the fix, but don’t you think March is a little bit late?

This is obviously a bug for a major feature in Couchbase 4 and the fix is really really easy. It’s one character change. I don’t really understand the decision behind March release. This is perfectly fine for a minor update in my opinion.

#5

We’ve been in the process of updating a few things on build and test infrastructure @moon0326 and we wanted to have that in place for the next release. Indeed, a one character change is seemingly simple but we’d also had a couple of other larger changes planned for the release that need the full build/test infrastructure.

Maybe to get you unblocked, we can put together a build from what’s being worked on for the March release and you can verify that it relieves the issues for you? What PHP version, and OS are you looking for?

I don’t know if you’ve worked with PECL extensions before, but between the varying platforms and versions, we run into situations where something that seems like an obvious fix on one version of PHP 5.x won’t work on another platform.

#6

Thank you @ingenthr for the follow up.

I understand that there is a release schedule/plan. My only complaint was that n1ql is such a major feature in Couchbase 4 and It is a little bit let down that I can’t even use n1ql correctly with PHP SDK that was released months ago just because there was no test for the SDK to check a mistake.

I decided to hack around it. I think I’m good for now. Below is the new query method I’m using.

  private function query($queryObj, array $params, $json_asarray = false)
    {
        $m = $this->bucket->manager();
        $manager = new \ReflectionClass($m);
        $property = $manager->getProperty('_me');
        $property->setAccessible(true);
        $me = $property->getValue($m);

        $data = $queryObj->options;
        if (is_array($params)) {
            foreach ($params as $key => $value) {
                $data['$'.$key] = $value;
            }
        }

        $dataStr = json_encode($data, true);
        $dataOut = $me->n1ql_request($dataStr, $queryObj->adhoc);

        $meta = json_decode($dataOut['meta'], true);
        if (isset($meta['errors']) && count($meta['errors']) > 0) {
            $err = $meta['errors'][0];
            $ex = new \CouchbaseException($err['msg']);
            $ex->qCode = $err['code'];
            throw $ex;
        }

        $rows = array();
        foreach ($dataOut['results'] as $row) {
            $rows[] = json_decode($row, $json_asarray);
        }

        return $rows;
    }
#7

Hey @moon0326,

This is quite a clever workaround, a bit of a hack, but definitely clever. Note that a possible ‘simpler’ workaround would be to use the query method itself and then simply wrap the results to re-encode. For instance:

$results = $bucket->query($query, $params, false);
$results = json_decode(json_encode($results), true);

Cheers, Brett

#8

Hello @brett19, @ingenthr, @czajkowski

It is already mid April and I don’t think there is a new release that fixes the problem discussed in this thread.

Couchbase 4.5 DP is out with bunch of new features including new additions for n1ql.

I don’t understand how this little, but important bug cannot be fixed after 2 months+. Couchbase has been pushing n1ql forward and yet…PHP users cannot even use the most basic feature without hacking around the official SDK.

Do you have any release plan before Q2?

#9

The work on PHP7 ended up being a larger task than expected. We updated the release plans just recently and maintain our roadmap there on JIRA.

Right now there are a number of people building from source and we’re working toward a 2.2.0 Beta, followed by another beta with more 4.5 supporting features followed by a GA to support 4.5’s release.

(p.s.: Q2 started about 11 days ago :wink: )

#10

Thank you for the update and Q2 :slight_smile:

Don’t you consider this bug as a major though? It basically prevents you from using n1ql correctly.

one byte change (literally), + to . fixes this issue. I really don’t think it has anything to do php 7 support. Many people are going to use PHP 5 version for quite while.

I don’t know at this point. May be I’m the one who is using n1ql parameter binding (?) with php or I’m asking too much.

#11

I agree it’s a small change. That said, there is a workaround (you documented it!) and the branch had other changes in it that needed testing. Our new testing necessitated changes in our build infrastructure. The good news is that all of that is done now and we’re moving forward on our next update which will have this fix and a number of others.

The process we have, which has worked for us, is to have a regular cadence of releases that roll up fixes so we can test it well, update docs regularly, etc. We’re behind on PHP, but going to catch up.

#12

I understand. I will stick to the workaround.

I have to point out something though. I don’t think you are releasing regularly.

Last release was made on Nov, 15 and the 2.2.0 is planned to be released on June. I don’t think 8 months+ is considered as a regular release cycle.

It would be nice if you actually start releasing regularly.

Thank you for the follow up. I appreciate it.

Thanks,
Moon

#13

Yes, we definitely need to be releasing more regularly with PHP and that’s our plan. It should be better in the coming weeks and months.