Jens Geyer created THRIFT-6363:
----------------------------------
Summary: PHP generator: the inlined service client and processor
fail on every call
Key: THRIFT-6363
URL: https://issues.apache.org/jira/browse/THRIFT-6363
Project: Thrift
Issue Type: Bug
Components: PHP - Compiler
Reporter: Jens Geyer
With {{--gen php:inlined}}, the generated service client and processor cannot
be used.
Since THRIFT-6004 (0.24.0) the client constructor takes protocols,
{{\_\_construct(TProtocol $input, ?TProtocol $output = null)}}. The inlined
{{send\_\*}} methods still write the packed call with
{{$this->output->write($buff)}} and {{$this->output->flush()}}, which are
transport methods. So a client built on a protocol fails on its first call, and
one built on a transport fails in the constructor:
{noformat}
Error: Call to undefined method Thrift\Protocol\TBinaryProtocol::write()
TypeError: Calc\CalcClient::__construct(): Argument #1 ($input) must be of type
Thrift\Protocol\TProtocol, Thrift\Transport\TMemoryBuffer given
{noformat}
The processor's {{process(TProtocol $input, TProtocol $output)}} reads the
message header inline from {{$this->input}}, a property the processor does not
have, and writes the reply with {{$output->write($buff)}}:
{noformat}
Warning: Undefined property: Calc\CalcProcessor::$input
Error: Call to a member function readAll() on null
{noformat}
Seen with PHP 8.4.25 and the {{lib/php}} of master, with code generated by
{{--gen php:inlined,server}} from:
{code}
namespace php Calc
service Calc { i32 add(1: i32 a, 2: i32 b) }
{code}
Only the service code is affected; the struct classes are generated separately.
There are two ways to fix this:
# Repair the inlined client and processor: write to the transports under the
given protocols, and read the header from the local {{$input}}.
# Stop generating inlined service code and keep {{inlined}} for the struct
classes only. The inlined client has not worked since 0.24.0.
Which one is preferred?
_Drafted with AI assistance (Claude Opus 5.5); reviewed and filed by Jens
Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)