Energy is not getting added to nodes when viewing them.

I followed this video http://www.youtube.com/watch?v=vxXeJASe-QM using a fresh drupal 7.23 install with only ctools, radioactivity and radioactivitydefaults enabled.

Steps to reproduce:

download and install drupal 7.23
drush dl ctools, radioactivity
drush en ctools, radioactivity, radioactivitydefaults
add a radioactivity field to article
view incident energy set to 10
set display type to 'Raw numeric value'
accuracy set to 100
create an article
view the article and refresh page a few times and the number stays the same

CommentFileSizeAuthor
#21 2136857-screenshot.png71.84 KBtcmug
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nhero’s picture

I was able to get it working using rules. If rules is indeed required it should be added as a dependency.

pinkonomy’s picture

I have the same issue,no energy is added when viewing a node.

jcam88’s picture

I am having a similar issue Drupal 7.23. No energy added when viewing a node that is displayed using Panels. Disabling the panel and energy is added. Is anyone using Radioactivity with panels?

pinkonomy’s picture

I finally managed to solve this adding a rule.

antpre’s picture

Same problem here.

antpre’s picture

Well actually this problem occurs with drupal 7.23 and 7.24.
Any plan for a release that fix this ?

pinkonomy’s picture

@antpre: There is no need for a fix.You can create a rule that gives points when viewing content.
Cheers

antpre’s picture

Thanks. I ll try it... but my understanding is that the module is suppose to work properly out of the box. So guess there should be a release that fix the problem...
Bye

antpre’s picture

Ok so i managed to and incident with rules. But it adds energy when I view the node itself... but also if I view a page with a teaser of the node appearing in a list of content... Which I dont want.
With the module u would simply put 0 energy for the teaser that appear in a list. How to do that with rules...
Any help would be appreciated.
Thanks
PS : should the priority of this bug be higher as the module is not usable as such ????

antpre’s picture

Priority: Normal » Major

ok I am raising the status (fell free to lower if I am wrong).
Same problem with the 7.x-2.8 and 7.x-2.x dev version.

tcmug’s picture

I haven't been unable to replicate this bug.

Please check that you are running Drupal cron at nice intervals. The field cache does not get cleared without it and Drupal keeps displaying the cached field state - this might explain the described situation.

tcmug’s picture

Status: Active » Closed (cannot reproduce)

Closing issue!

adrien.felipe’s picture

I ran cron and cleared the cache several times, no energy was ever given.
The only thing that made it work was the rule.

(I use panels to display the node and the radioactivity field)

vegantriathlete’s picture

Status: Closed (cannot reproduce) » Needs work

I can confirm that I can reproduce the issue when I am using Panels.

If I test this in an environment without panels, it works exactly as expected, given the setup. If I use the same setup in an environment that uses Panels, I experience the same problem that no energy is added. I agree that we should not have to use Rules to do this basic functionality. I don't know if the bug is in Panels or in this module. I will dig into it more.

jenlampton’s picture

Status: Needs work » Active

I'm also having this issue, using panels and page manager, and no energy is ever added when viewing a node.

Things I tried to no avail:
* explicitly adding the Radioactivity field to the panel display
* adding the rendered node in "full" view mode to the panel display
* disabling the node view variant for this node type
* disabling the page manager handler for all nodes (node/%node)
* clearing all caches
* clearing the "page and else" cache (this clears cached fields)
* running cron

Will dig deeper to see if I can find out why it's not working...

jenlampton’s picture

Title: No energy added to any items when viewing them using drupal 7.23 » No energy added to any nodes when viewing them using Panels

updating issue title.

Results of deeper digging: It looks like the function that is supposed to update the energy level when a node is viewed is _radioactivity_update_energy() and that function is only called two times in this module.

One of those calls is in radioactivity.rules.inc which is why people have been able to get around this problem by setting up a Rule.

The other call is in the RadioactivityIncident class, in includes/RadioactivityIncident.inc. I'm not sure why this incident isn't being triggered when the node is being viewed via page manager / panels, but will dig deeper.

CB’s picture

I believe Rules is server-side only isn't it? Those of us running Varnish are screwed because Rules never sees the request. The beauty of this field is that it fires with JS making it a much better candidate for a 'view' in my opinion.

Rules does have an action for adding the AJAX and maybe thats the best option.

jenlampton’s picture

I think the recommendation from @tcmug isn't correct, because according to the code, it looks like the field cache is cleared after each increase in energy. If the energy is being increased, you will see it right away when viewing the node.

Results of digging...

The RadioactivityIncident class is called in emit.php, which is hit with AJAX every time the field is viewed. (This is why it is necessary to enable the field under Manage Fields even if you configure it not to display a value).

However, every time a node with this field is viewed, I get an error on emit.php:

NetworkError: 400 Bad Request - http://whatevs.com/sites/all/modules/contrib/radioactivity/emit.php

Possibly related
* #2329081: Failed to load resource: the server responded with a status of 400 -- emit.php
* #1454406: Invalid post data - check configuration.

jenlampton’s picture

Well, that error was unrelated. That's now resolved, things are posting correctly to emit.php, and still the values in the radioactivity fields are not increasing when a node is viewed. :/ So, where the heck are these values supposed to increase?

Coming back full circle... we know this works with rules. So, looking in the rules code the function that is called is _radioactivity_update_energy. That function is also called in RadioactivityIncident.inc inside the method updateEnergy.

Where is that called? Well, it looks like each storage class calls it. I'm using LiveIncidentStorage so let's start there...
Let's see if that fires when the page is viewed. NO.
Let's see if it fires on cron. NO.
Well, there's a problem.

tcmug’s picture

Hmm we had a similiar thing just now on a site using entitycache 1.1 could that be the cause?

Then some clarification regarding rules: rules are meant to be used to boost nodes energy, so for example when you write a comment on a node, you might want to boost it up a little bit in addition to boosting it when you've viewed it.

The boosting by viewing bit works via the field formatters, so whenever a radioactivity field is displayed it actually injects a bit of javascript which then gets triggered in in radioactivity JS beaviors and POSTed back to the server directly to emit.php. emit.php is then responsible for storing the data sent to whichever storage you have chosen for the field. Then at cron runs the data is processed and fed into the fields.

Anyhoo, I'm having a go at duplicating this now to see if I can give you ideas on how to solve it :)

tcmug’s picture

FileSize
71.84 KB

Sorry but I was unable to replicate this still :(

Few points to look for:

  1. Make sure you've added the radioactivity field to the panels, otherwise the JS is not injected on the page - if it already is there, try disabling all caches.
  2. Check browsers network activity for the node page, check if emit.php is POSTed to (result should be HTTP 200, if its something else check what the response is).
  3. Verify you do not accidentally have flood protection on.
patrickfweston’s picture

I also ran into this issue while trying to set up Radioactivity with a Panelized content type.

I have the Radioactivity field displayed (it's showing the correct, raw value for the radioactivity). However, viewing the page does not increase the energy of the page (the radioactivity decays properly). I've dug into the javascript that's included on the page, along with emit.php.

My problem seems to be stemming from the fact that _radioactivity_checksum_validate is failing in radioactivity-bootstrap.inc. Returning a value of true (instead of running the conditional check) causes the energy to be correctly incremented.

I have verified that the POST to emit.php is returning an error. I'm getting:
400 (Bad Request edd7746c57c54ff857e65f0171d270f2 - 83372879a8f183cb6a120f52fbf97db5)

I modified the header to return _radioactivity_checksum_generate($data) and the $checksum from the _radioactivity_checksum_validate() function.

If you'd like me to dig around more in a certain area, I'd be happy to take a look. Thanks!

Update: It looks like this isn't the issue, as I've reset my configuration and have gotten rid of the 400 response. The energy for a node is still not be increased when it is viewed. I have tried with multiple storage types to no avail.

varshith’s picture

Hi,

I am using drupal_commons which includes radioactivity within.
I am also using panels. In my case radioactivity was not updating energy at all (both in node-view and rules).
But when I clear my cache I could see a one step increase in energy (even if I view the node 10 times, the energy will only increase for 1 time on cache clear)
On debugging I found that the issue was due to entitycache module (also a part of drupal_commons).
Radioactivity updates the energy in DB and attempts to clear the field cache. But with entitycache, this is not cleared.
I have added a patch for this here
https://www.drupal.org/node/2795497