diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/php/ext/grpc/channel.c | 12 | ||||
-rw-r--r-- | src/php/ext/grpc/channel_credentials.c | 10 | ||||
-rw-r--r-- | src/php/ext/grpc/package.xml | 43 | ||||
-rw-r--r-- | src/php/lib/Grpc/AbstractCall.php | 11 | ||||
-rwxr-xr-x | src/php/lib/Grpc/BaseStub.php | 5 | ||||
-rw-r--r-- | src/php/tests/generated_code/AbstractGeneratedCodeTest.php | 4 | ||||
-rwxr-xr-x | src/php/tests/generated_code/GeneratedCodeTest.php | 6 | ||||
-rw-r--r-- | src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php | 5 | ||||
-rwxr-xr-x | src/php/tests/interop/interop_client.php | 2 |
9 files changed, 78 insertions, 20 deletions
diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index f8c4f0423f..60c94412dc 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -154,16 +154,20 @@ PHP_METHOD(Channel, __construct) { array_hash = Z_ARRVAL_P(args_array); if (zend_hash_find(array_hash, "credentials", sizeof("credentials"), (void **)&creds_obj) == SUCCESS) { - if (zend_get_class_entry(*creds_obj TSRMLS_CC) != + if (Z_TYPE_P(*creds_obj) == IS_NULL) { + creds = NULL; + zend_hash_del(array_hash, "credentials", 12); + } else if (zend_get_class_entry(*creds_obj TSRMLS_CC) != grpc_ce_channel_credentials) { zend_throw_exception(spl_ce_InvalidArgumentException, "credentials must be a ChannelCredentials object", 1 TSRMLS_CC); return; + } else { + creds = (wrapped_grpc_channel_credentials *)zend_object_store_get_object( + *creds_obj TSRMLS_CC); + zend_hash_del(array_hash, "credentials", 12); } - creds = (wrapped_grpc_channel_credentials *)zend_object_store_get_object( - *creds_obj TSRMLS_CC); - zend_hash_del(array_hash, "credentials", 12); } php_grpc_read_args_array(args_array, &args); if (creds == NULL) { diff --git a/src/php/ext/grpc/channel_credentials.c b/src/php/ext/grpc/channel_credentials.c index df4a5d5162..ae9a9897fc 100644 --- a/src/php/ext/grpc/channel_credentials.c +++ b/src/php/ext/grpc/channel_credentials.c @@ -169,6 +169,14 @@ PHP_METHOD(ChannelCredentials, createComposite) { RETURN_DESTROY_ZVAL(creds_object); } +/** + * Create insecure channel credentials + * @return null + */ +PHP_METHOD(ChannelCredentials, createInsecure) { + RETURN_NULL(); +} + static zend_function_entry channel_credentials_methods[] = { PHP_ME(ChannelCredentials, createDefault, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) @@ -176,6 +184,8 @@ static zend_function_entry channel_credentials_methods[] = { ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(ChannelCredentials, createComposite, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(ChannelCredentials, createInsecure, NULL, + ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_FE_END}; void grpc_init_channel_credentials(TSRMLS_D) { diff --git a/src/php/ext/grpc/package.xml b/src/php/ext/grpc/package.xml index a2e3e2826a..9c98f82540 100644 --- a/src/php/ext/grpc/package.xml +++ b/src/php/ext/grpc/package.xml @@ -10,11 +10,11 @@ <email>grpc-packages@google.com</email> <active>yes</active> </lead> - <date>2015-10-21</date> - <time>17:04:32</time> + <date>2015-12-16</date> + <time>12:56:11</time> <version> - <release>0.6.1</release> - <api>0.6.0</api> + <release>0.7.0</release> + <api>0.7.0</api> </version> <stability> <release>beta</release> @@ -22,19 +22,22 @@ </stability> <license>BSD</license> <notes> -- fixed undefined constant fatal error when run with apache/nginx #2275 +- Breaking change to Credentials class (removed) #3765 +- Replaced by ChannelCredentials and CallCredentials class #3765 +- New plugin based metadata auth API #4394 +- Explicit ChannelCredentials::createInsecure() call </notes> <contents> <dir baseinstalldir="/" name="/"> <file baseinstalldir="/" md5sum="6f19828fb869b7b8a590cbb76b4f996d" name="byte_buffer.c" role="src" /> <file baseinstalldir="/" md5sum="c8de0f819499c48adfc8d7f472c0196b" name="byte_buffer.h" role="src" /> - <file baseinstalldir="/" md5sum="d64c9005993de02abac55664b0b9e0b2" name="call.c" role="src" /> - <file baseinstalldir="/" md5sum="26acbf04c30162c2d2aca4688bb2aec8" name="call.h" role="src" /> - <file baseinstalldir="/" md5sum="6fa13d260dfde216f795225644f04e7a" name="call_credentials.c" role="src" /> - <file baseinstalldir="/" md5sum="e45269975f9a30fd349a90daf6b31aa2" name="call_credentials.h" role="src" /> - <file baseinstalldir="/" md5sum="0779db3b196c98081b2260ceec22cd4d" name="channel.c" role="src" /> + <file baseinstalldir="/" md5sum="ee7eb7757f9e6f0e36f8f616b6bd0af5" name="call.c" role="src" /> + <file baseinstalldir="/" md5sum="44c56bd9912d2538cbd6059e3e0452b6" name="call.h" role="src" /> + <file baseinstalldir="/" md5sum="ff90f6c03ed44b5f4170bf3259a6704e" name="call_credentials.c" role="src" /> + <file baseinstalldir="/" md5sum="3c3860e1d84f43cb6b2fbaa8d2ae1ab7" name="call_credentials.h" role="src" /> + <file baseinstalldir="/" md5sum="aee9b63f790522aec2c682055240cc61" name="channel.c" role="src" /> <file baseinstalldir="/" md5sum="ed4b00c0cf3702b115d0cfa87450dc09" name="channel.h" role="src" /> - <file baseinstalldir="/" md5sum="1b40f50fa6184ad7d24a961ac76151ff" name="channel_credentials.c" role="src" /> + <file baseinstalldir="/" md5sum="1a51c76d0b7b7d3ab570ed7d60c2ea46" name="channel_credentials.c" role="src" /> <file baseinstalldir="/" md5sum="a86250e03f610ce6c2c7595a84e08821" name="channel_credentials.h" role="src" /> <file baseinstalldir="/" md5sum="55ab7a42f9dd9bfc7e28a61cfc5fca63" name="completion_queue.c" role="src" /> <file baseinstalldir="/" md5sum="f10b5bb232d74a6878e829e2e76cdaa2" name="completion_queue.h" role="src" /> @@ -130,5 +133,23 @@ Update to wrap gRPC C Core version 0.10.0 - fixed undefined constant fatal error when run with apache/nginx #2275 </notes> </release> + <release> + <version> + <release>0.7.0</release> + <api>0.7.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <date>2015-12-16</date> + <license>BSD</license> + <notes> +- Breaking change to Credentials class (removed) #3765 +- Replaced by ChannelCredentials and CallCredentials class #3765 +- New plugin based metadata auth API #4394 +- Explicit ChannelCredentials::createInsecure() call + </notes> + </release> </changelog> </package> diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php index c80cf4464e..712af91eb2 100644 --- a/src/php/lib/Grpc/AbstractCall.php +++ b/src/php/lib/Grpc/AbstractCall.php @@ -114,4 +114,15 @@ abstract class AbstractCall return call_user_func($this->deserialize, $value); } + + /** + * Set the CallCredentials for the underlying Call. + * + * @param CallCredentials $call_credentials The CallCredentials + * object + */ + public function setCallCredentials($call_credentials) + { + $this->call->setCredentials($call_credentials); + } } diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index 8e9dedf73b..2de1b337e5 100755 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -72,6 +72,11 @@ class BaseStub } $opts['grpc.primary_user_agent'] .= 'grpc-php/'.$package_config['version']; + if (!array_key_exists('credentials', $opts)) { + throw new \Exception("The opts['credentials'] key is now ". + 'required. Please see one of the '. + 'ChannelCredentials::create methods'); + } $this->channel = new Channel($hostname, $opts); } diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php index aa6906192f..1fe81b9d54 100644 --- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php +++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php @@ -111,7 +111,9 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase */ public function testInvalidMethodName() { - $invalid_client = new DummyInvalidClient('host', []); + $invalid_client = new DummyInvalidClient('host', [ + 'credentials' => Grpc\ChannelCredentials::createInsecure(), + ]); $div_arg = new math\DivArgs(); $invalid_client->InvalidUnaryCall($div_arg); } diff --git a/src/php/tests/generated_code/GeneratedCodeTest.php b/src/php/tests/generated_code/GeneratedCodeTest.php index 7043e8e1d1..0cdce6cf92 100755 --- a/src/php/tests/generated_code/GeneratedCodeTest.php +++ b/src/php/tests/generated_code/GeneratedCodeTest.php @@ -38,10 +38,12 @@ class GeneratedCodeTest extends AbstractGeneratedCodeTest public function setUp() { self::$client = new math\MathClient( - getenv('GRPC_TEST_HOST'), []); + getenv('GRPC_TEST_HOST'), [ + 'credentials' => Grpc\ChannelCredentials::createInsecure(), + ]); } - public static function tearDownAfterClass() + public function tearDown() { self::$client->close(); } diff --git a/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php b/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php index 5a20e684c7..6bb1955ccb 100644 --- a/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php +++ b/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php @@ -39,7 +39,8 @@ class GeneratedCodeWithCallbackTest extends AbstractGeneratedCodeTest { self::$client = new math\MathClient( getenv('GRPC_TEST_HOST'), - ['update_metadata' => function ($a_hash, + ['credentials' => Grpc\ChannelCredentials::createInsecure(), + 'update_metadata' => function ($a_hash, $client = []) { $a_copy = $a_hash; $a_copy['foo'] = ['bar']; @@ -48,7 +49,7 @@ class GeneratedCodeWithCallbackTest extends AbstractGeneratedCodeTest }]); } - public static function tearDownAfterClass() + public function tearDown() { self::$client->close(); } diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index ee604a387c..aebf80f6bf 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -438,6 +438,8 @@ if ($use_tls) { } $opts['credentials'] = $ssl_credentials; $opts['grpc.ssl_target_name_override'] = $host_override; +} else { + $opts['credentials'] = Grpc\ChannelCredentials::createInsecure(); } if (in_array($test_case, ['service_account_creds', |