Skip to content

Commit

Permalink
Merge pull request #22 from sprucely-designed/master
Browse files Browse the repository at this point in the history
Prevent strpos(): Passing null to parameter #1 error
  • Loading branch information
BrianHenryIE committed Mar 20, 2024
2 parents 3e9dbe0 + faabf98 commit c20de43
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/wp-includes/class-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public function process( $user_id ) {
}

// Check for bots.
$user_agent = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT' );
// Use the null coalescing operator to ensure $user_agent is always a string.
// This prevents passing null to strpos, which is deprecated in newer PHP versions.
$user_agent = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT' ) ?? '';
$bot = false !== strpos( $user_agent, 'bot' );
if ( $bot ) {
return $user_id;
Expand Down

0 comments on commit c20de43

Please sign in to comment.