Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292997

Add Exception for TypeError Argument must be String in \Drupal\Component\Utility\Html escape{}

$
0
0

(Issue summary updated after comments from #17 and below)

Many users report after updating or migrating to a Drupal version like Drupal core 9.5.7 or above, the following error gets reported in different shades of it in detail:

TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string, array given in htmlspecialchars() (line 432 of core\lib\Drupal\Component\Utility\Html.php)

This issue has been modified and converted into a feature request for core handling. The original reporter provided an error output showing that some Views field formatting has caused the error in his case. Others reported to have a WSOD now making the site not maintainable no more caused by other contrib modules.

(Note: Use the patch provided here to make your site operable again and help by uncommenting the check code to find out your individual cause).

Summary

After collecting some user reports it finally turned out soon, that this issue can quickly turn into a misinforming collection basin for the same TypeError message. For different reasons and causes in each of the cases. Reason for this TypeError caused in escape{} is that Arguments of Type Array accidently get handed over to Html.php escape{} and run thru htmlspecialchars(), where Type String is mandatory. Why this happens NOW so often in different individual cases and what has changed so that this collusion happens and suddently becomes obvious in such mass occurance is different in each scenario and should be cleared in the respective issue queues of the subsystems or contrib projects repsonsible for this Array send to escape().

What this issue is now about

How we deal with this flood in core for all upcoming cases to prevent WSOD or sites being unoperable? But keep track on the issue? How to help informing about the reasns and more details about the Array passed since this Error is very generic and tells not much about the root cause. After disussions on Slack I came to the conclusion: What this issue should be about is to add an informal way of dealing with this error in case if Argument is Array like started from #30 and below without interrupting (breaking site/code) since this is not a dangerous issue. First patches provide already the functionality and error handling to make sites operable again. In further discussions it became obviuous: best way would be to add an Exception to deal with this.

Users humbling over this issue by searching for a fix should read carefully from #17 and below how to test what this TypeError has caused in each individual case and should report it in the respective issue queue of the project causing this.

(This starting issue summary has been rcompletely rewritten for the solution oriented context now by @diqidoq in favour of a new issue, to keep track of the initial reports. Thanks for the original report and all the reports helping to find a clear goal for this.)


Viewing all articles
Browse latest Browse all 292997

Trending Articles