1

I am using the Rules Link module in a Drupal 7 site. The site contains a view that lists a number of entities, including the Rules link field. The Rules Link rule set is simple: when clicked, data of a field value is set. The rules link works fine, however ...

When I check the recent log messages (dblog) I see that every page load of that views page, Rules link repeats a check on every rules link available on the page. Such as this Rules link where

" Executing and Rules link: Bin condition.
0 ms Executing and Rules link: Bin condition.
0.098 ms AND evaluated to TRUE.
0.11 ms Finished executing of and Rules link: Bin condition.

I did not include a trigger for when a page is viewed, so I think this is strange. And even stranger, why is a rules condition check for every link listed in a view? I get long lists in my dblog showing repeating Rules Link condition checks.

0

1 Answer 1

1

What you have noticed (= repeat a check on every Rules Link available on the page), is simply how the Rules Link module works, especially if used in combination with the Views module, as in your question here.

As an example, refer to (my) question about "How to show authorized users a link for relevant Views results using the Rules Link module?". The accepted (my own) answer to that question includes an example of a Views result that looks like so:

User name      Active  Created date        Last login
Hillary.Trump  No      06/18/2016 - 13:45                      Unblock user
Donald.Clinton No      06/18/2016 - 13:42                      Unblock user
Someone.Else   Yes     05/12/2016 - 12:09  09/17/2017 - 11:18
Pierre.Vriens  Yes     03/11/2016 - 21:05  10/06/2017 - 16:04
Dries.Buytaert Yes     11/23/2015 - 10:11  09/17/2017 - 10:38
Anonymous      No

Actually the last column (with "Unlock user" for only the first 2 rows) is what got created via the Rules Link module. And to achieve this result, I used the "Configure Rules" tab to specify the relevant "Access Conditions". Don't be confused ... 'Access' here is not about permissions! Instead they are like an extra refinement of the permissions: they can be used to specify when to show the Rules Links, whereas this "when" is expressed using Rules Conditions (only).

I specified these Rules Conditions (which must both be satisfied), using the Add condition link (right above "Reactions"):

  1. Data comparison, with:

    • Data to compare: [user:uid]
    • Operator: is greater than
    • Data value: 0
  2. Data comparison, with:

    • Data to compare: [user:status]
    • Data value: Blocked

The 1st condition will ensure the link is NOT shown for Anonymous. And the 2nd condition will ensure the link is only shown for users for which the value of the Active column is No.

These Access Conditions of the Rules Link are actually saved as a regular Rules Component (using a Component Plugin type of "Condition set (AND)" and with machine name rules_link_condition_unblock_a_blocked_user).

So with the above in mind, and after I enabled "Show debug information" (within Rules Settings), I got a Rules Evaluation log which looks like this:

" Executing and Rules link: Unblock a blocked user condition.
0 ms Executing and Rules link: Unblock a blocked user condition.
0.532 ms The condition data_is evaluated to TRUE [edit]
1.831 ms The condition data_is evaluated to TRUE [edit]
1.839 ms AND evaluated to TRUE.
1.86 ms Finished executing of and Rules link: Unblock a blocked user condition.

" Executing and Rules link: Unblock a blocked user condition.
0 ms Executing and Rules link: Unblock a blocked user condition.
0.251 ms The condition data_is evaluated to TRUE [edit]
0.368 ms The condition data_is evaluated to TRUE [edit]
0.376 ms AND evaluated to TRUE.
0.394 ms Finished executing of and Rules link: Unblock a blocked user condition.

" Executing and Rules link: Unblock a blocked user condition.
0 ms Executing and Rules link: Unblock a blocked user condition.
0.277 ms The condition data_is evaluated to TRUE [edit]
0.394 ms The condition data_is evaluated to FALSE [edit]
0.402 ms AND evaluated to FALSE.
0.419 ms Finished executing of and Rules link: Unblock a blocked user condition.

" Executing and Rules link: Unblock a blocked user condition.
...

" Executing and Rules link: Unblock a blocked user condition.
...

" Executing and Rules link: Unblock a blocked user condition.
0 ms Executing and Rules link: Unblock a blocked user condition.
0.233 ms The condition data_is evaluated to FALSE [edit]
0.241 ms AND evaluated to FALSE.
0.258 ms Finished executing of and Rules link: Unblock a blocked user condition.

Some more details about the above logging data:

  • I got exactly 6 groups of logging records (1 for each Views result) of Rules logging data (each of them starting with the line "Executing and Rules link: Unblock a blocked user condition.").
  • Only for the first 2 groups it says "AND evaluated to TRUE." (i.e. the 2 rows for which the Rules Link-link is to be shown), while for the remaining blocks, they all say "AND evaluated to FALSE." (i.e. the rows for which the Rules Link is to be hidden).

But, for the Rules Link module to be able to correctly (yes or no) show such link for each Views result, it has to evaluate both Rules Conditions (those 2 data comparisons in my case, you were lucky ... you seem to only have 1 Rules Condition for each Views result ...). Or, to use your own words (as in your question): "repeat a check on every Rules Link available on the page".

Open (followup?) question: what happens if there are multiple pages of views results, i.e. when are those Rules Conditions evaluated for subsequent pages (when the page is to be actually shown, or at the very beginning when the very first page is shown)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.