Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

2.1 View count won't increament.

24567

Comments

  • @Lincoln see above.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited May 2014

    I meant @linc :)

    @chanh‌
    if you have
    $Configuration['Vanilla']['Views']['Denormalize'] = TRUE;

    in your config.php remove it and see if your views increment.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • chanhchanh OngETC.com - CMS Researcher ✭✭

    I will attempt to follow your instruction.
    Thanks

  • LincLinc Detroit Admin
    edited May 2014

    I think @peregine's solution of removing that value from the config should solve this.

    @Tim and I are talking about this today. The short version is: there's an issue where the cache layer is reporting it's present for incrementing views even if it is installed but not actually caching. That makes the Vanilla.Views.Denormalize setting a potential trap if you previously set it in 2.0 to fix the view counter. Tim is looking into removing the false positive on the caching layer for 2.1.1, but hopefully simply removing that config value is good enough.

  • TimTim Operations Vanilla Staff

    To be clear, the cache layer is designed to do this. We created a cache called DirtyCache which is enabled by default. It stores nothing and returns nothing. This allows us to always code as if there is a valid cache instead of having to always create 2 code paths (one for if there is a cache, one for if there is not). You can see how the latter approach would get really tedious very quickly.

    The problem is, there are cases when having a "Dirty" cache is not enough, cases such as this. The bug here is that the view de-normalization code does not check explicitly for a functioning cache. That's what we'll be adding.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • in config defaults

    $Configuration['Cache']['Enabled'] = TRUE;

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • TimTim Operations Vanilla Staff

    Yes. That's correct.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • i read your notes on github. looks like lord bracko has a solution to it all.

    I learned a bunch from this exercise.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • TimTim Operations Vanilla Staff

    p.s. your LogMessage function is cool. There is a similar debugging helper in core, called "DebugMethod()" which you should look at. It doesn't write to phplog, it echos to the screen, but it does help with seeing when a method is called, and with what arguments.

    debugMethod(__METHOD__, func_get_args()) is the typical usage.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • chanhchanh OngETC.com - CMS Researcher ✭✭

    @peregrine I don't have this in my config.php
    $Configuration['Vanilla']['Views']['Denormalize'] = TRUE;

    I add this code in my config.php and the view work and jump from 1 to 4, may be it is from the cache?

    $Configuration['Garden']['Cache']['Enabled'] = TRUE;

    With this change, the view is incrementing like it should. I think, I will monitor it for awhile to see if it still jump instead of increment by 1.

    Thank you all.

  • chanhchanh OngETC.com - CMS Researcher ✭✭

    I just check the view count today and it does not seem to work.

    I thought the cache setting in config would fix it but it didn't. It is now increment by 2 if I enable IncrementView plugin it won't implement if IncrementView plugin is not enable.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I think Increment view plugin only works when the statistics plugin is not enabled.

  • chanhchanh OngETC.com - CMS Researcher ✭✭

    I disable the Vanilla stat but it still increment by 2.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    hmmm how about disabling those and refreshing the page some 20 times and see if that works. Maybe there just are not enough views to count. But I am just guessing. I have not had that problem.

    The Increment View plugin from what I understand is a way to increment fictitiously the views. It does not affect the real stats. But I could be wrong. @peregrine can shed more light I am sure...

  • @chanh

    I'll pm you the details. I think you have mixed and matched my previous instructions.

    I'll give you the changes Tim and Lincoln fixed it with, as well as tell you want you need to remove.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited May 2014

    @chanh

    on second thought here is what to do. please do the steps in order and pay attention and foucs to ensure you follow all the steps. please don't skip steps.

    pay attention and focus on this - follow all steps.


    Step1

    disable the incrementview plugin


    Step2

    remove the statement from config.php

    $Configuration['Cache']['Enabled'] = TRUE;

    (it is already in your config.defaults.php- leave it in this file)


    Step3

    change this statement from your config.php to FALSE or remove it entirely

    from
    
    $Configuration['Garden']['Errors']['LogEnabled'] = TRUE;
    
    to
    
    $Configuration['Garden']['Errors']['LogEnabled'] = FALSE;
    

    Step4

    remove this statement in config.php if you have it

    $Configuration['Vanilla']['Views']['Denormalize'] = TRUE;


    Step5

    make these code changes in the two php files (it implements the fix that Tim and Lincoln worked on)

    in applications/vanilla/models/class.discussionmodel.php around line 1947 or so

    replace the old AddView function (method) with this:

     public function AddView($DiscussionID) {
          $IncrementBy = 0;
          if (
             C('Vanilla.Views.Denormalize', FALSE) &&
             Gdn::Cache()->ActiveEnabled() &&
             Gdn::Cache()->Type() != Gdn_Cache::CACHE_TYPE_NULL)
          {
             $WritebackLimit = C('Vanilla.Views.DenormalizeWriteback', 10);
             $CacheKey = sprintf(DiscussionModel::CACHE_DISCUSSIONVIEWS, $DiscussionID);
    
             // Increment. If not success, create key.
             $Views = Gdn::Cache()->Increment($CacheKey);
             if ($Views === Gdn_Cache::CACHEOP_FAILURE)
                Gdn::Cache()->Store($CacheKey, 1);
    
             // Every X views, writeback to Discussions
             if (($Views % $WritebackLimit) == 0) {
                $IncrementBy = floor($Views / $WritebackLimit) * $WritebackLimit;
                Gdn::Cache()->Decrement($CacheKey, $IncrementBy);
             }
          } else {
             $IncrementBy = 1;
          }
    
          if ($IncrementBy) {
             $this->SQL
                ->Update('Discussion')
                ->Set('CountViews', "CountViews + {$IncrementBy}", FALSE)
                ->Where('DiscussionID', $DiscussionID)
                ->Put();
          }
    
    }
    

    around line 686 replace core class.statistics.php

    replace this

    if (C('Garden.Analytics.Views.Denormalize', FALSE) && Gdn::Cache()->ActiveEnabled()) {

    with this

             if (
                C('Garden.Analytics.Views.Denormalize', FALSE) &&
                Gdn::Cache()->ActiveEnabled() &&
                Gdn::Cache()->Type() != Gdn_Cache::CACHE_TYPE_NULL)
             {
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Trying to follow what actually worked here. Should I try what @vrijvlinder suggested (statsbox)?

    I don't have this in my config.php file:
    $Configuration['Garden']['Cache']['Enabled'] = TRUE;

    If I'm reading this correctly it seems like @chanh added this and the view started incrementing. So is that the way to go?

    Also, thanks for the tip on removing it altogether @peregrine‌

  • The stats box won't help I don't think if your view count is being updated in the database.

    try the stats box and if that doesn't work.

    try this. http://vanillaforums.org/discussion/comment/207395/#Comment_207395

    if neither works come back. if either works come back and report.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine‌ - working on this now. Only 5 steps? Hardly a challenge.

  • as long as you don't lose the thriill of the chase you'll be cool!

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.