nrk/phpiredis

String values with space

Closed this issue · 11 comments

Hi there,

guys, I can't run the following command because the " is not
understand as delimiter for the 3. parameter.

phpphpiredis_command($redis, 'SET user "Foo bar"');

Did I miss something?

Cheers

nrk commented

Hi @fightbulc,

You should really use phpiredis_command_bs since phpiredis_command is not safe to use (we should just remove it IMHO). phpiredis_command_bs accepts an array instead of a string with each command argument being an element of the array:

<?php

$redis = phpiredis_connect("127.0.0.1");
phpiredis_command_bs($redis, array("SET", "user", "Foo bar"));

Hi Daniele, thanks for the prompt answer. I've noticed that _bs was working but how could I use then the pipeline feature? I assumed multi_command would do the trick.

cheers
Tino

Tino Ehrich
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Friday, 23. November 2012 at 19:23, Daniele Alessandri wrote:

Hi @fightbulc (https://github.com/fightbulc),
You should really use phpiredis_command_bs since phpiredis_command is not safe to use (we should just remove it IMHO). phpiredis_command_bs accepts an array instead of a string with each command argument being an element of the array:

nrk commented

Good catch, there's indeed no way to pipeline commands in a binary-safe way right now. I'll try implementing a phpiredis_multi_command_bs function this weekend.

Nice one! Looking forward.

Cheers

Morning nrk,

any success over the weekend?

Cheers from Berlin

nrk commented

Heya @fightbulc,

sorry for being late but in the end I didn't have much time last weekend to hack on phpiredis, but anyway now I got phpiredis_multi_command_bs() implemented in the multi_command_bs branch. If you can give it a try and confirm that everything works I'll merge that branch into master.

Thanks!

Heyho @nrk,

no worries. I will give it a try today and let you know about the outcome.

Really appreciate your taken time.

Thanks!
Cheers

@nrk, on my mac installing went smooth.

On my gentoo machine not quite because I got thrown off by test fails.
I simply got failed tests although compilation went find. After a couple
of reinstalls without any effect on the result I assumed that you might
forgot about adjusting the tests. So I ran my application and all
seems to run as expected.

Any idea?

Find below the test summary.

Cheers
Tino

TEST RESULT SUMMARY

Exts skipped : 0

Exts tested : 44

Number of tests : 25 25
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 10 ( 40.0%) ( 40.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)

Tests passed : 15 ( 60.0%) ( 60.0%)

Time taken : 1 seconds

FAILED TEST SUMMARY

phpiredis connect [tests/001.phpt]
phpiredis command [tests/002.phpt]
phpiredis multicommand [tests/003.phpt]
phpiredis array [tests/004.phpt]
phpiredis multicommand [tests/005.phpt]
phpiredis command binary safe [tests/006.phpt]
phpiredis command binary safe using image [tests/007.phpt]
phpiredis reconnect on disconnect [tests/008.phpt]
phpiredis reconnect on disconnect [tests/009.phpt]

phpiredis multicommand (binary safe) [tests/025.phpt]

nrk commented

@fightbulc yeah the failed tests are most likely unrelated, the fact that your failed tests are the ones opening a connection to Redis makes me think that you have something that blocks connections to port 6379 on localhost on your gentoo machine or Redis is bound to a different port than the standard one as I can't really think of a different reason.

I'll merge that branch into master anyway, thanks for the feedback!

@nrk, you're right. The server is bound to a different IP.

nrk commented

@fightbulc alright thanks for confirming it wasn't a bug or anything :-)