Skip to main content
Bad behavior errors on PHP 8.1 & 8.2 Started by radu81 · · Read 5322 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

Bad behavior errors on PHP 8.1 & 8.2

Using PHP 8.1 I see this error in Elkarte log:
  • Type of error: General
  • Unknown Error: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
  • File: /sources/ext/bad-behavior/bad-behavior/blacklist.inc.php
    Line: 170

    Code: [Select]
    164: 	// Do not edit below this line.
    165:
    166: @$ua = $package['headers_mixed']['User-Agent'];
    167: @$uri = $package['request_uri'];
    168:
    169: foreach ($bb2_spambots_0 as $spambot) {
    170: $pos = strpos($ua, $spambot);
    171: if ($pos !== FALSE && $pos == 0) {
    172: return "17f4e8c8";
    173: }
    174: }


Using PHP 8.2 I get this error:
Immagine 2023-03-17 161552.png
sorry for my bad english

Re: Bad behavior errors on PHP 8.1 & 8.2

Reply #1

All part of the reason I dropped this feature in 2.0 and added our own smaller set of checks that BB did perform.  BB has not been updated in some time, and the licensing is a bit persnickety which is why I don't patch it myself.

Anyway, at line 168 add $ua = $ua ?? ''; and see if that clears the log.

Re: Bad behavior errors on PHP 8.1 & 8.2

Reply #2

Ok, thanks again, just did that edit, let you know in the next days if it helped.
sorry for my bad english