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.
Options

View counter works with Apache Prefork MPM, but not Worker MPM

OK, here's a weird one...I work with @monquixote on thefretboard.co.uk - we had a whole bunch of performance issues as noted in his thread, which were resolved by altering the KeepaliveTimeout and switching to the worker MPM (among other things).

Anyway, the view counter has now stopped working. For the sake of testing, I set up a dev environment under the prefork MPM, then put alerts either side of the AJAX call to settings/analyticstick.json at line 882 of js/global.js. Querying GDN_Discussion for the countviews field when viewing a discussion showed that between those two alerts, countviews was incremented.

Switching to the worker MPM, I did exactly the same thing....and countviews remained where it was (no increment), although the JSON returned by the call reports success.

Has anybody come across this behaviour before?

Comments

  • Options

    This doesn't answer your question.

    adds a view slightly differently than the analytics.

    but you could use this http://vanillaforums.org/addon/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.

  • Options
    edited January 2014

    For the record, I've fixed it - for some unknown reason, this line in vanilla/settings/class.hooks.php was failing (part of the Gdn_Statistics_Tick_Handler function):

    $ResolvedArgs = @json_decode(Gdn::Request()->Post('ResolvedArgs'));

    The problem was that Post('ResolvedArgs') was coming through double-escaped, as though magic_quotes was on...but it's off in every instance of php.ini and .htaccess on the server. In the end, the only way I could think of to get it working again was to change it to this:

    if(get_magic_quotes_gpc() == 1) {
    $ResolvedArgs = @json_decode(stripslashes(Gdn::Request()->Post('ResolvedArgs')));
    } else {
    $ResolvedArgs = @json_decode(Gdn::Request()->Post('ResolvedArgs'));
    }

    No, it's not even remotely ideal, but we needed a fast workaround...I guess I could've done it in a one-liner, but I'd rather it was more readable in case I'm not the one who ends up finding an actual fix...

  • Options
    ShadowdareShadowdare r_j MVP
    edited January 2014

    The code you changed the line to will still have the same exact problem presuming that Magic Quotes is off, but it's actually not off in your case. Magic Quotes is actually turned on since get_magic_quotes_gpc() is returning TRUE for you.

    Make sure that the magic_quotes_gpc setting in the php.ini file isn't commented out and says magic_quotes_gpc = Off, because it's on by default even if it's commented out depending on your PHP version. There can be multiple php.ini files on your server, so make sure you are changing the one that the website is using, and be sure to restart the web server for any changes to take affect.

    The Magic Quotes feature causes many problems with PHP programs and has been depreciated as of PHP 5.3.0 and removed since PHP 5.4.0, so updating to a newer version of PHP would fix the problem as well.

    Add Pages to Vanilla with the Basic Pages app

  • Options

    Yup, I've done all of that - magic_quotes_gpc=Off in all instances of php.ini on the server, that's what's confusing the hell out of me. I'm not a PHP guy, really, so I'm not 100% familiar with how it behaves. For example...which php.ini is used when its running in FastCGI under the worker MPM? Pretty sure it's not /etc/php5/apache2/php.ini - is it /etc/php5/cgi/php.ini? In any case, both of them have magic quotes set to off.

    Just as annoying is that I'm getting the incomplete headers error when trying to run phpinfo() to figure out what the settings are.

    To say this is driving me nuts would be something of an understatement ;)

  • Options

    Also, what I do find interesting is that this is the only AJAX call in the whole application which suffers from this problem under the worker MPM; everything else (Whosonline, posting from the editor etc) works absolutely fine.

    Very, very strange.

  • Options

    add this to .htaccess

    php_flag magic_quotes_gpc Off
    php_value magic_quotes_gpc Off
    

    grep is your friend.

Sign In or Register to comment.