Fix casting on compressed attributes when value is NULL, reduce some BINKP debugging messages

This commit is contained in:
Deon George 2022-11-05 00:06:47 +11:00
parent 9721db185b
commit c7187dbb0e
2 changed files with 22 additions and 15 deletions

View File

@ -10,15 +10,15 @@ class CompressedString implements CastsAttributes
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return string
* @return string|null
*/
public function get($model, string $key, $value, array $attributes): string
public function get($model,string $key,$value,array $attributes): ?string
{
return zstd_uncompress(base64_decode($value));
return $value ? zstd_uncompress(base64_decode($value)) : NULL;
}
/**

View File

@ -306,6 +306,7 @@ final class Binkp extends BaseProtocol
Log::debug(sprintf('%s:+ binkp_recv',self::LOGKEY));
$blksz = $this->rx_size == -1 ? BinkpMessage::BLK_HDR_SIZE : $this->rx_size;
if ($this->DEBUG)
Log::debug(sprintf('%s: - binkp_recv blksize [%d] rx_size [%d].',self::LOGKEY,$blksz,$this->rx_size));
if ($blksz !== 0) {
@ -367,6 +368,7 @@ final class Binkp extends BaseProtocol
/* Next block */
} else {
ZeroLen:
if ($this->DEBUG)
Log::debug(sprintf('%s: - binkp_recv NEXT BLOCK, is_msg [%d]',self::LOGKEY,$this->is_msg));
if ($this->is_msg) {
@ -382,6 +384,7 @@ final class Binkp extends BaseProtocol
return 1;
}
if ($this->DEBUG)
Log::debug(sprintf('%s: - binkp_recv BUFFER [%d]',self::LOGKEY,strlen($this->rx_buf)));
$rc = ord(substr($this->rx_buf,0,1));
@ -477,6 +480,7 @@ final class Binkp extends BaseProtocol
$rc = 1;
}
if ($this->DEBUG)
Log::debug(sprintf('%s:= binkp_recv [%d]',self::LOGKEY,$rc));
return $rc;
@ -487,6 +491,7 @@ final class Binkp extends BaseProtocol
*/
private function binkp_send(): int
{
if ($this->DEBUG)
Log::debug(sprintf('%s:+ binkp_send - tx_left [%d]',self::LOGKEY,$this->tx_left));
if ($this->tx_left == 0 ) { /* tx buffer is empty */
@ -561,6 +566,7 @@ final class Binkp extends BaseProtocol
}
}
if ($this->DEBUG)
Log::debug(sprintf('%s:= binkp_send [1]',self::LOGKEY));
return 1;
@ -595,6 +601,7 @@ final class Binkp extends BaseProtocol
*/
private function msgs(string $id,string $msg_body): void
{
if ($this->DEBUG)
Log::debug(sprintf('%s:+ msgs [%d:%s]',self::LOGKEY,$id,$msg_body));
$this->mqueue->push(new BinkpMessage($id,$msg_body));