diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c
index f8c4f0423f2..60c94412dce 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 df4a5d51624..ae9a9897fcd 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 79a0a79d3a1..9c98f825403 100644
--- a/src/php/ext/grpc/package.xml
+++ b/src/php/ext/grpc/package.xml
@@ -10,8 +10,8 @@
grpc-packages@google.com
yes
- 2015-12-15
-
+ 2015-12-16
+
0.7.0
0.7.0
@@ -25,6 +25,7 @@
- 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
@@ -34,9 +35,9 @@
-
+
-
+
@@ -141,12 +142,13 @@ Update to wrap gRPC C Core version 0.10.0
beta
beta
- 2015-12-15
+ 2015-12-16
BSD
- 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
diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php
index c80cf4464e5..712af91eb28 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 8e9dedf73b5..2de1b337e53 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 aa6906192ff..1fe81b9d549 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 7043e8e1d1b..0cdce6cf924 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 5a20e684c73..6bb1955ccb1 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 ee604a387cc..aebf80f6bf0 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',