Regarding the deprecation ‘preg_match(): Passing null to parameter…’
-
Thank you for a nice plugin.
The following deprecations are reported in the PHP8.2 and WordPress6.5.5 environment:
PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /.../wp-content/plugins/infinite-scroll-block/build/infinite-scroll/render.php on line 6
The relevant code is below
$next_page_content = '';
$next_page_content = render_block_core_query_pagination_next($attributes, $next_page_content, $block);
$link = preg_match('/href="([^"]*)"/', $next_page_content, $matches) ? $matches[1] : '';This seems to be because the $next_page_content passed to the second argument of the preg_match() function is null, not a string. The message disappeared when I corrected it as follows.
$next_page_content = '';
$next_page_content = render_block_core_query_pagination_next($attributes, $next_page_content, $block);
if ($next_page_content) {
$link = preg_match('/href="([^"]*)"/', $next_page_content, $matches) ? $matches[1] : '';
} else {
$link = '';
}This is merely an improvement made in my environment, and it appears to work fine, but I would appreciate it if you could verify the code and make it available in the next version.
- You must be logged in to reply to this topic.