From b15ca2fbc9665fb28de559c1bcb490415c5775ae Mon Sep 17 00:00:00 2001 From: jf-cbd Date: Tue, 27 May 2025 10:41:05 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B08260=20-=20Change=20format=20of=20REST?= =?UTF-8?q?=20logs=20when=20they=20are=20close=20to=20the=20SQL=20field=20?= =?UTF-8?q?size=20limit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webservices/rest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webservices/rest.php b/webservices/rest.php index e0cbfc081..a629a4bdb 100644 --- a/webservices/rest.php +++ b/webservices/rest.php @@ -302,9 +302,17 @@ if (MetaModel::GetConfig()->Get('log_rest_service')) $iUnescapeSlashAndUnicode = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; $sJsonOuputWithPrettyPrinting = json_encode($oResult, $iUnescapeSlashAndUnicode | JSON_PRETTY_PRINT); $sJsonOutputWithoutPrettyPrinting = json_encode($oResult, $iUnescapeSlashAndUnicode); - !$oLog->StringFitsInField('json_output', $sJsonOuputWithPrettyPrinting) ? + !StringFitsInLogField( $sJsonOuputWithPrettyPrinting) ? $oLog->SetTrim('json_output', $sJsonOutputWithoutPrettyPrinting) : // too long, we don't make it pretty $oLog->SetTrim('json_output', $sJsonOuputWithPrettyPrinting); $oLog->DBInsertNoReload(); +} + +/** + * @deprecated - will be removed in 3.3.0 + */ +function StringFitsInLogField(string $sLog): bool +{ + return mb_strlen($sLog) <= 16383; // hardcoded value, see N°8260 } \ No newline at end of file