Joomla4 + 2.7.2+build.2022.05.09.18.01.50.cff9cffac + PHP8.1 Deprecated: str_rep

1 year 11 months ago #329460 by djanubis
Hi,
Using config as in title on a development site, I get frequent messages like:
"( ! ) Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/html/J41/components/com_comprofiler/plugin/user/plug_cbprivacy/library/Trigger/FieldTrigger.php on line 295"

PHP8.1 has deprecated using null as an empty string in parameters. So, all calls to php_replace within CB code should be like
str_replace( '[field_id]', $fieldId, $field->params->get( 'cbprivacy_asset', '', GetterInterface::STRING ) )
instead current code
str_replace( '[field_id]', $fieldId, $field->params->get( 'cbprivacy_asset', null, GetterInterface::STRING ) )
As GetterInterface is STRING, passing an empty string as parameter fixes this deprecated warning.

Is this a real solution or is there another way ?

Thank you in advance for your answer.

Please Log in to join the conversation.

1 year 11 months ago - 1 year 11 months ago #329465 by krileon
This is now fixed in latest build release of CB Privacy. Have made all strings strict return a string.

forge.joomlapolis.com/issues/8950

Please let us know if you see any others. Also keep in mind these are just deprecations. We have PHP 8.1 compatibility, but if you've full error reporting and debug mode on you'll see those deprecations which won't hurt anything for the time being. Please also keep in mind Joomla itself is still working on clearing 8.1 deprecation notices as well. You can track Joomla progress below.

github.com/joomla/joomla-cms/issues/34952

github.com/joomla/joomla-cms/pulls?q=is%3Apr+is%3Aopen+label%3A%22PHP+8.x%22


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.354 seconds

Facebook Twitter LinkedIn