mrwweb / enhanced-embed-block

Enhance the default YouTube Embed Block in WordPress to load faster.
GNU General Public License v3.0
4 stars 1 forks source link

WP Rest API "posts" endpoint shows deprecated messages while WP_DEBUG True #13

Open jeflopodev opened 2 days ago

jeflopodev commented 2 days ago

I was trying to use WP with AstroJs using the Rest API posts endpoint http://<domain>/wp-json/wp/v2/posts

Since I had define( 'WP_DEBUG', true );

I'm getting this as part of the output:

<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
<br />
<b>Deprecated</b>:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in <b>C:\laragon\www\latest\wp-content\plugins\enhanced-embed-block-main\enhanced-embed-block.php</b> on line <b>178</b><br />
...

Seems that the first parameter has a null value and parse_str() doesn't like that since it expects a string, or maybe there's no result and since it's mandatory as of php 8.0.0 it fails, or both I don't know 😅

Just sharing, in case you find it useful in any way.

mrwweb commented 2 days ago

Thanks for the report, @jeflopodev. I can see why this would end up happening. In fact, I'm a little surprised I didn't catch this one myself. I'll try to get an update out sooner than later.

This is untested, but if you need an immediate fix, I suspect you can replace line 178 with:

if( $params ) {
    parse_str( $params, $query );
}