Deprecated function: strlen()

Created on 7 April 2025, 10 days ago

Steps to reproduce

I just install the 2.0.0-beta2 version and i am getting this warning.

Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\domain_config_ui\DomainConfigUIManager->getSelectedConfigName() (line 47 of modules/contrib/domain/domain_config_ui/src/DomainConfigUIManager.php).

Proposed Solution

Here is the old code.
public function getSelectedConfigName($name, $omit_language = FALSE) {
$domain_id = $this->getSelectedDomainId();

if (!is_null($domain_id)) {
$prefix = "domain.config.{$domain_id}.";
$langcode = $this->getSelectedLanguageId();

if (!$omit_language && strlen($langcode) > 0) {
$prefix .= "{$langcode}.";
}
return $prefix . $name;
}

return $name;
}

Update one:

public function getSelectedConfigName($name, $omit_language = FALSE) {
$domain_id = $this->getSelectedDomainId();

if (!is_null($domain_id)) {
$prefix = "domain.config.{$domain_id}.";
$langcode = $this->getSelectedLanguageId();
if (!$omit_language && !empty($langcode)) {
$prefix .= "{$langcode}.";
}
return $prefix . $name;
}

return $name;
}

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India suraj3310 Punjab

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

Comments & Activities

Production build 0.71.5 2024