Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.9.1
-
Patch Available
Description
On flush in the php implementation of the TBufferedTransport it doesn't clear the internal buffer before calling the underlying write function. However the write function in TBufferedTransport does.
TBufferedTransport.php
public function write($buf) { $this->wBuf_ .= $buf; if (TStringFuncFactory::create()->strlen($this->wBuf_) >= $this->wBufSize_) { $out = $this->wBuf_; // Note that we clear the internal wBuf_ prior to the underlying write // to ensure we're in a sane state (i.e. internal buffer cleaned) // if the underlying write throws up an exception $this->wBuf_ = ''; $this->transport_->write($out); } } public function flush() { if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) { $this->transport_->write($this->wBuf_); $this->wBuf_ = ''; } $this->transport_->flush(); }
If a write on the underlying transport fails when we call flush, the internal buffer won't be cleared.
This causes some interesting issues when this happens. If you happen to call the same function twice (first call fails to write, but the second one succeeds), it will call the function on the server with the data provided in the first call, rather than your current call.