Found it.
First of all, I was searching for the wrong line of code, wpdb::escape.
The string to look for is $wpdb->escape.
It is a little bit everywhere, mainly plugins.
In my case, it was in the file sunrise.php. In fact, commenting the following line in wp-config.php, makes the error disappear.
// define('SUNRISE', 'on');
However, I suppose that the solution is to fix the file sunrise.php itself.
Unfortunately, esc_sql() can’t be used, since apparently sunrise.php is been included before the function esc_sql() is even registered.
So, I looked up into esc_sql().
function esc_sql( $data ) {
global $wpdb;
return $wpdb->_escape( $data );
}
Therefore, in sunrise.php, I commented the original line that causes the trouble, and duplicated it right below, modifying it as such:
// $dm_domain = $wpdb->escape( $_SERVER[ 'HTTP_HOST' ] );
$dm_domain = $wpdb->_escape( $_SERVER[ 'HTTP_HOST' ] );
So far, so good. Hopefully this will help others somehow.