[wp-trac] [WordPress Trac] #54836: Huge error logs filled with "WordPress database error Illegal mix of collations" errors caused by spammers
WordPress Trac
noreply at wordpress.org
Fri Feb 28 12:28:31 UTC 2025
#54836: Huge error logs filled with "WordPress database error Illegal mix of
collations" errors caused by spammers
--------------------------+------------------------------
Reporter: jh20001 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version:
Severity: critical | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by podpirate):
@drzraf Actually with `parse_query` there is such a filter.
I've been struggling with the same issue. The following code (in a mu-
plugin) fixed it for me:
{{{#!php
<?php
add_action('parse_query', function($wp_query) {
if ( $wp_query->is_search ) {
$s = $wp_query->get('s');
// @see https://stackoverflow.com/a/77150421/1983694
$s = preg_replace_callback(
'/./u',
function (array $match) {
return strlen($match[0]) >= 4 ? '' :
$match[0];
},
$s
);
$wp_query->set('s', $s);
}
});
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54836#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list