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-02-07 01:19:10 +0300
committerGitHub <noreply@github.com>2020-02-07 01:19:10 +0300
commit40d169fe7c67993292f5e64498cd5b22d9fcc75f (patch)
treea61ee40372831067abf125bfc72c7d17aec54bb5
parent76ac42c23dea9d098c24be1bade6f81c1dcd1a0f (diff)
Reduce risk of segmentation fault in visit log (#15471)
-rw-r--r--core/View.php31
-rw-r--r--plugins/Contents/VisitorDetails.php2
m---------plugins/CustomDimensions0
-rw-r--r--plugins/Events/VisitorDetails.php1
-rw-r--r--plugins/Live/VisitorDetails.php4
m---------plugins/MarketingCampaignsReporting0
-rw-r--r--plugins/Referrers/VisitorDetails.php1
7 files changed, 29 insertions, 10 deletions
diff --git a/core/View.php b/core/View.php
index d59ac66970..14d8dd166d 100644
--- a/core/View.php
+++ b/core/View.php
@@ -123,6 +123,15 @@ class View implements ViewInterface
private $useStrictReferrerPolicy = true;
/**
+ * Can be disabled to not send headers when rendering a view. This can be useful if heaps of views are being
+ * rendered during one request to possibly prevent a segmentation fault see eg #15307 . It should not be disabled
+ * for a main view, but could be disabled for views that are being rendered eg during a twig event as a "subview" which
+ * is part of the "main view".
+ * @var bool
+ */
+ public $sendHeadersWhenRendering = true;
+
+ /**
* Constructor.
*
* @param string $templateFile The template file to load. Must be in the following format:
@@ -274,18 +283,20 @@ class View implements ViewInterface
// can fail, for example at installation (no plugin loaded yet)
}
- ProxyHttp::overrideCacheControlHeaders('no-store');
+ if ($this->sendHeadersWhenRendering) {
+ ProxyHttp::overrideCacheControlHeaders('no-store');
- Common::sendHeader('Content-Type: ' . $this->contentType);
- // always sending this header, sometimes empty, to ensure that Dashboard embed loads
- // - when calling sendHeader() multiple times, the last one prevails
- if(!empty($this->xFrameOptions)) {
- Common::sendHeader('X-Frame-Options: ' . (string)$this->xFrameOptions);
- }
+ Common::sendHeader('Content-Type: ' . $this->contentType);
+ // always sending this header, sometimes empty, to ensure that Dashboard embed loads
+ // - when calling sendHeader() multiple times, the last one prevails
+ if(!empty($this->xFrameOptions)) {
+ Common::sendHeader('X-Frame-Options: ' . (string)$this->xFrameOptions);
+ }
- // don't send Referer-Header for outgoing links
- if (!empty($this->useStrictReferrerPolicy)) {
- Common::sendHeader('Referrer-Policy: same-origin');
+ // don't send Referer-Header for outgoing links
+ if (!empty($this->useStrictReferrerPolicy)) {
+ Common::sendHeader('Referrer-Policy: same-origin');
+ }
}
return $this->renderTwigTemplate();
diff --git a/plugins/Contents/VisitorDetails.php b/plugins/Contents/VisitorDetails.php
index acf3363d38..110966f986 100644
--- a/plugins/Contents/VisitorDetails.php
+++ b/plugins/Contents/VisitorDetails.php
@@ -31,6 +31,7 @@ class VisitorDetails extends VisitorDetailsAbstract
}
$view = new View('@Contents/_actionContent.twig');
+ $view->sendHeadersWhenRendering = false;
$view->action = $action;
$view->previousAction = $previousAction;
$view->visitInfo = $visitorDetails;
@@ -44,6 +45,7 @@ class VisitorDetails extends VisitorDetailsAbstract
}
$view = new View('@Contents/_actionTooltip');
+ $view->sendHeadersWhenRendering = false;
$view->action = $action;
return [[ 10, $view->render() ]];
}
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions
-Subproject 4df349ed91d001372311041ae0f6d593533ab56
+Subproject 16cda6608a317c283521b35bed014f8d1a2b22d
diff --git a/plugins/Events/VisitorDetails.php b/plugins/Events/VisitorDetails.php
index 7f9af081ef..5e58b3fc0c 100644
--- a/plugins/Events/VisitorDetails.php
+++ b/plugins/Events/VisitorDetails.php
@@ -65,6 +65,7 @@ class VisitorDetails extends VisitorDetailsAbstract
}
$view = new View('@Events/_actionEvent.twig');
+ $view->sendHeadersWhenRendering = false;
$view->action = $action;
$view->previousAction = $previousAction;
$view->visitInfo = $visitorDetails;
diff --git a/plugins/Live/VisitorDetails.php b/plugins/Live/VisitorDetails.php
index 37b3c71215..b6d51c0be7 100644
--- a/plugins/Live/VisitorDetails.php
+++ b/plugins/Live/VisitorDetails.php
@@ -96,6 +96,7 @@ class VisitorDetails extends VisitorDetailsAbstract
$sitesModel = new \Piwik\Plugins\SitesManager\Model();
$view = new View($template);
+ $view->sendHeadersWhenRendering = false;
$view->mainUrl = trim(Site::getMainUrlFor($this->getIdSite()));
$view->additionalUrls = $sitesModel->getAliasSiteUrlsFromId($this->getIdSite());
$view->action = $action;
@@ -107,6 +108,7 @@ class VisitorDetails extends VisitorDetailsAbstract
public function renderActionTooltip($action, $visitInfo)
{
$view = new View('@Live/_actionTooltip');
+ $view->sendHeadersWhenRendering = false;
$view->action = $action;
$view->visitInfo = $visitInfo;
return [[ 0, $view->render() ]];
@@ -115,6 +117,7 @@ class VisitorDetails extends VisitorDetailsAbstract
public function renderVisitorDetails($visitorDetails)
{
$view = new View('@Live/_visitorDetails.twig');
+ $view->sendHeadersWhenRendering = false;
$view->visitInfo = $visitorDetails;
return [[ 0, $view->render() ]];
}
@@ -122,6 +125,7 @@ class VisitorDetails extends VisitorDetailsAbstract
public function renderIcons($visitorDetails)
{
$view = new View('@Live/_visitorLogIcons.twig');
+ $view->sendHeadersWhenRendering = false;
$view->visitor = $visitorDetails;
return $view->render();
}
diff --git a/plugins/MarketingCampaignsReporting b/plugins/MarketingCampaignsReporting
-Subproject 6776c7061030e5fc7615292ca8e6363dba4d056
+Subproject 6c8d9a33be10675d3d46632a0d185f18053ebb9
diff --git a/plugins/Referrers/VisitorDetails.php b/plugins/Referrers/VisitorDetails.php
index e413d5386d..b59c7b5802 100644
--- a/plugins/Referrers/VisitorDetails.php
+++ b/plugins/Referrers/VisitorDetails.php
@@ -32,6 +32,7 @@ class VisitorDetails extends VisitorDetailsAbstract
public function renderVisitorDetails($visitorDetails)
{
$view = new View('@Referrers/_visitorDetails.twig');
+ $view->sendHeadersWhenRendering = false;
$view->visitInfo = $visitorDetails;
return [[ 10, $view->render() ]];
}