Forums

php strpos(): Deprecated. error_log is huge -> FIX for content plugin

zest96 05 Nov, 2024

chronoforms Version 8.0.23

PHP 8.2

I got this error which filled a nice 1gb error log over few months.

PHP Deprecated:  strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /public_html/plugins/content/chronoforms8/chronoforms8.php on line 22

here is the fix to the core file listed here above ⇧ and one more error coming right after, due to lack of checks of article text and in cases of loading the form in using the plugin {chronoforms 8}formName{/chronoforms8}

search these lines:

        // Simple performance check to determine whether bot should process further
        if (strpos($article->text, '{chronoforms8}') === false) {
            return;
        }
		
		preg_match_all('#{chronoforms8}(.*?){/chronoforms8}#s', $article->text, $matches);
		

replace with this

 // Simple performance check to determine whether bot should process further
// php 8.2 deprecated fixes

if (isset($article->text) && is_string($article->text) && strpos($article->text, '{chronoforms8}') === false) {
    return;
}
		
if (!empty($article->text) && is_string($article->text)) {
    preg_match_all('#{chronoforms8}(.*?){/chronoforms8}#s', $article->text, $matches);
}

Max_admin 06 Nov, 2024
Answer
1 Likes

Thank you for the fix, I have updated the download!

You can replace the first check with:

// Simple performance check to determine whether bot should process further
		if(empty($article->text)){
			return;
		}
		if (strpos($article->text, '{chronoforms8}') === false) {
			return;
		}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
zest96 06 Nov, 2024

clean! thanks

You need to login to be able to post a reply.