- Issue created by @Amer cloudy
- ๐ฎ๐ณIndia Ishani Patel
ishani patel โ made their first commit to this issueโs fork.
- Merge request !12073Resolve #3523317 "Typeerror drupalcomponentutilityhtmlescape argument" โ (Open) created by Unnamed author
Alternatively you have the option of changing your code not to pass a null.
- ๐บ๐ธUnited States smustgrave
Issue summary is incomplete.
But also need some more investigation, what's being passed here that's null. If caused by custom code then seems the custom code is wrong.
In fact, in these cases the log messages would make no sense without values in placeholders.
- ๐ฉ๐ชGermany gbyte Berlin
Yes the issue related to custom code and i already have production that save logs in database with null it works with D10 and when upgrade to drupal 11 the issue appears
- ๐ฌ๐ทGreece arx-e
I had the same error trying to access a simplenews page (admin/config/services/simplenews/settings/subscription) and this patch solves the issue.
- ๐ฎ๐นItaly uccio Turin
I had the same error trying to access to admin/reports/status in a site with a lot of module contrib but only after the upgrade drupal 10.4.7
-> 11.1.7 - ๐บ๐ธUnited States _andrew Pennsylvania
Please see supplied patch which should apply cleanly in 11.1 and probably 11.2 which solves the issue. Relaxes the string requirement allowing for a null argument, and returns an empty string on null.
- ๐บ๐ธUnited States mighty_webber
11.2.2 made some changes that made patch #14 not work correctly. These are the same changes in patch 14, just applied to different line numbers.
- ๐บ๐ธUnited States ryan osฤซtis
I was attempting to test the patch from #14 ๐ TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given Needs review , but patching is affected as well. Insidious little bug, this one.
- PHP: 8.3
- Drupal: 11.2.2
- Original Triggering Action: I attempted to enable the Gin Admin Theme as the default theme on a clean new Drupal 11 site. I then tried to install the patch as a fix for the null text error I recieved. All pages on the site now display it.
- Error Message: While using composer install, this was returned:
Gathering patches from patch file. Gathering patches for dependencies. This might take a minute. - Installing drupal/core (11.2.2): Extracting archive - Applying patches for drupal/core fix-type-error-null-text.patch (Fix type error null text) In RemoteFilesystem.php line 105: [TypeError] Composer\Util\RemoteFilesystem::copy(): Argument #1 ($originUrl) must be of type string, null given, called in /v ar/www/html/vendor/cweagans/composer-patches/src/Patches.php on line 388
- ๐บ๐ธUnited States mighty_webber
I've attempted to apply it using extra.patches.drupal/commerce, extra.patches.drupal/core, extra.patches.drupal/core-recommended, all of which fail.
patch "-p4" --no-backup-if-mismatch -d "M:\development\projects\react-safe-drupal/web/modules/contrib/commerce" < "C:\Users\User\AppData\Local\Temp/686448b16b77a.patch" can't find file to patch at input line 5 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |diff --git a/web/core/lib/Drupal/Component/Utility/Html.php b/web/core/lib/Drupal/Component/Utility/Html.php |index 1a53a8de..e4426fe4 100644 |--- a/web/core/lib/Drupal/Component/Utility/Html.php |+++ b/web/core/lib/Drupal/Component/Utility/Html.php -------------------------- File to patch: Skip this patch? [y] Skipping patch. 2 out of 2 hunks ignored Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2025-07-01/fix-type-error-null-text-3523317-15.patch
I have attempted with both patches.
- ๐บ๐ธUnited States mighty_webber
Ok, I think I resolved the issue with it. Specifically, the file pointers.
When composer is installing, it's installing from web/core. The patch points to web/core/lib.
It should look like :
diff --git a/lib/Drupal/Component/Utility/Html.php b/lib/Drupal/Component/Utility/Html.php index 1a53a8de..e4426fe4 100644 --- a/lib/Drupal/Component/Utility/Html.php +++ b/lib/Drupal/Component/Utility/Html.php
Instead of
diff --git a/web/core/lib/Drupal/Component/Utility/Html.php b/web/core/lib/Drupal/Component/Utility/Html.php index 1a53a8de..e4426fe4 100644 --- a/web/core/lib/Drupal/Component/Utility/Html.php +++ b/web/core/lib/Drupal/Component/Utility/Html.php
- ๐บ๐ธUnited States mighty_webber
As an added note, I think this patch creates issues with fields with "Unlimited" cardinality. When trying to root out the issue (couldn't create new fields with unlimited cardinality or save forms with existing fields with unlimited cardinality and "add another item" would fail, as the index values for the weight/order were coming in as null/empty strings.
Oddly enough, after removing this patch from my installation, I didn't not continue receiving the error noted in this ticket when attempting to install commerce, and the functionality of fields with unlimited cardinality returned.
- Status changed to Needs work
25 days ago 2:14pm 9 July 2025 I manually applied the changes in patch at #15, it seems to have worked.
- ๐ท๐บRussia Alezu
The problem with the patch from #15 is that it considers zero symbol as empty that breaks sorting of multiple field elements and I believe not only it. So we should check if the input text is 0.
Changes in patch #15 seems to have caused problems with the weight variable throughout the site. Reverted this patch, which seems to have resolved the weight problem, then manually applied patch #21. Seems to work.
- ๐บ๐ธUnited States smustgrave
Summary update and steps to reproduce still appear to be missing
- ๐บ๐ธUnited States w01f
Can confirm manually applying #21 resolves the issue on our test site.
- ๐บ๐ธUnited States smustgrave
#24 is still needed and this needs to be reviewed