$url objects in \Drupal\recurly\Controller\RecurlySubscriptionListController::subscriptionStateMessage to be converted to strings

Created on 23 May 2023, almost 2 years ago
Updated 24 May 2023, almost 2 years ago

Problem/Motivation

There are a couple of places in \Drupal\recurly\Controller\RecurlySubscriptionListController::subscriptionStateMessage where we create a $url, and then use it as a placeholder value in a translated string. But the code doesn't call $url->toString() and so the links are never actually created.

You'll see an error like this:

The website encountered an unexpected error. Please try again later.
TypeError: strpos(): Argument #1 ($haystack) must be of type string, Drupal\Core\Url given in strpos() (line 358 of core/lib/Drupal/Component/Utility/UrlHelper.php).

strpos(Object, ':') (Line: 358)
Drupal\Component\Utility\UrlHelper::stripDangerousProtocols(Object) (Line: 221)
Drupal\Component\Render\FormattableMarkup::placeholderFormat('This plan has expired. Please <a href=":url">purchase a new subscription</a>.', Array) (Line: 195)
Drupal\Core\StringTranslation\TranslatableMarkup->render() (Line: 15)

Proposed resolution

Use $url->toString() everywhere we insert a URL into a translated string in \Drupal\recurly\Controller\RecurlySubscriptionListController::subscriptionStateMessage

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇺🇸United States eojthebrave Minneapolis, MN

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024