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.
Action "Add an item to a list" needs to be ported to Rules 8.x-3.x.
Action "Add an item to a list" needs to be ported to Rules 8.x-3.x.
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #2
dasjoComment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedCode for this is up at https://github.com/fago/rules/pull/102
Comment #4
dasjothanks steve, unassigning as per the needs review state
Comment #5
fagoThanks! See PR, some minor stuff needs work.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedBit stuck on this one, here's the deets I posted to github:
Hi - am stuck on two issue on this one, just spoke to fago who didn't know what the issue is either so posting here whilst trying to debug too, although may move to something else whilst I'm stuck!
I'm setting a provided value but it says the context is not valid. Also I'm having to force values for 'unique' and 'pos' even though I say they're not required. Here's the output of my test:
There was 1 error:
1) Drupal\Tests\rules\Unit\Action\ListAddItemTest::testActionExecution
Drupal\Component\Plugin\Exception\ContextException: The outputlist provided context is not valid.
/Users/steve/Sites/d8dev/modules/rules/src/Context/RulesContextTrait.php:61
/Users/steve/Sites/d8dev/modules/rules/src/Context/RulesContextTrait.php:50
/Users/steve/Sites/d8dev/modules/rules/src/Context/RulesContextTrait.php:40
/Users/steve/Sites/d8dev/modules/rules/src/Plugin/Action/ListAddItem.php:90
/Users/steve/Sites/d8dev/modules/rules/tests/src/Unit/Action/ListAddItemTest.php:66
phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:179
phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:132
There was 1 failure:
1) Drupal\Tests\rules\Unit\Condition\UserHasEntityFieldAccessTest::testConditionEvaluation
Failed asserting that false is true.
/Users/steve/Sites/d8dev/modules/rules/tests/src/Unit/Condition/UserHasEntityFieldAccessTest.php:123
phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:179
phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:132
FAILURES!
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedok, think it's fixed now & ready for testing
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #9
fagoThanks - I reviewed your PR and posted come comments.
Comment #11
klausiMerged, thanks!
Comment #13
fagoRe-opening for addressing the todo for the info alter. Check the d7 info alter, implement like it's done for
FetchEntityById
(seerefineContextDefinitions()
) and add test coverage for it.Comment #14
fagoComment #15
dasjoComment #16
dasjoI made some progress here.
While EntityFetchByField refines based on the type being configured, in this case we need to get the type from the configured context itself.
We noticed that ContextHandlerTrait::mapContext() should also work without a state.
The code can be found in this branch:
https://github.com/fago/rules/compare/8.x-3.x...dasjo:2317193-data-add-w...
This was maybe a good exercise and can be useful for other plugins, but I realised that we shouldn't provide anything for this action: the drupal 7 action just manipulates the list and also the drupal 8 implementation is coded like this. So instead of refining context here, we just remove the provided definition.
Made a pull request:
https://github.com/fago/rules/pull/196
Comment #17
fagoThanks, merged.