diff options
author | jfarrell <jfarrell@apache.org> | 2015-08-25 01:09:35 -0400 |
---|---|---|
committer | jfarrell <jfarrell@apache.org> | 2015-08-25 01:09:35 -0400 |
commit | 6949b7c96933da182fde5e40b6c493eb054a7672 (patch) | |
tree | c7ea9e5c26cd597f0ce8fca314c855985c430a5f | |
parent | f13e431babd92f08f46cbc1f32da48965e1c5ca8 (diff) | |
download | thrift-6949b7c96933da182fde5e40b6c493eb054a7672.tar.gz |
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.
-rw-r--r-- | compiler/cpp/src/generate/t_php_generator.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc index 891987741..0026d70ab 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; |