Skip to content

Commit

Permalink
[5.2] Only register hits on items when GET or POST request (#43231)
Browse files Browse the repository at this point in the history
* Only register hits on items when GET or POST request

* codestyle
  • Loading branch information
Hackwar authored Aug 26, 2024
1 parent 9833057 commit c75b69b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions components/com_contact/src/View/Contact/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,10 @@ public function display($tpl = null)
$this->contacts = &$contacts;
$this->contactUser = $contactUser;

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function display($cachable = false, $urlparams = false)
throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 403);
}

if ($vName === 'article') {
if ($vName === 'article' && \in_array($this->input->getMethod(), ['GET', 'POST'])) {
// Get/Create the model
if ($model = $this->getModel($vName)) {
if (ComponentHelper::getParams('com_content')->get('record_hits', 1) == 1) {
Expand Down
6 changes: 4 additions & 2 deletions components/com_newsfeeds/src/View/Newsfeed/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ public function display($tpl = null)
$item->tags->getItemTags('com_newsfeeds.newsfeed', $item->id);

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

$this->_prepareDocument();

Expand Down
1 change: 1 addition & 0 deletions components/com_tags/src/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function display($cachable = false, $urlparams = false)

if (
$vName === 'tag'
&& \in_array($this->input->getMethod(), ['GET', 'POST'])
&& ComponentHelper::getParams('com_tags')->get('record_hits', 1) == 1
&& $model = $this->getModel($vName)
) {
Expand Down

0 comments on commit c75b69b

Please sign in to comment.