Problem/Motivation

Spotted use of some deprecated methods during module upgrade.

Proposed resolution

Changes in drupalmoduleupgrader.grep.yml:

function_calls:
  check_plain: '\Drupal\Component\Utility\SafeMarkup::checkPlain'

to

function_calls:
  check_plain: '\Drupal\Component\Utility\Html::escape'

However this may cause "double escaping" as highlighted here: #2549395: SafeMarkup methods are removed in "Escaping markup" - "Twig" section.

Remaining tasks

1. Is double escaping above ok or does it need an associated comment and link to this change record?

2. Should format_date be changed to use a formatter with the same arguments rather than the advised service from format_date documentation.

i.e.

format_interval: '\Drupal::service("date.formatter")->formatInterval'

or

format_interval: '\Drupal\Core\Datetime\DateFormatter::format'

The latter has the same arguments and seems the right choice to me. Does this require a comment in code also to recommend using the service?

User interface changes

N/A

API changes

Depends on choices in the "Remaining Tasks" above.

Data model changes

N/A (None that I'm aware of)

Original report by [mccrodp]

N/A

Comments

mccrodp created an issue. See original summary.

mccrodp’s picture

Assigned: mccrodp » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new706 bytes

Patch includes change from SafeMarkup::checkPlain to Html::escape only.

webchick’s picture

Status: Needs review » Fixed

Awesome stuff, thank you!

Committed and pushed to 8.x-1.x. Thanks!

  • webchick committed a7b4fee on 8.x-1.x authored by mccrodp
    Issue #2576661 by mccrodp: Remove calls to deprecated methods (...

Status: Fixed » Closed (fixed)

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