Skip to content

SQL Replacements need to use DB_PREFIX when building the regex replacements #143

@mattbucci

Description

@mattbucci

WP Version: 6.7
PG4WP Version: Latest
PHP Version: 8.4

Error:

WordPress database error: [ERROR: syntax error at or near "a" LINE 1: DELETE a, b FROM gwp_options a, gwp_options b ^]
DELETE a, b FROM gwp_options a, gwp_options b WHERE a.option_name LIKE '_transient_%' AND a.option_name NOT LIKE '_transient_timeout_%' AND b.option_name = CONCAT( 'transient_timeout', SUBSTRING( a.option_name, 12 ) ) AND b.option_value < 1739820273

RAW SQL

DELETE a, b FROM gwp_options a, gwp_options b WHERE a.option_name LIKE '_site_transient_%' AND a.option_name NOT LIKE '_site_transient_timeout_%' AND b.option_name = CONCAT( 'site_transient_timeout', SUBSTRING( a.option_name, 17 ) ) AND b.option_value < 1739820273

Expected Rewritten SQL

DELETE FROM gwp_options a
USING gwp_options b
WHERE a.option_name LIKE '_site_transient_%'
  AND a.option_name NOT LIKE '_site_transient_timeout_%'
  AND b.option_name = CONCAT('site_transient_timeout', SUBSTRING(a.option_name, 17))
  AND b.option_value < 1739820273;

Actual Rewritten SQL

DELETE a, b FROM gwp_options a, gwp_options b WHERE a.option_name LIKE '_site_transient_%' AND a.option_name NOT LIKE '_site_transient_timeout_%' AND b.option_name = CONCAT( 'site_transient_timeout', SUBSTRING( a.option_name, 17 ) ) AND b.option_value < 1739820273

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions