PluginOutput: Limit length to 1000 by default

This commit is contained in:
Johannes Meyer 2024-03-22 11:23:45 +01:00
parent a0344491a4
commit 1564c3bbbc
4 changed files with 42 additions and 11 deletions

View file

@ -64,6 +64,9 @@ class PluginOutput extends HtmlString
/** @var bool Whether the output contains HTML */
protected $isHtml;
/** @var int The maximum amount of characters to process */
protected $characterLimit = 1000;
/** @var bool Whether output will be enriched */
protected $enrichOutput = true;
@ -93,6 +96,20 @@ class PluginOutput extends HtmlString
return $this->isHtml;
}
/**
* Set the maximum amount of characters to process
*
* @param int $limit
*
* @return $this
*/
public function setCharacterLimit(int $limit): self
{
$this->characterLimit = $limit;
return $this;
}
/**
* Set whether the output should be enriched
*
@ -185,6 +202,10 @@ class PluginOutput extends HtmlString
$output = $this->processHtml($output);
}
if ($this->characterLimit) {
$output = substr($output, 0, $this->characterLimit);
}
$this->renderedOutput = $output;
return $output;

View file

@ -125,6 +125,11 @@ parameters:
count: 1
path: library/Icingadb/Util/PerfData.php
-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Util\\\\PluginOutput\\:\\:render\\(\\) should return string but returns string\\|false\\|null\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Parameter \\#1 \\$str of function trim expects string, string\\|null given\\.$#"
count: 1
@ -135,6 +140,11 @@ parameters:
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Util\\\\PluginOutput\\:\\:\\$renderedOutput \\(string\\) does not accept string\\|false\\|null\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#"
count: 1

View file

@ -125,11 +125,21 @@ parameters:
count: 1
path: library/Icingadb/Util/PerfData.php
-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Util\\\\PluginOutput\\:\\:render\\(\\) should return string but returns string\\|null\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|null given\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Util\\\\PluginOutput\\:\\:\\$renderedOutput \\(string\\) does not accept string\\|null\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#"
count: 1

View file

@ -5040,11 +5040,6 @@ parameters:
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Util\\\\PluginOutput\\:\\:render\\(\\) should return string but returns string\\|null\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Parameter \\#1 \\$html of method Icinga\\\\Module\\\\Icingadb\\\\Util\\\\PluginOutput\\:\\:processHtml\\(\\) expects string, string\\|null given\\.$#"
count: 1
@ -5067,7 +5062,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|null given\\.$#"
count: 2
count: 3
path: library/Icingadb/Util/PluginOutput.php
-
@ -5075,11 +5070,6 @@ parameters:
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Property Icinga\\\\Module\\\\Icingadb\\\\Util\\\\PluginOutput\\:\\:\\$renderedOutput \\(string\\) does not accept string\\|null\\.$#"
count: 1
path: library/Icingadb/Util/PluginOutput.php
-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Web\\\\Control\\\\GridViewModeSwitcher\\:\\:getTitle\\(\\) should return string but returns string\\|null\\.$#"
count: 1