Fix casting on compressed attributes when value is NULL, reduce some BINKP debugging messages
This commit is contained in:
parent
9721db185b
commit
c7187dbb0e
@ -10,15 +10,15 @@ class CompressedString implements CastsAttributes
|
||||
/**
|
||||
* Cast the given value.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param array $attributes
|
||||
* @return string
|
||||
* @param Model $model
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param array $attributes
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@ class CompressedString implements CastsAttributes
|
||||
* @param array $attributes
|
||||
* @return string|null
|
||||
*/
|
||||
public function set($model, string $key, $value, array $attributes): ?string
|
||||
public function set($model,string $key,$value,array $attributes): ?string
|
||||
{
|
||||
return $value ? base64_encode(zstd_compress($value)) : NULL;
|
||||
}
|
||||
|
@ -306,7 +306,8 @@ 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;
|
||||
Log::debug(sprintf('%s: - binkp_recv blksize [%d] rx_size [%d].',self::LOGKEY,$blksz,$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) {
|
||||
try {
|
||||
@ -367,7 +368,8 @@ final class Binkp extends BaseProtocol
|
||||
/* Next block */
|
||||
} else {
|
||||
ZeroLen:
|
||||
Log::debug(sprintf('%s: - binkp_recv NEXT BLOCK, is_msg [%d]',self::LOGKEY,$this->is_msg));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_recv NEXT BLOCK, is_msg [%d]',self::LOGKEY,$this->is_msg));
|
||||
|
||||
if ($this->is_msg) {
|
||||
$this->mib++;
|
||||
@ -382,7 +384,8 @@ final class Binkp extends BaseProtocol
|
||||
return 1;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s: - binkp_recv BUFFER [%d]',self::LOGKEY,strlen($this->rx_buf)));
|
||||
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,7 +480,8 @@ final class Binkp extends BaseProtocol
|
||||
$rc = 1;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:= binkp_recv [%d]',self::LOGKEY,$rc));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:= binkp_recv [%d]',self::LOGKEY,$rc));
|
||||
|
||||
return $rc;
|
||||
}
|
||||
@ -487,7 +491,8 @@ final class Binkp extends BaseProtocol
|
||||
*/
|
||||
private function binkp_send(): int
|
||||
{
|
||||
Log::debug(sprintf('%s:+ binkp_send - tx_left [%d]',self::LOGKEY,$this->tx_left));
|
||||
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 */
|
||||
$this->tx_ptr = $this->tx_left = 0;
|
||||
@ -561,7 +566,8 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:= binkp_send [1]',self::LOGKEY));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:= binkp_send [1]',self::LOGKEY));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -595,7 +601,8 @@ final class Binkp extends BaseProtocol
|
||||
*/
|
||||
private function msgs(string $id,string $msg_body): void
|
||||
{
|
||||
Log::debug(sprintf('%s:+ msgs [%d:%s]',self::LOGKEY,$id,$msg_body));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:+ msgs [%d:%s]',self::LOGKEY,$id,$msg_body));
|
||||
|
||||
$this->mqueue->push(new BinkpMessage($id,$msg_body));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user