Closed (duplicate)
Project:
Drupal core
Version:
11.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Dec 2019 at 03:49 UTC
Updated:
12 Aug 2025 at 16:51 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
venugopp commentedHere is the fix for the issue.
Replacing
!issetwithemptyComment #3
aklalita commentedComment #8
kristen polThanks for the issue and patch. If this is still an issue, it needs a reroll.
Comment #9
kristen polFixing title.
Comment #10
kristen polThe issue summary needs an update as well.
Comment #11
joshua1234511Rerolled the patch for v9.4.0
Tested the Patch and issue as per


- Add a link field to any content type
- Allow external links for the field.
- Add a new content and fill the link with query parameters
eg: https://www.drupal.org?q=123&test=
- The link will be displayed as https://www.drupal.org?q=123&test= on FE
- Apply patch and clear cache
- Revisit the page an the link will be https://www.drupal.org?q=123&test
Before patch
After Patch
Updated the issue summary
Comment #13
kristen polErrors didn't look related so retesting.
Comment #15
joshua1234511Some of the test fails are related to the above change the existing test will also need to be modified as the test are written to have =

On further investigation
(empty($value)) does not handle the 0 case
ie: it will treat 0 as empty
There was 1 failure:
1) Drupal\Tests\system\Functional\Pager\PagerTest::testActiveClass
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'?page=0'
+'?page'
Comment #17
heilop commentedThe patch #11 Rerolled.
I included an extra validation to avoid treating 0 as empty. I tested for external links and works for internal as well.
Comment #18
joshua1234511Investigated the failing test cases.

The above patch applied for all the query parameters irrespective of external or internal links (As per issue reported: only need case for external links)
Eg: internal search links with default key='' case.
Updated the build query to remove empty query parameters only for external links.
Comment #19
rakhi soni commentedI have created a patch to fix the 'External links cannot have empty query parameters' issue, Now its working fine on 9.5x version,
Before Patch - url like https://www.drupal.org?q=
After patch - url like https://www.drupal.org?q
kindly review patch,,
Comment #20
kristen polStill getting failures so back to needs work.
Comment #24
nikolay shapovalov commentedThanks for all you effort, but from my side this doesn't look like bug.
It looks like default behavior.
My suggestion if you want this behavior create custom formatter, or contrib module that implements this.
Comment #25
dcam commentedThis is a duplicate of #3040048: Url generator will add '=' after query parameter when value is an empty string which is both older and has more recent work on a fix. Credit has been granted to the people who worked on patches.