Issue Task Rejected

#101625Simplify GeneralUtility::implodeArrayForUrl

Oliver Klee 08/09/23, 07:40 updated 07/16/24, 14:37

Description

From https://review.typo3.org/c/Packages/TYPO3.CMS/+/80247/4#message-6b4a6d09948689295f9467fbb69c930995cd8549:

I wonder if that method cannot be simplified (in another patch, of course) that uses http_build_query() instead of manual array assembling.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 7

  1. Oliver Klee changed subject Simplify GneralUtility::implodeArrayForUrl Simplify GeneralUtility::implodeArrayForUrl 08/09/23, 07:40

  2. Stefan Bürk commented 08/15/23, 13:44

    Small note/hint:

    The current implementation ensures a rawurlencode on values in a recursive manner.
    This needs to be carefully checked if replaced with `http_build_query()`.

    Maybe it makes sense to add special tests for this, if not already contained. (Not checked).

  3. Benni Mack commented and changed status New Needs Feedback 06/19/24, 21:05

    There is only one place left, we can deprecate this method? Or we keep it? I don’t know if we have a problem keeping this method? Maybe documenting the difference between this method and `http_build_query´ ?

  4. Garvin Hicking commented 06/25/24, 14:43

    @benni That method is also used by a few public extensions:

    sr_feuser_register
    yoast_seo
    tt_address
    cs_seo
    nnhelpers
    pw_comments
    maps2
    recaptcha
    mediaoembed
    jar_utilities
    jumpurl
    tt_products
    in2publish_core
    rn_base
    div2007
    crawler

    Also undecided on whether it should be kept. As far as I can see most usages could be replaced in the extensions, so maybe we should encourage that by deprecating this method.

  5. Benni Mack commented 06/26/24, 10:44

    Hey Garvin,

    I would then suggest to just document the native alternative in the methods’ comments.

  6. Georg Ringer commented and changed status Needs Feedback Rejected 07/16/24, 14:35

    hey Oliver,

    this is not that easy as it seems.

    When changing the method’s body to

    return http_build_query($theArray, $name);

    the tests will fail hard

    --- Expected
    +++ Actual
    @@ @@
    -'&foo[one]=%E2%88%9A&foo[two]=2'
    +'one=%E2%88%9A&two=2'

    therefore I suggest leaving the method for the time being until we really don’t need it anymore and get rid of it.

    as the benefit is so small compared to troubles we can produce for people I am closing this issue.
    In an ideal world we could just migrate GU to something nicer but just for moving code around it is not worth the troubles

  7. Oliver Klee commented 07/16/24, 14:37

    Makes sense. Thanks for checking and for cleaning up the issues, Georg!