Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serendipity_event_contactform: php 8.1 issues #861

Open
bauigel opened this issue Jan 19, 2025 · 4 comments
Open

serendipity_event_contactform: php 8.1 issues #861

bauigel opened this issue Jan 19, 2025 · 4 comments

Comments

@bauigel
Copy link

bauigel commented Jan 19, 2025

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 bauigel changed the title serendipity_event_contactform serendipity_event_contactform: notices for strip_tags() Jan 19, 2025
@garvinhicking
Copy link
Member

Easiest would be to use:

strip_tags($variable ?? '')

@bauigel
Copy link
Author

bauigel commented Jan 19, 2025

Easiest would be to use:

strip_tags($variable ?? '')

Tried it and seems to work for me. Thanks!

@bauigel bauigel changed the title serendipity_event_contactform: notices for strip_tags() serendipity_event_contactform: php 8.1 issues Jan 25, 2025
@bauigel
Copy link
Author

bauigel commented Jan 25, 2025

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     }

@garvinhicking
Copy link
Member

Should be fixable with:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants