Needs work
Project:
Radioactivity
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Dec 2012 at 21:36 UTC
Updated:
4 Aug 2014 at 22:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pwolanin commentedAnalyzing the JS code - it should NOT be using Drupal behaviors for this - jsut invoke the callback when the DOM is ready.
Comment #2
loze commentedI know this issue is old, but I am seeing something related to this. any javascript that loads ajax data, such as flagging, is calling emit.php.
Comment #3
loze commentedComment #4
tripper54 commentedPatch attached - checks context, only attaches behaviour in the case of a 'document' context. I'm not sure if this is the _correct_ approach, but it works for me.
Comment #5
tripper54 commentedMaybe interestingly for some, I came across this error because my production servers were reporting php 'Input variables exceeded xxx' warnings.
My page has a few blocks that refresh periodically via ajax callbacks. These were also triggering a call to emit.php , each time appending a new event to the POST data.
So if people leave a page open and walk away from their computer for a few hours, the POST data with each emit.php grows and grows until it exceeds php's max_input_vars value.
Considering I was getting 10 - 20 warnings per minute, I'm looking forward to taking a large load off my servers now that I've found this bug!
Comment #6
loze commentedIt looks like it working for me too. Thanks tripper54!
Comment #7
paulihuhtiniemi commentedMaybe we could use jQuery .once() method, I think that's the usual way to prevent javascript being executed multiple times?
Here's a patch adds the following wrapper:
Comment #8
corbacho commentedI prefer also the use of
$('body').once, as it's used for example in Drupal core's JS files for one-time- execution functions.Getting rid of Drupal.behaviors, it's normally good idea for these type of one-time-executions, as @pwolanin suggested, but in this case it *could* be problematic because the code reads from Drupal.settings and those variables probably are still not initialized. (Although I haven't tested myself)
Comment #9
paulihuhtiniemi commentedUpdated the patch, this.config is not available in emitDefault()
Comment #11
tcmug commentedThis needed to be fixed in a different way. The patch would have caused content loaded with ajax not to emit at all. I have fixed this in the latest dev version by using hook_ajax_render_alter() function to add the settings generated by Radioactivity to the ajax call. This will cause the settings.radioactivity.emitters to contain the proper emitters for each ajax call :)
At least ajaxed views pager works well, views infinite pager not so well - that one is a bit bitchy.
Comment #12
Ravenight commentedI am seeing the same thing but I am using Authcache. I just upgraded to 7.x-2.x and every time authcache makes a AJAX call emit is still being called. I am also using Memcache storage but when I run the CRON I am getting +70 added to a node vs. the +10 that it should be and I found 6 Ajax calls on the page + the initial emit.
Comment #13
loze commentedThe latest dev version does not seem to fix this for me as claimed in #11.
i.e. Flagging a node from the node view page does 2 additional emit.php calls (I expected it not to do any)
The patch in #10 does work for the time being.
Comment #14
Ravenight commentedUpdate:
I am running 7.x-2.x-dev and the update mentioned in #11 did not work for me. I reverted the updates done in #11 to radioactivity.js by downloading the the 7.x-2.9 radioactivity.js file and then patched that radioactivity.js with the file from #9 here.
Everything seems to be working in regards to the AJAX calls not running emit.php on every AJAX request.
This works for me as I only want it to be called when the page loads the first time. As I said before, I am caching the page with authcache and putting the emitter into memcache and updating the field on a cron run. All of these things are working well together on my end now.
There may be use-cases that #9 messes with but in my case it works.
Comment #15
loze commentedany update on this?
Comment #16
tcmug commentedThere is some work done for this in the latest commits to the 2.x branch. At least flags on my local tests no longer cause any extra calls. Can any of you folks verify? :)
Comment #17
Ravenight commentedI just downloaded the latest -DEV and it seems to have corrected this issue on my site.
Comment #18
tripper54 commentedI can also confirm the latest dev seems to fix this on my site.