eca_endpoint: Action "Request: Get path argument" needs ability to ignore language code

Created on 15 April 2025, 28 days ago

Problem/Motivation

Having a bunch of configurations that are being shipped accross different sites. Some of these configurations make use of "Request: Get path argument" action. When one site uses language codes in the URL path and some don't, this action will return a different argument.

Example:

1. Node page on site without language code in path: "/node/1"
2. With language code is path: "/en/node/1"

Now when executing the action using position 1, then result is "1" for (1.) whereas the result is "node" for (2.)

There is a token provided by contrib token module that automatically "skips" the language code, something like this: "[current-page:url:args:value:1]"

We may want to achieve same behavior when using this action.

Steps to reproduce

Proposed resolution

Add an option to this action that allows to automatically use the internal system path which would then be "skipping" the language code. Some users may want to include the language code to be considered, so it should be optional.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

3.0

Component

Miscellaneous

Created by

🇩🇪Germany mxh Offenburg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mxh
  • 🇮🇳India prabha1997

    I am working on this issue

  • Pipeline finished with Failed
    21 days ago
    #479172
  • 🇩🇪Germany mxh Offenburg

    Thanks for addressing this issue.

    I briefly looked into your current MR and suggest considering a different solution path. Instead of brute-force checking whether we might have a language code as prefix, may only solve this particular use case but not anything else that may add a certain prefix to a given system path. Also, there even may be routes that could actually start with a language code as prefix but were not added by the translation system...

    Here is a suggested way to get the "correct" path we want to finally work with:

    $current_url = Url::fromRoute('<current>');
    
    // We want to get the path without language prefix, therefore use internal.
    $path = $current_url->getInternalPath();
    $path_args = explode('/', $path);
    // ...
    
  • Pipeline finished with Canceled
    21 days ago
    Total: 152s
    #479233
  • 🇮🇳India prabha1997

    I have updated the MR as per @mxh review comments

  • Pipeline finished with Failed
    21 days ago
    Total: 571s
    #479238
  • 🇩🇪Germany mxh Offenburg

    Thanks. You've removed the option "skip_language_prefix" in the last commit, but this option is needed - could it be re-added?

    The new logic should also only apply when this new option is in use, otherwise the previously implemented logic should just be applied as it was before, so we don't break existing configurations.

  • 🇮🇳India prabha1997

    I’ve re-added the skip_language_prefix option and updated the logic to use the internal path only when this option is enabled. Existing configurations will continue to work with the original logic.

    Please have a look and let me know if any further changes are needed.

  • Pipeline finished with Failed
    20 days ago
    Total: 556s
    #479833
  • 🇩🇪Germany mxh Offenburg

    Thanks, now when using the internal path, we may want to use a proper naming of the option for that. Instead of "Skip language prefix" it may be called "Use internal path" as option, with a description something like "When using the internal path, added prefixes such as language code will be ignored. For example, both "/en/node/1" and "/node/1" would return "1" when index is set to 1.". This should make it more clear and also be understood for other cases than language code prefix.

    Tests and code checks are currently all red, but that doesn't seem to come from the MR itself, rather from the current state of the 3.0.x branch. Once the section above got addressed we may set this again to Needs review.

  • 🇮🇳India prabha1997

    Thanks @mxh for the detailed feedback!
    I’ve updated the MR to reflect the suggested changes:
    Renamed the option from "Skip language prefix" to "Use internal path".
    Updated the description to make it more general, not just about language prefixes.
    Please have a look and let me know if any further changes are needed.

  • Pipeline finished with Failed
    19 days ago
    Total: 531s
    #480954
  • 🇩🇪Germany mxh Offenburg

    Thanks for addressing the feedback.

    The logic is still a bit different than before when we don't use the option. For example the $path parts are being split using the explode function and if we have not specified any path position, the following is being returned now: return '/' . implode('/', $parts);

    Despite the logic not being the same anymore we may set this to NR for now as the end result may still be the same (but I'm not sure).

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Note, I'm in the process of fixing all tests for the 3.0.x branch of ECA in 📌 Fix PhpStan 2.0 issues with the code base Active and the MR can be rebased when this has been completed. Then we can make sure that the MR passes all tests as well.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    OK, the other issue is fixed and I've rebased the MR, let's see what the tests are looking like now.

  • Pipeline finished with Failed
    19 days ago
    Total: 777s
    #481471
  • 🇩🇪Germany mxh Offenburg

    There are some PHPCS complaints that should be addressed.

  • Pipeline finished with Success
    18 days ago
    Total: 474s
    #481711
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This is looking good to me, except for 1 suggestion that I've made in the MR.

    Then, we need an update hook to update existing models and we should have some tests.

    Note to self: this should be back ported to 2.1.x when completed.

  • 🇮🇳India prabha1997

    @jurgenhaas I have updated the description text to use a clearer example, where the index and the value are different to avoid confusion.

  • Pipeline finished with Success
    15 days ago
    Total: 534s
    #483556
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thank you @prabha1997 that's much better. It's now time for the update hook and tests, are you up for that?

  • 🇮🇳India prabha1997

    I've given it a try, but I'm having some difficulty getting it to work as expected. I haven't been able to achieve the correct results yet.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    @prabha1997 which part are you trying first? For the update hook there are examples in the 2.x branch, e.g. eca_update_8011(). For tests, you could probably also build on top of already existing tests, if that's helpful.

  • 🇮🇳India prabha1997

    @jurgenhaas
    In the 3.0.x branch, I noticed that the eca.install file was removed.
    Since I need to add an update hook, is it okay to reintroduce the eca.install file, or is there a specific reason it was removed?

  • 🇩🇪Germany jurgenhaas Gottmadingen

    @prabha1997 the missing eca.install file is due to the expected upgrade path to ECA 3 where all the updates must have been applied before upgrading to 3. So, therefore it would be better for this to be a separate MR which goes against the 2.1.x branch.

Production build 0.71.5 2024