SQL error when cleaning up options via cron job
-
The cron job or WordPress triggers a cleanup process of maspik plugin once a day. Within the file contact-forms-anti-spam/includes/includes/functions.php there is a function named “maspik_clean_expired_ip_check_transients”
The errornous SQL is:
$wpdb->query(“DELETE FROM {$wpdb->options} WHERE option_name LIKE ‘transient_maspik_ip_check%’ AND option_name NOT IN (SELECT CONCAT(‘transient‘, SUBSTRING(option_name, 20)) FROM {$wpdb->options} WHERE option_name LIKE ‘transient_timeout_maspik_ip_check%’)”);
This creates the following error message:
Output: WordPress database error You can’t specify target table ‘wp_options’ for update in FROM clause for query
MySQL doesn’t allow to deleting from a table when the subselect is using the same table.
See also: https://dev.mysql.com/doc/refman/8.4/en/update.html
- You must be logged in to reply to this topic.