Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2020-04-28 14:42:37 +0300
committerGitHub <noreply@github.com>2020-04-28 14:42:37 +0300
commit1534367810d12bc9f50571d1dde02b153dae0d6a (patch)
treecad51128990534e178bd4838b0494293fc43b4fa
parent73fe4955d77e4860acf1d7b86d3dbe4e9d9d569e (diff)
Keep last 100 characters of archive error message when error is too long (#15854)
Currently investigating some archiving issue where I can only see the first 6000 characters of the serialised archive response which looks good. However, I cannot see the any of the last characters so I can't really tell if the full response looks good or what the issue could be potentially. Therefore, changing the logic to also show the last 100 characters of the response. Tested this locally and worked for me. Makes the message technically 5 characters longer because of ` ... ` but that should be fine.
-rw-r--r--core/CronArchive.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/CronArchive.php b/core/CronArchive.php
index c039a507aa..51326e2f34 100644
--- a/core/CronArchive.php
+++ b/core/CronArchive.php
@@ -1234,8 +1234,13 @@ class CronArchive
public function logError($m)
{
if (!defined('PIWIK_ARCHIVE_NO_TRUNCATE')) {
- $m = substr($m, 0, self::TRUNCATE_ERROR_MESSAGE_SUMMARY);
$m = str_replace(array("\n", "\t"), " ", $m);
+ if (Common::mb_strlen($m) > self::TRUNCATE_ERROR_MESSAGE_SUMMARY) {
+ $numCharactersKeepFromEnd = 100;
+ $m = Common::mb_substr($m, 0, self::TRUNCATE_ERROR_MESSAGE_SUMMARY - $numCharactersKeepFromEnd)
+ . ' ... ' .
+ Common::mb_substr($m, -1 * $numCharactersKeepFromEnd);
+ }
}
$this->errors[] = $m;
$this->logger->error($m);