Problem/Motivation

There are new default implemtenations of execute() and evalute() that forward calls to doExecute() and doEvalute(). That way we can use type-hinting and save getContextValue() methods.

Proposed resolution

See for example the doExecute from the EntityFetchByField class: all actions & conditions should use the new scheme of doExecute/doEvaluate and pass context variables via method parameters.
Please create separate pull requests for each action & condition and link them in a comment here.

Remaining tasks

Update execute() functions:

Already done:

Update evalute() functions:

All done!

Rules Conditions -- if these call evaluate(), it should be changed to doEvaluate(...).

Update the documentation:

Comments

dasjo created an issue. See original summary.

ndeet’s picture

Hi Josef, looks like low hanging fruit and the right task for me (and hopefully others) to get started. Don't have the big picture of rules and D8 in general yet so bear with me :D
Pull request: https://github.com/fago/rules/pull/232

Torenware’s picture

Torenware’s picture

Torenware’s picture

While waiting for the Barcelona to finish its breakfast...

Grabbing class DataListContains (condition_id = rules_list_contains)

PR https://github.com/fago/rules/pull/238 for [#2574513: doEvaluate for rules_list_contains]

Torenware’s picture

Grabbing condition_id = rules_entity_field_access (class UserHasEntityFieldAccess).

botris’s picture

Issue summary: View changes
botris’s picture

I've listed all the execute()functions that are used in Actions.
But the function is also used in 2 core functions and 3 tests, not sure if those functions should be updated as well:
RulesActionBase
ExpressionBase
TestLogAction
TestNodeAction
TestStringAction

botris’s picture

Issue summary: View changes
botris’s picture

Issue summary: View changes
Torenware’s picture

Boris,

I've listed all the execute()functions that are used in Actions.
But the function is also used in 2 core functions and 3 tests, not sure if those functions should be updated as well:
RulesActionBase
ExpressionBase
TestLogAction
TestNodeAction
TestStringAction

Generally speaking, in the tests you want to call evaluate() or execute(), because you want the system to dispatch the action or condition. Also: remember that doExecute() and doEvaluate() are deliberately declared "protected". You can't call them in tests. So you have to use these in test classes.

In RulesActionBase, execute() is the magic glue that calls doExecute() on the action plug-in by finding the context and setting up the call to the plugin's doExecute() method. This is only called if the plugin does not override execute(). So to do your change, we need to remove the plugin's execute call, and replace it with doExecute() with the arguments in the same order as the annotation's context items.

RulesConditionBase does the same job with conditions and doEvaluate. So it must implement evaluate() as a public method.

This sometimes does not work right now due to #2573823: Context in Rules plugins does not respect annotation order. Some tests will fail until this issue is resolved.

I haven't looked at any expressions yet, but I think the principle's the same. So ExpressionBase needs to know how to set up a call to doExecute(), I think.

After looking at this a bit, expressions work a bit differently. Typically, they get passed a RulesState object. So we probably should not include them under this issue. They're consumers of context.

Torenware’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes
Torenware’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes

  • klausi committed 9d6c8eb on 8.x-3.x authored by ndeet
    Issue #2572119: Updating EntityDelete action to use doExecute()
    
ndeet’s picture

Issue summary: View changes

  • klausi committed 88026cf on 8.x-3.x authored by ndeet
    Issue #2572119: Updating UserBlock action to use doExecute()
    
ndeet’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes

  • klausi committed 22fb91f on 8.x-3.x authored by ndeet
    Issue #2572119: Updating SystemSendMail action to use doExecute()
    
ndeet’s picture

Issue summary: View changes

  • klausi committed 7883d40 on 8.x-3.x authored by ndeet
    Issue #2572119: Updating SendAccountMail action to use doExecute()
    
ndeet’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes
Torenware’s picture

Issue summary: View changes
emclaughlin’s picture

Issue summary: View changes

I grabbed VariableAdd, and here's the PR: https://github.com/fago/rules/pull/259

Associated issue: #2583861: doExecute for VariableAdd

emclaughlin’s picture

Issue summary: View changes
emclaughlin’s picture

I grabbed DataListItemRemove and here's the PR: https://github.com/fago/rules/pull/260

Associated Issue: #2585019: doExecute for DataListItemRemove

emclaughlin’s picture

I grabbed UserIsBlocked and here's the PR: https://github.com/fago/rules/pull/262

Associated Issue: #2585321: doEvaluate for UserIsBlocked

emclaughlin’s picture

Issue summary: View changes
emclaughlin’s picture

Issue summary: View changes
emclaughlin’s picture

Issue summary: View changes

I grabbed PathHasAlias and here is the PR: https://github.com/fago/rules/pull/263

Associated Issue: #2585403: doEvaluate for PathHasAlias

emclaughlin’s picture

Issue summary: View changes

Snagged the PathAliasExists condition. PR here: https://github.com/fago/rules/pull/264

Associated Issue: #2585419: doEvaluate for PathAliasExists

emclaughlin’s picture

Issue summary: View changes
emclaughlin’s picture

I grabbed NodeIsSticky and here's the PR: https://github.com/fago/rules/pull/265

Associated Issue: #2585429: doEvaluate for NodeIsSticky

emclaughlin’s picture

I grabbed NodeIsPublished and here's the PR: https://github.com/fago/rules/pull/266

Associated Issue: #2585431: doEvaluate for NodeIsPublished

emclaughlin’s picture

I grabbed NodeIsPromoted and here's the PR: https://github.com/fago/rules/pull/267

Associated Issue: #2585435: doEvaluate for NodeIsPromoted

emclaughlin’s picture

Issue summary: View changes

Snagged the NodeIsOfType condition. PR here: https://github.com/fago/rules/pull/268

Associated Issue: #2585463: doEvaluate for NodeIsOfType

emclaughlin’s picture

Issue summary: View changes

Snagged EntityIsOfType with a PR here: https://github.com/fago/rules/pull/269

emclaughlin’s picture

Snagged EntityIsOfBundle condition. PR here: https://github.com/fago/rules/pull/270

emclaughlin’s picture

Issue summary: View changes

Snagged EntityIsNew condition. PR here: https://github.com/fago/rules/pull/271

emclaughlin’s picture

Issue summary: View changes

Snagged EntityHasField condition. PR here: https://github.com/fago/rules/pull/272

emclaughlin’s picture

Issue summary: View changes

Snagged DataListCountIs condition. PR here: https://github.com/fago/rules/pull/272

  • klausi committed a6f8be7 on 8.x-3.x authored by ndeet
    Issue #2572119: Updating PathAliasCreate to use doExecute().
    

  • klausi committed ad6f816 on 8.x-3.x authored by ndeet
    Issue #2572119: Updating PathAliasDeleteByPath to use doExecute().
    

  • klausi committed 8e23e3c on 8.x-3.x authored by ndeet
    Issue #2572119: Updating UserRoleRemove to use doExecute().
    

  • klausi committed 21783f3 on 8.x-3.x authored by ndeet
    Issue #2572119: Updating UserRoleAdd to use doExecute().
    

  • klausi committed bd3b667 on 8.x-3.x authored by ndeet
    Issue #2572119: Updating SystemMessage action to use doExecute().
    

  • klausi committed 1722abe on 8.x-3.x authored by emclaughlin
    Issue #2572119: Update DataListCountIs condition to use doEvaluate
    

  • klausi committed e365111 on 8.x-3.x authored by emclaughlin
    Issue #2572119: Update EntityIsOfBundle condition to use doEvaluate
    

  • klausi committed 2a7cbd3 on 8.x-3.x authored by emclaughlin
    Issue #2572119: doEvaluate() conversion for EntityIsOfType
    

  • klausi committed dab4210 on 8.x-3.x authored by emclaughlin
    Issue #2572119: doEvaluate() conversion for NodeIsPromoted
    

  • klausi committed 509b9b1 on 8.x-3.x authored by emclaughlin
    Issue #2572119: doEvaluate() conversion for EntityHasField
    

  • klausi committed 7cb00fc on 8.x-3.x authored by ndeet
    Issue #2572119: doEexcute() for UserUnblock
    
reeller_sk’s picture

Issue summary: View changes

  • klausi committed 642b84d on 8.x-3.x authored by ndeet
    Issue #2572119: doExecute() conversion for EntitySave action
    
reeller_sk’s picture

Issue summary: View changes
dasjo’s picture

Issue tags: +Novice

  • fago committed 0d0acf1 on 8.x-3.x authored by reeller_sk
    Issue #2572119: Updating DataSet action to use doExecute().
    
fago’s picture

Issue summary: View changes
fago’s picture

Issue summary: View changes
ndeet’s picture

Issue summary: View changes
ndf’s picture

Added last *not-refactored* conditions:
- DataIsEmpty
- UserHasRole

ndeet’s picture

Issue summary: View changes
fago’s picture

Issue summary: View changes

DataListItemAdd - created pull request - 299 (reeller_sk): needs work

fago’s picture

can we mark items that needs work like this in the summary? It's hard to figure out what needs review and what not else.

fago’s picture

Issue summary: View changes

  • fago committed 196c855 on 8.x-3.x authored by ndeet
    Issue #2572119: Convert execute to doExecute() for EntityPathAliasCreate...

  • klausi committed 5f4fc9e on 8.x-3.x authored by ndeet
    Issue #2572119: Convert execute to doExecute() for DataConvert action
    
klausi’s picture

Issue summary: View changes

Conditions are all done, yay!

Only one action remaining and updating the documentation.

shahinam’s picture

Which item is remaining, Are you referring to PR #299.

shahinam’s picture

Status: Active » Needs review

Update DataListItemAdd action to use doExecute().
PR: https://github.com/fago/rules/pull/326

  • klausi committed 579b98a on 8.x-3.x authored by shahinam
    Issue #2572119 by reeller_sk, shahinam: doExecute() conversion for...
klausi’s picture

Issue summary: View changes
Status: Needs review » Fixed

merged, thanks!

I think that was all for this issue, thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.