Passing null to ltrim deprecated

Getting Error “Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated”

Expected behavior

This is a deprecation error and not really major.

Current behavior

Gett error only with Debug on!

Possible solution

Add $query = ''; to line 2925 or wp-includes/wp-db.php

Steps to reproduce

With WPDEBUG set to true

  1. was troubleshooting a cookie issue
  2. turned on WPDEBUG manually in wp-config.php
  3. error appears
  4. did not test if error appears AFTER I deleted site cookies (my original reason for turning on debug)


Was troubleshooting wp-login issue?
In the real world debug would be set to false so this may not effect anyone but developers.


Set query string as empty before the ltrim is asked for to avoid passing null
In wp-db.php I added $query = ''; on line 2925 which is the first BLANK line before the collation query.

Seems you are using PHP > 8.0. Which ClassicPress version?
A lot of deprecations are in place.

With ClassicPress v. 2 PHP 8.2 is working fine, but many plugins are still not supporting PHP > 8.0.

1 Like

PHP Version 8.1.17

Version 1.5.3
file affected: wp-includes/wp-db.php

Version 1.5 supports PHP 8.0. That’s not the only deprecation you’ll find.
However deprecations will not create troubles unless you are logging them and fill your log file.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.