HyperDB icon indicating copy to clipboard operation
HyperDB copied to clipboard

db.php deprecated use of function

Open Zachify opened this issue 3 years ago • 2 comments

There is a use of stripos() in db.php which can lead to an error:

Line 439 of db.php:

if ( false !== stripos( $query_match, $key ) ) {

As of PHP 7.3, the second parameter of stripos() cannot be an integer. I have had success overcoming this by casting the parameter as a string:

if ( false !== stripos( $query_match, (String)$key ) ) {

Zachify avatar Sep 19 '22 20:09 Zachify

It would be nice to know what query lead to triggering this.. as technically, this should not really be possible (although a similar notice would be)

$key should be a table name, which is inherently a string, but it's likely false in this case as $this->get_table_from_query( $query ) probably failed..

That doesn't explain why it's an integer, rather than a boolean though..

Some code doing something like $wpdb->srtm[] = true would trigger your error though.

dd32 avatar Oct 06 '22 06:10 dd32

Unfortunately I cannot find the full query, just this snippet from my server's error log: stripos('SELECT * FROM w...', 0)

This is The Events Calendar plugin's migration process that triggers this error, causing the migration to halt indefinitely.

In a site without the HyperDB plugin, this migration performs as expected.

Zachify avatar Oct 06 '22 18:10 Zachify