Originally reported on mediawiki.org with this topic.
It appears that CAST AS INTEGER is not supported by MySQL 5.6 and 5.7 introduced with bcd6b2f732824d26a55ff3892442e143df7994a6
As a fix it is suggested to replace CAST(SUBSTRING(content_address, 4) AS INTEGER) = old_id' with 'CAST(SUBSTRING(content_address, 4) AS SIGNED) = old_id' in "/ReplaceTextSearch.php"