Repository: thrift
Updated Branches:
  refs/heads/master f13e431ba -> 6949b7c96


THRIFT-2981: IDL with no namespace produces unparsable PHP
Client: php
Patch: Randy Abernethy

The compiler is generating the namespace statement even when there isn't one, 
which blows up the PHP interpreter. Patch supresses service and type file 
output of namespace unless there actually is one.


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/6949b7c9
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/6949b7c9
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/6949b7c9

Branch: refs/heads/master
Commit: 6949b7c96933da182fde5e40b6c493eb054a7672
Parents: f13e431
Author: jfarrell <[email protected]>
Authored: Tue Aug 25 01:09:35 2015 -0400
Committer: jfarrell <[email protected]>
Committed: Tue Aug 25 01:09:35 2015 -0400

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_php_generator.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/6949b7c9/compiler/cpp/src/generate/t_php_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_php_generator.cc 
b/compiler/cpp/src/generate/t_php_generator.cc
index 8919877..0026d70 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -397,7 +397,9 @@ void t_php_generator::init_generator() {
 
   // Print header
   f_types_ << "<?php" << endl;
-  f_types_ << "namespace " << php_namespace_suffix(get_program()) << ";" << 
endl << endl;
+  if ( ! php_namespace_suffix(get_program()).empty() )  {
+    f_types_ << "namespace " << php_namespace_suffix(get_program()) << ";" << 
endl << endl;
+  }
   f_types_ << autogen_comment() << php_includes();
 
   f_types_ << endl;
@@ -1143,7 +1145,9 @@ void t_php_generator::generate_service(t_service* 
tservice) {
   f_service_.open(f_service_name.c_str());
 
   f_service_ << "<?php" << endl;
-  f_service_ << "namespace " << php_namespace_suffix(tservice->get_program()) 
<< ";" << endl;
+  if ( ! php_namespace_suffix(tservice->get_program()).empty() ) {
+    f_service_ << "namespace " << 
php_namespace_suffix(tservice->get_program()) << ";" << endl;
+  }
   f_service_ << autogen_comment() << php_includes();
 
   f_service_ << endl;

Reply via email to