Skip to content

[5.2] Only register hits on items when GET or POST request#43231

Merged
pe7er merged 4 commits intojoomla:5.2-devfrom
Hackwar:5.2-hits
Aug 26, 2024
Merged

[5.2] Only register hits on items when GET or POST request#43231
pe7er merged 4 commits intojoomla:5.2-devfrom
Hackwar:5.2-hits

Conversation

@Hackwar
Copy link
Member

@Hackwar Hackwar commented Apr 8, 2024

Pull Request for Issue #40476 .

Summary of Changes

Right now, Joomla registers every call to the URL of a content item as a hit. However, there are cases where for example FeedBurner does HEAD requests to the URL, which isn't really a real request to get the content item. This PR filters the requests to only be registered as a hit when triggered by GET or POST.

Testing Instructions

Install the testing sample data and visit an article of your choice, for example "Content Component". See the hit counter. Request the same URL with a tool like Postman as a HEAD request.

Actual result BEFORE applying this Pull Request

The HEAD request is counted as a hit.

Expected result AFTER applying this Pull Request

The HEAD request is not counted as a hit.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@Ruud68
Copy link
Contributor

Ruud68 commented Apr 9, 2024

Hi @Hackwar , can you eleborate what is the reason for doing these changes in the controller / view and not in the model or table hit function?

@Hackwar
Copy link
Member Author

Hackwar commented Apr 9, 2024

The model and table do the actual work of registering the hit. The decision if the hit should be counted has to be done by the controller/view. Normally, the code should be unified to check this either in the controller or in the view and not one time in the controller and the other time in the view. I can't say which solution is the right one right now. In the end, you might want to use the model or table in another context (a JSON API or CLI code) and register that as a hit, which would then create problems when you have the additional checks in there.

@crommie
Copy link

crommie commented Aug 24, 2024

I have tested this item ✅ successfully on 98a9ed5

Works as described.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43231.

@TLWebdesign
Copy link
Contributor

I have tested this item ✅ successfully on 98a9ed5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43231.

@Quy
Copy link
Contributor

Quy commented Aug 24, 2024

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43231.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 24, 2024
@pe7er pe7er added bug and removed Feature labels Aug 26, 2024
@pe7er pe7er enabled auto-merge (squash) August 26, 2024 10:02
@pe7er pe7er self-assigned this Aug 26, 2024
@pe7er pe7er merged commit c75b69b into joomla:5.2-dev Aug 26, 2024
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 26, 2024
@richard67 richard67 added this to the Joomla! 5.2.0 milestone Aug 26, 2024
@pe7er
Copy link
Contributor

pe7er commented Aug 26, 2024

Thanks @Hackwar !

@Hackwar Hackwar deleted the 5.2-hits branch June 10, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants