Problem/Motivation

Follow-up from #3224299-40: [META] Make Drupal 7 core compatible with PHP 8.1

I'm seeing this on ctools ATM, in the midst of tracking it down but thought I'd ask

exception: [Deprecated] Line 1898 of includes/bootstrap.inc:
htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated

EDIT: to give more context to why I ask, is that I think happening very generically in ctools, for example:

  protected function assertPluginMissingFunction($module, $type, $id, $function = 'function') {
    $func = ctools_plugin_load_function($module, $type, $id, $function);
    $this->assertEqual($func, NULL, t('Plugin @plugin of plugin type @module:@type for @function with missing function successfully failed.', array(
      '@plugin' => $id,
      '@module' => $module,
      '@type' => $type,
      '@function' =>$func,
    )));

Where one of those @ variables in t() is being passed to check_plain as either FALSE or NULL (null in this case). There are probably more places than can be counted. I could probably cast them in the test to make it pass (because I think this is testing missing plugins)

Steps to reproduce

Proposed resolution

Remaining tasks

Write tests

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3254699

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joelpittet created an issue. See original summary.

joelpittet’s picture

Component: base system » bootstrap system
Status: Active » Needs review
Issue tags: +Needs tests

liam morland’s picture

Status: Needs review » Reviewed & tested by the community

Merge request 1553 looks good. The others only have the tests. This will silence the deprecation messages without side-effects.

Another solution would be to add the type declaration to check_plain(). This would mean callers would have to ensure that function is only called with strings.

liam morland’s picture

Issue tags: -Needs tests +PHP 8.1
joseph.olstad’s picture

@joel_pittet, great work, MR 1554 tests prove that we need the change.

MR !1553 has both the fix and the tests.

RTBC+

This is ready for commit

  • mcdruid committed ea6f8eb on 7.x
    Issue #3254699 by joelpittet, Liam Morland, joseph.olstad: [PHP 8.1]...
mcdruid’s picture

Status: Reviewed & tested by the community » Fixed

Thank you!

Status: Fixed » Closed (fixed)

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