Skip to content

Commit

Permalink
Cast response content to string
Browse files Browse the repository at this point in the history
  • Loading branch information
guvra committed Oct 11, 2022
1 parent 65c5b33 commit bd7cb3c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Block/Zone/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getEsiUrlList(): array
$list = [];

$pattern = '/<esi:include[\s]+[^>]*src=[\'"]([^\'"]+)[\'"][^>]*>/';
if (preg_match_all($pattern, $this->response->getContent(), $matches)) {
if (preg_match_all($pattern, (string) $this->response->getContent(), $matches)) {
$list = $matches[1];
}

Expand Down
4 changes: 2 additions & 2 deletions Observer/AddToolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ private function buildToolbar(

// Add the last toolbars to the content
if ($area === Area::AREA_FRONTEND || $area === Area::AREA_ADMINHTML && $this->configHelper->isEnabledAdmin()) {
$content = $response->getContent();
$content = (string) $response->getContent();
$endTag = '</body';
if (strpos($content, $endTag) !== false) {
if (str_contains($content, $endTag)) {
$toolbarsContent = $this->getToolbarsBlock()->toHtml();
$content = str_replace($endTag, $toolbarsContent . $endTag, $content);
$response->setContent($content);
Expand Down
2 changes: 1 addition & 1 deletion view/base/templates/zone/response.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Smile\DebugToolbar\Block\Zone\Response;
/** @var Response $block */
$response = $block->getResponse();

$length = mb_strlen($response->getContent());
$length = mb_strlen((string) $response->getContent());

$headers = [];
foreach ($response->getHeaders() as $header) {
Expand Down

0 comments on commit bd7cb3c

Please sign in to comment.