Skip to content

Commit c75b69b

Browse files
authored
[5.2] Only register hits on items when GET or POST request (joomla#43231)
* Only register hits on items when GET or POST request * codestyle
1 parent 9833057 commit c75b69b

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

components/com_contact/src/View/Contact/HtmlView.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,10 @@ public function display($tpl = null)
371371
$this->contacts = &$contacts;
372372
$this->contactUser = $contactUser;
373373

374-
$model = $this->getModel();
375-
$model->hit();
374+
if (\in_array($app->getInput()->getMethod(), ['GET', 'POST'])) {
375+
$model = $this->getModel();
376+
$model->hit();
377+
}
376378

377379
$captchaSet = $item->params->get('captcha', $app->get('captcha', '0'));
378380

components/com_content/src/Controller/DisplayController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function display($cachable = false, $urlparams = false)
110110
throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 403);
111111
}
112112

113-
if ($vName === 'article') {
113+
if ($vName === 'article' && \in_array($this->input->getMethod(), ['GET', 'POST'])) {
114114
// Get/Create the model
115115
if ($model = $this->getModel($vName)) {
116116
if (ComponentHelper::getParams('com_content')->get('record_hits', 1) == 1) {

components/com_newsfeeds/src/View/Newsfeed/HtmlView.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ public function display($tpl = null)
212212
$item->tags->getItemTags('com_newsfeeds.newsfeed', $item->id);
213213

214214
// Increment the hit counter of the newsfeed.
215-
$model = $this->getModel();
216-
$model->hit();
215+
if (\in_array($app->getInput()->getMethod(), ['GET', 'POST'])) {
216+
$model = $this->getModel();
217+
$model->hit();
218+
}
217219

218220
$this->_prepareDocument();
219221

components/com_tags/src/Controller/DisplayController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function display($cachable = false, $urlparams = false)
5959

6060
if (
6161
$vName === 'tag'
62+
&& \in_array($this->input->getMethod(), ['GET', 'POST'])
6263
&& ComponentHelper::getParams('com_tags')->get('record_hits', 1) == 1
6364
&& $model = $this->getModel($vName)
6465
) {

0 commit comments

Comments
 (0)