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.

12346

Comments

  • I made a mistake and the above is now edited.

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

  • MasterOneMasterOne ✭✭
    edited May 2014

    @peregrine said:
    so there is discussion id there.
    no lets see if the json_decode works.
    can you change in that routine to this now:
    I made a mistake and the above is now edited.

    Done & done. ;)

  • peregrineperegrine MVP
    edited May 2014

    then the next step if discussion id does not print out

    e.g.

    20 May 2014 - 07:33:16: [Garden] /var/www/vanilla/applications/vanilla/settings/class.hooks.php, 519, Object.Method(), DISCUSSION id is 35

    can you look at these lines is the LogMessage at the bottom. (in the code you added)

         // Discussion link
        elseif ($ResolvedPath == 'vanilla/discussion/index') {
        $DiscussionID = GetValue('DiscussionID', $ResolvedArgs, NULL);
        LogMessage(__FILE__,__LINE__,'Object','Method',"DISCUSSION id is $DiscussionID");
    }
    

    or it is like this

       // Discussion link
        elseif ($ResolvedPath == 'vanilla/discussion/index') {
            LogMessage(__FILE__,__LINE__,'Object','Method',"DISCUSSION id is $DiscussionID");
        $DiscussionID = GetValue('DiscussionID', $ResolvedArgs, NULL);
    }
    

    the top one is how we want it.

    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

    Perhaps the json_decode is an issue.

    or perhaps the

    yours with \ before the "

    20 May 2014 - 07:41:24: [Garden] /usr/www/users/stilld/testo.stilldragon.org/applications/vanilla/settings/class.hooks.php, 495, Object.Method(), Resolved Args non jsondecode is {\"DiscussionID\":\"547\",\"DiscussionStub\":\"50l-bain-marie\",\"Page\":\"\"}
    
    and mine
    
    20 May 2014 - 07:33:16: [Garden] /var/www/vanilla/applications/vanilla/settings/class.hooks.php, 499, Object.Method(), Resolved Args non jsondecode is {"DiscussionID":"35","DiscussionStub":"tewt","Page":""}
    

    perhaps we could preg_replace all the \ with nothing.

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

  • MasterOneMasterOne ✭✭
    edited May 2014

    Log message is at the bottom:

    // Discussion link
    elseif ($ResolvedPath == 'vanilla/discussion/index') {
    $DiscussionID = GetValue('DiscussionID', $ResolvedArgs, NULL);
    LogMessage(__FILE__,__LINE__,'Object','Method',"DISCUSSION id is $DiscussionID");
    }
    

    No idea how it's possible that we get different results on what's shown in the log.

  • peregrineperegrine MVP
    edited May 2014

    do you have magic quotes turned on. if so can you turn them off

    http://php.net/manual/en/security.magicquotes.disabling.php

    It would be interesting to see if things work with magic quotes off.

    in php.ini

    magic_quotes_gpc = Off

    or via .htaccess

    php_flag magic_quotes_gpc Off

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

    MasterOneR_J
  • DANG! You solved the mystery!

    magic_quotes_gpc was enabled, I just switched it off and ViewCount is incrementing again!

    I just checked, it was off on the old server as well, but on by default on the new server.

    Just checked on more info about magic_quotes_gpc, it's also considered to be best practice to have in enabled due to security reasons. I guess I have to leave it switched off then if Vanilla needs it.

    peregrine
  • peregrineperegrine MVP
    edited May 2014

    thanks for your patience. and for the help in helping me test it.

    you can put the originals back obviously.

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

  • Well done, @peregrine‌, you are a true master of diagnoses.

    I just disabled your IncrementView plugin on our production forum, switched Vanilla Statistics back on, and ViewCount is working as expected again. :)

    peregrine
  • peregrineperegrine MVP
    edited May 2014

    @MasterOne

    well, you are easy to work with, you don't give up, you respond quicky, and do things accurately.

    all necessary make it possible to help the helper solve thing effectively.

    at least it is solved for one person :)

    110 comments later :) all entities included.

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

    R_Jhgtonight
  • mnerurkarmnerurkar New
    edited May 2014

    So... I'm having the same issue but this seems like a really involved fix... Damn :(

    Weirdly enough the views still increase in the stats though...

  • peregrineperegrine MVP
    edited May 2014

    @mnerurkar said:
    So... I'm having the same issue but this seems like a really involved fix... Damn :(

    Weirdly enough the views still increase in the stats though...

    simple question - do you have

    do you have magic quotes turned on. if so can you turn them off

    http://php.net/manual/en/security.magicquotes.disabling.php

    in php.ini

    magic_quotes_gpc = Off

    or via .htaccess

    php_flag magic_quotes_gpc Off


    If that doesn't solve you problem, if not it may be another issue. - perhaps caching.

    you might also change

    in applications/vanilla/models/class.discussionmodel.php in the AddView function.

        public function AddView($DiscussionID) {
          $IncrementBy = 0;
          if (C('Vanilla.Views.Denormalize', FALSE) && Gdn::Cache()->ActiveEnabled()) {
    

    to

    public function AddView($DiscussionID) {
    $IncrementBy = 0;
    if (
    C('Vanilla.Views.Denormalize', FALSE) &&
    Gdn::Cache()->ActiveEnabled() &&
    Gdn::Cache()->Type() != Gdn_Cache::CACHE_TYPE_NULL)
    {
    

    and

    in /librarycore/class.statistics.php in the AddView function.

    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)
        {
    

    also in your config.php

    remove the line totally.

    $Configuration['Vanilla']['Views']['Denormalize']

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

  • @mnerurkar

    it would be interesting to find out if the above solves your problem for reference sake.

    but you can always use the incrementview plugin.

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

  • Disabled magic quotes via htaccess. That did the trick. Thanks a lot :D

    peregrinehgtonight
  • @mnerurkar said:
    Disabled magic quotes via htaccess. That did the trick. Thanks a lot :D

    When I disable magic quotes via htaccess, I get an Internal Server Error (500).

    I'm running Vanilla 2.1.3 on a 1and1 shared host.

  • some hosts won't alllow certain changes in .htaccess. call your host and ask them for help or perhaps you can change php.ini.

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

    hgtonight
  • Sorry to necro this, but it seems like the most appropriate place since the more recent posts say to search for this one. The plugin URL above is broken and I'm having the same problem described after just upgrading my site via a tool call softalicious. I have attempted to insert some debugging into the code to find out why addview isn't being called and I am not having any luck.

  • shumooshumoo New
    edited April 2015

    added

    IfModule mod_php5.c
    # fix for view count not incrementing
    php_flag magic_quotes_gpc off
    /IfModule

    to .htaccess - no luck

    edit: had to remove <>s so the tags could be displayed.

  • R_JR_J Ex-Fanboy Munich Admin

    Create a file on your server with the following content:

    <?php
    echo phpinfo();
    

    Open that file and check if magic quotes are really off

    hgtonight
  •                                   logical | master
    

    magic_quotes_gpc Off Off
    magic_quotes_runtime Off Off
    magic_quotes_sybase Off Off
    mail.add_x_header Off Off

Sign In or Register to comment.