[Beta] Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated #1037

Open
opened 2024-01-26 15:01:54 +00:00 by Sven Lewerentz · 5 comments

Steps to reproduce the issue

  • Create a component that contains a text field, which ist listed in an admin list view. The text field should not have a character limit or a limit >50 characters
  • enter a value that contains more than 50 characters in the text field
  • save and close to get back to the list view

Expected result

  • Value of text field is shown in list view (I guess it is intended that the value is shortened to 50 characters)

Actual result

  • Deprecated message: Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated

System information (as much as possible)

  • OS Name & Version: Ubuntu running in WSL / Windows 11
  • MySql Version: 8.1.27
  • Apache Version: 2.4.52 (Ubuntu)
  • PHP Version: 8.1.27
  • Joomla Version: 5.0.2
  • JCB Version: 3.1.35 (Beta)
  • Browser: Chrome

Additional comments

### Steps to reproduce the issue - Create a component that contains a text field, which ist listed in an admin list view. The text field should not have a character limit or a limit >50 characters - enter a value that contains more than 50 characters in the text field - save and close to get back to the list view ### Expected result - Value of text field is shown in list view (I guess it is intended that the value is shortened to 50 characters) ### Actual result - Deprecated message: Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated ### System information (as much as possible) - OS Name & Version: Ubuntu running in WSL / Windows 11 - MySql Version: 8.1.27 - Apache Version: 2.4.52 (Ubuntu) - PHP Version: 8.1.27 - Joomla Version: 5.0.2 - JCB Version: 3.1.35 (Beta) - Browser: Chrome ### Additional comments
Owner

I thought I fixed this already... I will take another look. Thanks!

I thought I fixed this already... I will take another look. Thanks!
Owner

Okay lets see... the method being called here is the shorten method from the StringHelper class, found here:

Can you check if your string helper class is in sync? not only in your file system but also in the powers database area? Since I found if you compile a Joomla 3 component and install it will build the string helper class from what you have in your database and overwrite the string helper class (on installing this component locally)... not sure if this quarks is ideal, and I am trying to resolve it.

But this is what I think is happening.

How to update the StringHelper class in your install (DB) of JCB... select the class in the list view and at the top click '[Reset]` this will sync your version of the StringHelper class (in your database) with the current up-to-date version from the global repository.

I updated this global repository with all the changes we made. This global repo will normally stay in step with all the changes we make. This global repos is the place from which JCB will fetch all the classes and code it needs when it builds features for your component that was not shipped with the ZIP package.

Long story short.. you can clone this repos and point your instance of JCB at your own version... which will allow an override effect (but that is a topic for another day).

After all that... this is the fix:

$words = preg_split('/([\s\n\r]+)/', (string) $string, -1, PREG_SPLIT_DELIM_CAPTURE);

It use to be the following (which has the null):

$words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE);

Please check if it resolves your issue.

Okay lets see... the method being called here is the shorten method from the StringHelper class, found here: - https://git.vdm.dev/joomla/super-powers/src/branch/master/src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/code.php#L59 Can you check if your string helper class is in sync? not only in your **file system** but also in the **powers database area**? Since I found if you compile a Joomla 3 component and install it will build the string helper class from what you have in your *database* and overwrite the string helper class (on installing this component locally)... not sure if this *quarks* is ideal, and I am trying to resolve it. > But this is what I think is happening. How to update the StringHelper class in your install (DB) of JCB... select the class in the list view and at the top click '[Reset]` this will sync your version of the StringHelper class (in your database) with the current up-to-date [version from the global repository](https://git.vdm.dev/joomla/super-powers/src/branch/master/src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef). I updated this global repository with all the changes we made. This [global repo](https://git.vdm.dev/joomla/super-powers/src/branch/master) will normally stay in step with all the changes we make. This global repos is the place from which JCB will fetch all the classes and code it needs when it builds features for your component that was not shipped with the ZIP package. Long story short.. you can clone this repos and point your instance of JCB at your own version... which will allow an override effect (but that is a topic for another day). After all that... this is the fix: ``` $words = preg_split('/([\s\n\r]+)/', (string) $string, -1, PREG_SPLIT_DELIM_CAPTURE); ``` It use to be the following (which has the null): ``` $words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE); ``` Please check if it resolves your issue.
Llewellyn added the
Beta
label 2024-01-27 07:31:51 +00:00
Author

I don't know, if I got everything right.

I did the following:

  • I reseted the powers "StringHelper" (I have it twice in my list view, is this correct?)
  • I compiled a new version of my component
  • I deinstalled the previous version of my component and installed the new one.

The code in /libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php is the following:

$words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE);

I still get the depreated message.

I don't know, if I got everything right. I did the following: - I reseted the powers "StringHelper" (I have it twice in my list view, is this correct?) - I compiled a new version of my component - I deinstalled the previous version of my component and installed the new one. The code in /libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php is the following: `$words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE);` I still get the depreated message.
Owner

I reseted the powers "StringHelper" (I have it twice in my list view, is this correct?)

Nope this should not happen... please delete one.

Change the code:

$words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE);

TO THIS CODE:

$words = preg_split('/([\s\n\r]+)/', (string) $string, -1, PREG_SPLIT_DELIM_CAPTURE);

Note the -1 value it must not be null...

You must change the code in the database, and in the local file found at:

/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php
> I reseted the powers "StringHelper" (I have it twice in my list view, is this correct?) Nope this should not happen... please delete one. Change the code: ``` $words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE); ``` TO THIS CODE: ``` $words = preg_split('/([\s\n\r]+)/', (string) $string, -1, PREG_SPLIT_DELIM_CAPTURE); ``` Note the `-1` value it must not be null... You must change the code in the database, and in the local file found at: ``` /libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php ```
Author

Ok, now it works. Thanks.

Ok, now it works. Thanks.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1037
No description provided.