I just rename the original AddView to xAddView and add your code so that I can easily reverse back. That is the only deviating from your instructions that I am aware.
Just an FYI, the DebugLog did have something written to but only from the Smarty error the I encounter not from the debug code so that rule out the permission or the location of the DebugLog file.
I might eventually get to the bottom of this but for now I will use your plugin.
chanh - ignore this thread if you don't want to follow the steps. but if you do want to follow the steps properly, with focus.
figured I'd post this in case someone else was having problems and could follow steps.
I'm going to give it another try - to see if you chanh, want to follow instructions.
this would be a logical process. assuming you want to do a logical step by step.
assuming you added this to your config.php, you can skip this.
create a folder called log (give it permissions 777)
e.g.
vanilla/log
if your forum is in forum the folder would be in forum
e.g. forum/log
since results are written to log
all of your debug messages will go to a file called DebugLog
1
use the default theme
2
disable vanilla statistics plugin
3
disable the increment view plugin.
4
vanilla/applications/vanilla/settings/classhooks.php
if you change classhooks.php
from
if ($DiscussionID)
$DiscussionModel->AddView($DiscussionID);
}
to
if ($DiscussionID) {
$DiscussionModel->AddView($DiscussionID);
LogMessage(__FILE__,__LINE__,'Object','Method',"pre - discussion id is $DiscussionID");
}
}
make sure you include all the brackets. as shown.
5
in library/core/class.statistics.php around line 686
change from:
if (C('Garden.Analytics.Views.Denormalize', FALSE) && Gdn::Cache()->ActiveEnabled()) {
in /applications/vanilla/models/discussionmodel.php around line 1837
temporarily replace the entire AddView function with code below
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);
LogMessage(__FILE__,__LINE__,'Object','Method',"my views are $Views");
if ($Views === Gdn_Cache::CACHEOP_FAILURE) {
Gdn::Cache()->Store($CacheKey, 1);
}
// Every X views, writeback to Discussions
$tmp = $Views % $WritebackLimit;
LogMessage(__FILE__,__LINE__,'Object','Method',"my views writeback tmp is $Views $WritebackLimit $tmp");
if (($Views % $WritebackLimit) == 0) {
$IncrementBy = floor($Views / $WritebackLimit) * $WritebackLimit;
Gdn::Cache()->Decrement($CacheKey, $IncrementBy);
}
} else {
$IncrementBy = 1;
}
LogMessage(__FILE__,__LINE__,'Object','Method',"myincrement is: $IncrementBy");
if ($IncrementBy) {
$this->SQL
->Update('Discussion')
->Set('CountViews', "CountViews + {$IncrementBy}", FALSE)
->Where('DiscussionID', $DiscussionID)
->Put();
}
}
7
click on the discussion page.
8
then click on a specific discussion.
9
click to go to the main discussion page.
10
then click on a specific discussion.
11
click to go to the main discussion page.
12
then click on a specific discussion.
13
click to go to the main discussion page.
14
then click on a specific discussion.
15
you should see lines created in your debug log.
if so post your results that show up in the DebugLog
depending on the results of your log - it could be a problem with cache or cache incrementing or your custom theme or vanillastats. we won't know until you display the debug results.
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, I just found out that I am facing the same problem. I see that you were getting annoyed by the OP not pursuing the issue, so I'm gonna give it a try now.
I have just upgraded from v2.1b1 to v2.1_final and moved the forum to another server. Before ViewCount worked as expected, now it does not increment any more. I always had APC and the Vanilla Stats module enabled, no "Denormalize" option, no increment view plugin.
I'll try now the steps you outlined in your last comment before mine.
@peregrine, I have followed all of your instructions step by step, but nothing gets written to the DebugLog file. I assume this is because no error occurs?
It's not a permission problem concerning log/DebugLog, I have just tested it by changing the db username to cause an "Oops" and that error gets written to DebugLog.
Is there something else that has to be done to make LogMessage work, or are the LogMessage lines not correct?
@peregrine, I have followed all of your instructions step by step, but nothing gets written to the DebugLog file. I assume this is because no error occurs?
actually. the statements...
e.g.
LogMessage(FILE,LINE,'Object','Method',"myincrement is: $IncrementBy");
should log something whether there is an error or not when the code is hit.
and the code should be hit.
what do you have in your config.php
as far as denormalize or cache related.
and is statistics enabled.
also did you make copies of the files you changed and leave them in the folder.
or did you just change the files without making copies or duplicates (because copies can sometimes be pulled in instead of original depending on how you name them.).
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
also did you make copies of the files you changed and leave them in the folder.
or did you just change the files without making copies or duplicates (because copies can sometimes be pulled in instead of original depending on how you name them.).
I made the changes to all files as suggested without making any copies.
Disabling cache also did not help. Disabled cache, tested as suggested with going from Discussions to a certain discussion and back four times, nothing gets written to DebugLog.
Could you post your config.php with your password and salt and email and other private infor removed.
either the discussionmodel is being overridden or for some reason addview is not being hit, or logmessage is failing.
to test whether log message works if you want.
in the the plugins folder add a folder called Tester
like so /plugins/Tester
copy this into /plugins/Tester/default.php
<?php if (!defined('APPLICATION')) exit();
// Define the plugin:
$PluginInfo['Tester'] = array(
'Name' => 'Tester',
'Description' => 'Tester',
'Version' => '1',
'Author' => "Peregrine",
);
class Tester extends Gdn_Plugin {
public function DiscussionsController_BeforeDiscussionName_Handler($Sender) {
LogMessage(__FILE__,__LINE__,'Object','Method',"log message does work from the tester plugin");
}
}
then enable the plugin Tester in your dashboard.
then click on discussions page ( the one with lists of discussions) a few times
then look at the DebugLog
A
it should have a bunch of new lines that say "log message does work from the tester plugin"
or B
if you don't see a bunch of new lines that say "log message does work from the tester plugin"
if not then log message doesn't work. in that case you could try the logger plugin.
if you get log messages with the Tester plugin, then
either the discussionmodel is being overridden or for some reason addview is not being hit
perhaps a plugin is enabled that overrides it.
disable the Tester plugin when you are finished testing.
if you used Memcached and ubunutu 12.04
also from php.net
"If it'll save others some head-scratching, the PECL Memcached extension only supports initializing increment (or decrement) values from 2.0.0b2 onwards - i.e. not the version (1.0.2) that comes out of the box with Ubuntu 12.04."
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
So, my apologies to chan, because if the two of you say you are having problems and you say you followed the instructions. maybe similarities (plugins, os, etc )between the both of you will answer the questions
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, your Tester plugin works and I can see a bunch of messages with "log message does work from the tester plugin" in DebugLog.
I have disabled the Tester plugin, cleared DebugLog, disabled all plugins, cleared /cache (just to be sure), tried your test with 4 x going from a certain discussion to Discussions and back, and nothing shows up in DebugLog.
Attached you find my config.php with all "sensible" data replaced by "XXXXX".
BTW At one point during my testing I got the following DebugLog entries:
19 May 2014 - 09:30:15 TESTINSTALLATION Garden Exception: file_get_contents() [<a
href='function.file-get-contents'>function.file-get-contents</a>]: http:// wrapper is
disabled in the server configuration by allow_url_fopen=0 in /usr/www/users/TESTACCOUNT
/TESTINSTALLATION/applications/dashboard/controllers/class.utilitycontroller.php on 47819 May
2014 - 09:30:15 TESTINSTALLATION Garden #0 [internal function]: Gdn_ErrorHandler(2,
'file_get_conten...', '/usr/www/users/...', 478, Array)19 May 2014 - 09:30:15
TESTINSTALLATION Garden #1 /usr/www/users/TESTACCOUNT/TESTINSTALLATION/applications
/dashboard/controllers/class.utilitycontroller.php(478): file_get_contents('http:/
/vanillaf...')19 May 2014 - 09:30:15 TESTINSTALLATION Garden #2 [internal function]:
UtilityController->GetFeed('news', '4', 'extended')19 May 2014 - 09:30:15 TESTINSTALLATION
Garden #3 /usr/www/users/TESTACCOUNT/TESTINSTALLATION/library/core/class.dispatcher.ph
p(350): call_user_func_array(Array, Array)19 May 2014 - 09:30:15 TESTINSTALLATION Garden
#4 /usr/www/users/TESTACCOUNT/TESTINSTALLATION/index.php(46): Gdn_Dispatcher->Dispatch()19
May 2014 - 09:30:15 TESTINSTALLATION Garden #5 {main}19 May 2014 - 09:30:16
TESTINSTALLATION Garden Exception: file_get_contents() [<a href='function.file-get
-contents'>function.file-get-contents</a>]: http:// wrapper is disabled in the server
configuration by allow_url_fopen=0 in /usr/www/users/TESTACCOUNT/TESTINSTALLATION
/applications/dashboard/controllers/class.utilitycontroller.php on 47819 May 2014 - 09:30:16
TESTINSTALLATION Garden #0 [internal function]: Gdn_ErrorHandler(2, 'file_get_conten...',
'/usr/www/users/...', 478, Array)19 May 2014 - 09:30:16 TESTINSTALLATION Garden #1 /usr
/www/users/TESTACCOUNT/TESTINSTALLATION/applications/dashboard/controllers
/class.utilitycontroller.php(478): file_get_contents('http://vanillaf...')19 May 2014 -
09:30:16 TESTINSTALLATION Garden #2 [internal function]: UtilityController->GetFee
d('announce', '2', 'extended')19 May 2014 - 09:30:16 TESTINSTALLATION Garden #3 /usr/www
/users/TESTACCOUNT/TESTINSTALLATION/library/core/class.dispatcher.php(350):
call_user_func_array(Array, Array)19 May 2014 - 09:30:16 TESTINSTALLATION Garden #4 /usr
/www/users/TESTACCOUNT/TESTINSTALLATION/index.php(46): Gdn_Dispatcher->Dispatch()19 May 2014
- 09:30:16 TESTINSTALLATION Garden #5 {main}19 May 2014 - 09:31:05: [Garden] /usr/www
/users/TESTACCOUNT/TESTINSTALLATION/plugins/Tester/default.php, 14, Object.Method(), log
message does work from the tester plugin
What is this with allow_url_fopen? Does Vanilla need it? I just checked, it's disabled in my hoster's PHP configuration, as is allow_url_include, which is the recommended setting.
No Memcached or Ubunutu 12.04 in use at my hoster.
Comments
-rw-rw-rw- 0 May 7 22:37 DebugLog
http://uhostetc.com/class.discussionmodel.php.txt
I didn't aware about change need to be done in class.statistics.php so I didn't make any changes there. What do I have to change in this file?
Thanks
eidtied out. op decided not to pursue.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I did make the change.
http://uhostetc.com/class.statistics.php.txt
I just rename the original AddView to xAddView and add your code so that I can easily reverse back. That is the only deviating from your instructions that I am aware.
What screenshot do you need?
edited out. op decide not to pursue.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Thank you for your time.
ok. if you don't want to pursue your specific problem or follow instructions to debug. you can always use
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.
Just an FYI, the DebugLog did have something written to but only from the Smarty error the I encounter not from the debug code so that rule out the permission or the location of the DebugLog file.
I might eventually get to the bottom of this but for now I will use your plugin.
Thank you everyone
chanh - ignore this thread if you don't want to follow the steps. but if you do want to follow the steps properly, with focus.
figured I'd post this in case someone else was having problems and could follow steps.
I'm going to give it another try - to see if you chanh, want to follow instructions.
this would be a logical process. assuming you want to do a logical step by step.
assuming you added this to your config.php, you can skip this.
if your forum is in the "vanilla" directory.
create a folder called log (give it permissions 777)
e.g.
vanilla/log
if your forum is in forum the folder would be in forum
e.g. forum/log
since results are written to log
all of your debug messages will go to a file called DebugLog
1
use the default theme
2
disable vanilla statistics plugin
3
disable the increment view plugin.
4
vanilla/applications/vanilla/settings/classhooks.php
if you change classhooks.php
from
to
make sure you include all the brackets. as shown.
5
in library/core/class.statistics.php around line 686
change from:
to:
6
in /applications/vanilla/models/discussionmodel.php around line 1837
temporarily replace the entire AddView function with code below
7
click on the discussion page.
8
then click on a specific discussion.
9
click to go to the main discussion page.
10
then click on a specific discussion.
11
click to go to the main discussion page.
12
then click on a specific discussion.
13
click to go to the main discussion page.
14
then click on a specific discussion.
15
you should see lines created in your debug log.
if so post your results that show up in the DebugLog
depending on the results of your log - it could be a problem with cache or cache incrementing or your custom theme or vanillastats. we won't know until you display the debug results.
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, I just found out that I am facing the same problem. I see that you were getting annoyed by the OP not pursuing the issue, so I'm gonna give it a try now.
I have just upgraded from v2.1b1 to v2.1_final and moved the forum to another server. Before ViewCount worked as expected, now it does not increment any more. I always had APC and the Vanilla Stats module enabled, no "Denormalize" option, no increment view plugin.
I'll try now the steps you outlined in your last comment before mine.
@peregrine, I have followed all of your instructions step by step, but nothing gets written to the DebugLog file. I assume this is because no error occurs?
It's not a permission problem concerning
log/DebugLog
, I have just tested it by changing the db username to cause an "Oops" and that error gets written to DebugLog.Is there something else that has to be done to make
LogMessage
work, or are theLogMessage
lines not correct?hmmm.
@peregrine, I have followed all of your instructions step by step, but nothing gets written to the DebugLog file. I assume this is because no error occurs?
actually. the statements...
e.g.
LogMessage(FILE,LINE,'Object','Method',"myincrement is: $IncrementBy");
should log something whether there is an error or not when the code is hit.
and the code should be hit.
what do you have in your config.php
as far as denormalize or cache related.
and is statistics enabled.
also did you make copies of the files you changed and leave them in the folder.
or did you just change the files without making copies or duplicates (because copies can sometimes be pulled in instead of original depending on how you name them.).
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Thought so as well, but it's definitely not happening.
There is nothing with "denormalize" in my config-defaults.php or config.php.
The only cache related entry in my config.php is
$Configuration['Garden']['Messages']['Cache'] = array('[Base]');
and just the following is in config-defaults.php
Vanilla Statistics module is disabled.
I made the changes to all files as suggested without making any copies.
just for grins. as a test not permanent.. try...
adding in config.php
$Configuration['Cache']['Enabled'] = FALSE;
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Disabling cache also did not help. Disabled cache, tested as suggested with going from Discussions to a certain discussion and back four times, nothing gets written to DebugLog.
give me a few moments..
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
can you try with this line in config.php
It may need this as well and i overlooked that part.
$Configuration['Debug'] = 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.
also what other plugins do you have enabled?
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Could you post your config.php with your password and salt and email and other private infor removed.
either the discussionmodel is being overridden or for some reason addview is not being hit, or logmessage is failing.
to test whether log message works if you want.
in the the plugins folder add a folder called Tester
like so /plugins/Tester
copy this into /plugins/Tester/default.php
then enable the plugin Tester in your dashboard.
then click on discussions page ( the one with lists of discussions) a few times
then look at the DebugLog
A
it should have a bunch of new lines that say "log message does work from the tester plugin"
or B
if you don't see a bunch of new lines that say "log message does work from the tester plugin"
if not then log message doesn't work. in that case you could try the logger plugin.
if you get log messages with the Tester plugin, then
either the discussionmodel is being overridden or for some reason addview is not being hit
perhaps a plugin is enabled that overrides it.
disable the Tester plugin when you are finished testing.
if you used Memcached and ubunutu 12.04
also from php.net
"If it'll save others some head-scratching, the PECL Memcached extension only supports initializing increment (or decrement) values from 2.0.0b2 onwards - i.e. not the version (1.0.2) that comes out of the box with Ubuntu 12.04."
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
So, my apologies to chan, because if the two of you say you are having problems and you say you followed the instructions. maybe similarities (plugins, os, etc )between the both of you will answer the questions
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, your Tester plugin works and I can see a bunch of messages with "log message does work from the tester plugin" in DebugLog.
I have disabled the Tester plugin, cleared DebugLog, disabled all plugins, cleared /cache (just to be sure), tried your test with 4 x going from a certain discussion to Discussions and back, and nothing shows up in DebugLog.
Attached you find my config.php with all "sensible" data replaced by "XXXXX".
BTW At one point during my testing I got the following DebugLog entries:
What is this with
allow_url_fopen
? Does Vanilla need it? I just checked, it's disabled in my hoster's PHP configuration, as isallow_url_include
, which is the recommended setting.No Memcached or Ubunutu 12.04 in use at my hoster.