Skip to Content Skip to Menu

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

  • djanubis
  • djanubis
  • ONLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
2 years 6 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
Code:
str_replace( '[field_id]', $fieldId, $field->params->get( 'cbprivacy_asset', '', GetterInterface::STRING ) )
instead current code
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 or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 6 months ago - 2 years 6 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.
Last edit: 2 years 6 months ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum