Action that combines two lists

Created on 19 January 2025, 2 months ago

Problem/Motivation

There is currently no action that can combine the list values of two existing lists into one.

Proposed resolution

Create a new ECA action, as well as the corresponding documentation.

I'd be happy to contribute it :)

Feature request
Status

Active

Version

2.1

Component

Code

Created by

🇩🇪Germany Istari

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • API change

    Changes an existing API or subsystem. Not backportable to earlier major versions, unless absolutely required to fix a critical bug.

  • developer

    Used for Documentation issues that pertain to developer docs.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Istari
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I'd be happy to review this if something is available.

  • Pipeline finished with Canceled
    about 2 months ago
    Total: 179s
    #412690
  • Pipeline finished with Failed
    about 2 months ago
    Total: 560s
    #412692
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Left a couple of comments in reply to your questions.

    In addition to that, I've seen you're combining the values from the config? I'd say, what's configured in config is a token name, so those tokens are placeholders for the lists that have been stored in them before. That means, you need to use the token service to receive the lists first, and the result is what you then need to combine.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    And one more thought: is this really about array_combine? Might well be the intention of this plugin, I just don't know what a use case could be.

    When this issue was opened, I had something like array_merge in mind, but that was probably a mistake at my end. Needs some clarification, I guess.

  • 🇩🇪Germany Istari

    Well I'm open to change the logic to merge the two lists into one.

    But you might be right I can imagine that there could be more potential use cases where a list merge is more needed than a combined list.

    Also a merge list action would remove multiple entries of the same value.
    Sry hadn't thought about this.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    The array_combine function is combining a list of keys with a list of values. Not sure, if we have a use case for that?

    I can certainly see a use case for merging arrays, maybe even for deep merge.

    Please also note the test errors on the MR.

  • 🇩🇪Germany Istari

    I am currently in testing and polishing phase.
    My idea with merging two list is, that we not only make sure we remove duplicates in the merged list, but we also have to take a look on their respective data types.

    Let me give an example:
    What if we need to merge two Node objects from two lists into one?
    How can we check if the Node Object from list one is the same from list two?
    What array_merge() in case of objects does is, it puts both objects into into the merged array.

    So I implemented a method isEqual() that checks either in case of an entity for the id or in case of typed data the value.

    I'm currently running out of time with my work, but I will upload the result during today, when the final testing is done.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 689s
    #416178
  • Pipeline finished with Success
    about 2 months ago
    Total: 494s
    #416520
  • Pipeline finished with Success
    about 2 months ago
    Total: 525s
    #417666
  • Pipeline finished with Success
    about 2 months ago
    Total: 557s
    #417668
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I've left a couple of comments in the MR. And with regard to the duplicate handling, I think this is out of scope for this action plugin. De-duplicating and maybe sorting a list should be separate action plugins. It's much more flexible if we keep the actions granular as users then can combine them as they need to.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 746s
    #426902
  • Pipeline finished with Failed
    about 1 month ago
    Total: 577s
    #426931
  • Pipeline finished with Failed
    about 1 month ago
    Total: 563s
    #428512
  • Pipeline finished with Failed
    30 days ago
    Total: 514s
    #439369
  • Pipeline finished with Success
    30 days ago
    Total: 465s
    #439372
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I've left a few code change suggestions and comments in the MR. We should then also have some tests for this.

  • Pipeline finished with Failed
    24 days ago
    Total: 403s
    #444095
  • Pipeline finished with Failed
    24 days ago
    Total: 344s
    #444097
  • Pipeline finished with Success
    24 days ago
    Total: 463s
    #444098
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Getting close. Two more comments in the MR and a test is also required for this.

  • Pipeline finished with Failed
    10 days ago
    Total: 489s
    #455427
  • Pipeline finished with Failed
    10 days ago
    Total: 480s
    #455429
  • Pipeline finished with Success
    10 days ago
    Total: 478s
    #455430
  • Issue was unassigned.
  • Status changed to Needs review 10 days ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This is looking good now. Only a tiny clean-up is left to remove 2 obsolete lines of code.

    After that, only tests are required. They should at least test a couple of list merges and also test the cases that would not be executed due to the access control.

Production build 0.71.5 2024