Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.194 found 2 PHP-8 deprecation warnings #1531

Closed
horst-n opened this issue Feb 15, 2022 · 5 comments
Closed

3.0.194 found 2 PHP-8 deprecation warnings #1531

horst-n opened this issue Feb 15, 2022 · 5 comments

Comments

@horst-n
Copy link

horst-n commented Feb 15, 2022

Short description of the issue

I used PW 3.0.194 against PHP 8.1.12 and got two deprecation warnings

a) Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in ... wire-3.0.194\core\PagesPathFinder.php on line 1928

b) Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in ... wire-3.0.194\modules\LanguageSupport\LanguageSupportPageNames.module on line 515

Optional: Suggestion for a possible fix

I could fix these with

a) 1928: if(is_null($segment) || !strlen($segment)) continue;

b) 515: if($name == Pages::defaultRootName || is_null($name) || !strlen($name)) return '/';

@horst-n
Copy link
Author

horst-n commented Feb 16, 2022

I found some more.

The following belong to PW core:

Deprecated: Automatic conversion of false to array is deprecated in ... wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module on line 141 

possible fix:

  78:				static protected $isReady = false;  // change to null for PHP 8.1+ ?? 

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in wire-3.0.194\modules\Inputfield\InputfieldMarkup.module on line 93 
   93:		if(is_string($markupText) && strlen($markupText)) { 

The following belongs to RepeaterMatrix:

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in ... site\modules\FieldtypeRepeaterMatrix\InputfieldRepeaterMatrix.module on line 102 

possible fix:

 100:			if(!$label) $label = $this->field->get("matrix{$type}_label");
 101:			if(!$label) $label = $this->field->get("matrix{$type}_name");
 102:			$out = str_replace('{matrix_label}', $label, $out);
to
 100:			if(!$label) $label = $this->field->get("matrix{$type}_label");
 101:			if(!$label) $label = $this->field->get("matrix{$type}_name");
 102:           if(is_null($label)) $label = '';  // add this additional check
 103:			$out = str_replace('{matrix_label}', $label, $out);

And the last one for this time belongs to FieldtypeCombo:

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in ... site/modules/FieldtypeCombo/ComboSchema.php on line 224 

possible fix:

 224:			$type = strtolower($comboSettings->get($prefix . 'type'));
to
 224:			$type = is_null($comboSettings->get($prefix . 'type')) ? '' : strtolower($comboSettings->get($prefix . 'type'));

@matjazpotocnik
Copy link
Collaborator

b) Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in ... wire-3.0.194\modules\LanguageSupport\LanguageSupportPageNames.module on line 515

Deprecated: Automatic conversion of false to array is deprecated in ... wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module on line 141

Horst, thanks for the report. Ryan, those two are already reported in #1467 (comment)

@kixe
Copy link

kixe commented Feb 25, 2022

@horst-n
Could this be merged in #1467 and closed?

ryancramerdesign added a commit to processwire/processwire that referenced this issue Feb 25, 2022
@ryancramerdesign
Copy link
Member

@horst-n Thanks, I've pushed a fix for these and have also updated the matrix & combo modules, so those will appear in the next versions of those as well.

@horst-n
Copy link
Author

horst-n commented Feb 25, 2022

Thanks @ryancramerdesign !

@horst-n horst-n closed this as completed Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants