Installing module on D8.3.3 I got following message:

Warning: htmlspecialchars() expects parameter 1 to be string, object given in Drupal\Component\Utility\Html::escape() (line 423 of core/lib/Drupal/Component/Utility/Html.php).

Just installed honeypot months ago on other site, and got no message like this.

At first look I cant see any other problem

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MartinMa created an issue. See original summary.

rhormens’s picture

Assigned: Unassigned » rhormens
eelkeblok’s picture

Just to save somebody a few minutes of debugging, the problem is the Link object being passed into t() from the hook_install implementation.

eelkeblok’s picture

Status: Needs work » Needs review
FileSize
724 bytes

I took the liberty of baking a patch. Sorry if I duplicated some of your work, rhormens.

Just as some extra explanation about the patch, it not only changes the type of object passed into t(), but also changes the structure of the translated string. It is generally considerded better to keep linked text in context and only insert the linked url with a placeholder. This makes the translator's job a lot easier.

geerlingguy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. I'll merge soon and put out a new release. Thanks!

geerlingguy’s picture

Not only that, the install message looks pretty dumb the way it's currently displaying:

Honeypot install message bug

  • geerlingguy committed d25777c on 8.x-1.x authored by eelkeblok
    Issue #2885016 by eelkeblok, geerlingguy, MartinMa: htmlspecialchars()...
geerlingguy’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
78.71 KB

Fixed via patch, thanks for everyone's help! The install message looks correct again:

Honeypot successful install message.

rhormens’s picture

Assigned: rhormens » Unassigned
geerlingguy’s picture

Title: htmlspecialchars() expects parameter 1 to be string » Fix install message to prevent htmlspecialchars() warning

Updating title for posterity.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.