Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Negative values are always cut off. If you're using a cut off value of 10 and set the energy to -100, that negative energy will be deleted, although its actual amount is 100. Think of it like energy that just orients in the other direction, but has same power as +100. Like voltage.
As far as I can see, only radioactivity_cron() would have to be changed to handle cut off of negative energy properly. However, I am not sure, if other problems with negative energy can arise, since this doesn't seem to have been a requirement during development of the module.
Comment | File | Size | Author |
---|---|---|---|
#1 | negative-energy-1663738-1.patch | 3.59 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedI'd like to provide the patch below for discussion purposes. My insight in Radioactivity is too limited to assess potential side-effects of the patch. So please consider carefully.
The default cut off will work as before, exept that it will handle negative energy gracefully according to my thoughts of the original posting.
An advantage of the patch is, that setting the cut off to zero will disable it completely. This means also, with the patch it is possible to disable Rules invocation, which always at least required an additional SELECT statement against the database before.
The latter could be called a bug: pure existence of Rules causes an additional SELECT query during cron for each decay profile, even if there's not a single reaction rule using the cut-off event. Now (with the patch) just set the cut off to '0' to avoid that.
Criticism appreciated!
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedUPDATE: I did additional tests and run this patch in a production environment for over a month. Doesn't seem to do a harm. Negative values seem to work now.
Comment #3
killua99 CreditAttribution: killua99 commentedShnapoo I didn't try to apply this patch, but is currently compatible with the 2.x branch?
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedYou'll have to give it a try to find out. If patching succeeds, it will work. Otherwise you'll have to apply it manually in the right place.
About the working principle: the patch adds a few conditions to consider energy below zero as absolute (positive) values. So, if the value is below zero, we multiply it with -1 (make positive) and test the result against $cut_off. That's all it does.