Open andrewwerth opened 5 months ago
Same warnings with WP 6.5.4 and Pods 3.2.2 in a WooCommerce where I added to product content type some fields. If I am admin user, I don't get the error, but if I am another user or I am not logged, then I get this error in the description field that is not created by pods.
If in line 723, I add the condition that code is not empty, then the problem is gone
if(!empty($code)){
preg_match_all( '/('
. '\[' . preg_quote( $command, '/' ) . '\s*'
. '(?<field_attr>field="(?<field>[^"]*)")*' . '\s*'
. '(?<value_attr>value="(?<value>[^"]*)")*' . '\s*'
. '(?<compare_attr>compare="(?<compare>[^"]*)")*' . '\s*'
. '(?<other_attributes>[^\]]*)'
. ']|\[\/' . preg_quote( $command, '/' ) . '\]'
. ')/m', $code, $matches );
}
The same to line 828
if(!empty($code)){
$code = str_replace( '{@pod}', $pod->pod, $code );
$code = str_replace( '{@EntryID}', '{@' . $pod->pod_data['field_id'] . '}', $code );
}
Thanks a lot for the plugin
Description
On a single item custom post page, using pods shortcode [pods field="fieldname"] produces a warning in debug mode:
Deprecated: preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated in /var/www/html/wp-content/plugins/pods/components/Templates/includes/functions-view_template.php on line 723
Version
3.0.10
Testing Instructions
I don't have a way to provide step-by-step instructions to repeat this error. I have a page for displaying items of a custom post type created with Pods and there's a Template for that Single Item: PostTypeName. Within the template, there are two paragraph fields that use shortcodes to pull fields from the DB:
[pods field="fieldname1"] [pods field="fieldname2"] ...etc...
The information is displayed properly on the website, but with debug mode turned on the error messages appear. (Also note that in addition to the preg_match_all() deprecation message, there's also one for str_replace() on line 828 of functions-view_template.php, as shown in the screenshot.
Screenshots / Screencast
Possible Workaround
No response
Site Health Information
Pods Package
No response