Serendipity icon indicating copy to clipboard operation
Serendipity copied to clipboard

serendipity_event_contactform: php 8.1 issues

Open bauigel opened this issue 1 year ago • 5 comments

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)),

bauigel avatar Jan 19 '25 10:01 bauigel

Easiest would be to use:

strip_tags($variable ?? '')

garvinhicking avatar Jan 19 '25 11:01 garvinhicking

Easiest would be to use:

strip_tags($variable ?? '')

Tried it and seems to work for me. Thanks!

bauigel avatar Jan 19 '25 12:01 bauigel

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     }

bauigel avatar Jan 25 '25 19:01 bauigel

Should be fixable with:

preg_match('@^' . preg_quote($this->get_config('permalink')) . '@i', $serendipity['GET']['subpage'] ?? '')) {

garvinhicking avatar Jan 25 '25 20:01 garvinhicking

Should be fixed when https://github.com/s9y/additional_plugins/pull/196 gets merged.

onli avatar Jun 24 '25 18:06 onli

Which was merged now

onli avatar Jun 30 '25 12:06 onli