strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated

Created on 14 August 2023, 11 months ago
Updated 18 December 2023, 7 months ago

Problem/Motivation

Drupal 11.1.2
PHP 8.1.x
Core CKEditor5 is disabled until we migrate the CKEditor4 plugins. CKEditor 4.x is enabled as a contrib module

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\ckeditor_scayt\Plugin\CKEditorPlugin\ScaytCKEditorButton->getCkEditorVersion() (line 173 of /var/www/docroot/modules/contrib/ckeditor_scayt/src/Plugin/CKEditorPlugin/ScaytCKEditorButton.php)

  public function getCkEditorVersion() {
    $library = $this->libraryDiscovery->getLibraryByName('core', 'ckeditor');
    $version = $library['js'][0]['version'];
    $pluginVersion =  (strpos($version, '4.17') !== FALSE) ? '4.17' : ((strpos($version, '4.18') !== FALSE) ? '4.18' : '4.19');
    return $pluginVersion;
  }

Steps to reproduce

Have Drupal 10+ with core CKEditor5 disabled and contrib CKEditor4 enabled.

Proposed resolution

It appears that this line in the function
$library = $this->libraryDiscovery->getLibraryByName('core', 'ckeditor');
is looking for the library for the Core CKEditor and it is not enabled therefore the $version var returns a null that php8.x does not like

🐛 Bug report
Status

Closed: won't fix

Version

1.4

Component

Code

Created by

🇺🇸United States Aaronwa

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024