Query view returns null if key contains + (PHP SDK 2.0.4 and 2.0.5)


#1

The view returns correct response when using curl or when using admin console but not via PHP SDK 2.0.4 or 2.0.5.

If urlencoded or not in the admin console then it returns the expected JSON.
If urlencoded or not via curl it returns the expected JSON.
If urlencoded or not in the PHP SDK then it returns null.

Without “+”:
$key = ‘abc123’;
$viewQuery = \CouchbaseViewQuery::from(‘connections’, ‘byUserId’)
->key($key)
->stale(\CouchbaseViewQuery::UPDATE_BEFORE);
$view = $bucket->query($viewQuery);

// $view = [“total_rows” => 400, “rows” => []]

With “+”:
$key = ‘abc+123’;
$viewQuery = \CouchbaseViewQuery::from(‘connections’, ‘byUserId’)
->key($key)
->stale(\CouchbaseViewQuery::UPDATE_BEFORE);
$view = $bucket->query($viewQuery);

// $view = null

With urlencoded “+”:
$key = ‘abc%2b123’;
$viewQuery = \CouchbaseViewQuery::from(‘connections’, ‘byUserId’)
->key($key)
->stale(\CouchbaseViewQuery::UPDATE_BEFORE);
$view = $bucket->query($viewQuery);

// $view = null


#2

Hey robedarling,

Internally we perform all of the necessary marshalling. If you are looking to retrieve the key abc 123, you would need to send exactly that, no need to encode the spaces.

Cheers, Brett


#3

Hey Brett,

We have some users with emails that have a + in them. So we are not trying to encode spaces. ie. Rob+test@gmail.com
this returns null when using the php sdk (which is not expected) but using curl or admin console works as expected.