Opened 18 months ago
Last modified 12 days ago
#58476 new defect (bug)
preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated
Reported by: | KProvance | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.3 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
Bug Report
Description
Using the filter hook 'the_content' and passing an empty string or null produces the preg_split deprecation notice in the convert_smilies() function.
Environment
- WordPress: 6.3-alpha-55892
- PHP: 8.2.2
- Server: Apache/2.4.54 (Win64) PHP/8.2.2 mod_fcgid/2.3.10-dev
- Database: mysqli (Server: 8.0.27 / Client: mysqlnd 8.2.2)
- Browser: Chrome 114.0.0.0 (Windows 10/11)
- Theme: Seele 1.1.1
- MU-Plugins:
- WP Migrate DB Pro Compatibility 1.1
- Plugins:
- bbPress 2.6.9
- Classic Widgets 0.3
- Contact Form 7 5.7.7
- Database Backup for WordPress 2.5.2
- Envato Market 2.0.8
- Force Plugin Updates Check 1.0.2
- Optimize Database after Deleting Revisions 5.0.110
- Query Monitor 3.12.3
- Redux Framework 4.4.1.4
- Regenerate Thumbnails 3.1.5
- Requite Core 1.1.13
- Slider Revolution 6.6.14
- Slider Revolution Paint-Brush Add-On 3.0.4
- Slider Revolution Particles Effect 3.3.2
- Slider Revolution Slicey Add-On 3.0.4
- Theme Check 20230417
- Ultimate Addons for WPBakery Page Builder 3.19.14
- WooCommerce 7.7.2
- WordPress Beta Tester 3.4.1
- WordPress Importer 0.8.1
- WPBakery Page Builder 6.13.0
- WP Crontrol 1.15.2
- WP Migrate DB Pro 1.8.1
- WP Migrate DB Pro CLI 1.3.2
- WP Migrate DB Pro Media Files 1.4.9
- WP Migrate DB Pro Multisite Tools 1.2
Steps to Reproduce
- Use this filter, ensuring $content is empty or null: $content = apply_filters( 'the_content', $content );
preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated
wp-includes/formatting.php:3482
preg_split()
wp-includes/formatting.php:3482
convert_smilies()
wp-includes/class-wp-hook.php:310
apply_filters('the_content')
- 🐞 Bug occurs.
Expected Results
- ✅ The filtered content.
Actual Results
- ❌ The indicated deprecation error due to preg_split not liking a null value.
Attachments (1)
Change History (6)
#1
@
17 months ago
Is it ok to exclude calls that previously did pass?
If not, how about turning $text to empty string as
$text = empty ( $text ) ? '' : $text;
#2
follow-up:
↓ 3
@
13 months ago
Duplicate of #58275.
This needs a backtrace to see where the error originates from.
The convert_smilies()
function is clearly marked as only accepting string
values for $text
.
The current proposed patch would widen the parameter type to ?string
and hide the error instead of fixing it.
This should be fixed in the location where null
is being passed to convert_smilies()
instead.
#3
in reply to:
↑ 2
@
13 months ago
Using the filter hook 'the_content' and passing an empty string or null produces the preg_split deprecation notice in the convert_smilies() function.
I thought I made this clear with that statement. Pass an empty string or null to a 'the_content' filter. In turn, this passes the null/empty string to the convert_smiles()
function and, in turn, the error. How does one fix a null or blank string passed to the 'the_content' filter past not doing it? Sometimes, there is no content. @mecano had the correct solution.
#4
@
12 months ago
I have a similar issue on the page https://paasp.net
the deprecated error message appears and it also refers to the convert_smilies function in the formatting.php.
It looks to me like it is connected to WPBakery Page Builder. At least, I do not get this message when deactivating this plugin.
It looks like KProance has also installed this.
Is there a solution?
I added a checking in if condition