serendipity_event_contactform: php 8.1 issues
On the page for the contact form I get some notices
Notice: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in ./plugins/serendipity_event_contactform/serendipity_event_contactform.php on line 447.
'commentform_name' => (function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($serendipity['POST']['name'])) : htmlspecialchars(strip_tags($serendipity['POST']['name']), ENT_COMPAT, LANG_CHARSET)),
The same notice is for line 448 to 450
Modified code for line 447
'commentform_name' => (function_exists('serendipity_specialchars')
? serendipity_specialchars(strip_tags(isset($serendipity['POST']['name']) && is_string($serendipity['POST']['name']) ? $serendipity['POST']['name'] : ''))
: htmlspecialchars(strip_tags(isset($serendipity['POST']['name']) && is_string($serendipity['POST']['name']) ? $serendipity['POST']['name'] : ''), ENT_COMPAT, LANG_CHARSET)),
Easiest would be to use:
strip_tags($variable ?? '')
Easiest would be to use:
strip_tags($variable ?? '')
Tried it and seems to work for me. Thanks!
Another notice in backend:
preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in ./plugins/serendipity_event_contactform/serendipity_event_contactform.php on line 479.
471 function selected() {
472 global $serendipity;
473
474 if (!empty($serendipity['POST']['subpage'])) {
475 $serendipity['GET']['subpage'] = $serendipity['POST']['subpage'];
476 }
477
478 if ($serendipity['GET']['subpage'] == $this->get_config('pagetitle') ||
479 preg_match('@^' . preg_quote($this->get_config('permalink')) . '@i', $serendipity['GET']['subpage'])) {
480 return true;
481 }
482
483 return false;
484 }
Should be fixable with:
preg_match('@^' . preg_quote($this->get_config('permalink')) . '@i', $serendipity['GET']['subpage'] ?? '')) {
Should be fixed when https://github.com/s9y/additional_plugins/pull/196 gets merged.
Which was merged now