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

PagePaths module PHP 8 deprecation warning #1652

Closed
gebeer opened this issue Dec 5, 2022 · 2 comments
Closed

PagePaths module PHP 8 deprecation warning #1652

gebeer opened this issue Dec 5, 2022 · 2 comments

Comments

@gebeer
Copy link

gebeer commented Dec 5, 2022

Short description of the issue

Deprecation warning with PHP 8.1:
PHP Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in
https://github.com/processwire/processwire/blob/a3cc73bd87c3fed53a2afd52f36acd568df588ff/wire/modules/PagePaths.module#L638

Expected behavior

No warnings

Actual behavior

Warnings

Steps to reproduce the issue

install PagePaths module on PHP >= 8

Setup/Environment

  • ProcessWire version: 3.0.200 and latest dev
  • (Optional) PHP version: 8.1
@gebeer
Copy link
Author

gebeer commented Dec 6, 2022

@ryancramerdesign
Supposed Fix for https://github.com/processwire/processwire/blob/a3cc73bd87c3fed53a2afd52f36acd568df588ff/wire/modules/PagePaths.module#L638

if(!strlen((string) $name)) continue;

Working for me.
Since $query->fetch() returns NULL for empty name fields, it should be fine to cast that to an empty string. But maybe it would be more efficient to do this on the query level?

Inserting this after l 616 also solves the problem for me:

		$database->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_TO_STRING);

See https://www.php.net/manual/en/pdo.setattribute.php

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

Thanks @gebeer I've pushed a fix for this issue.

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

2 participants