From 60d1e87a8c335272772e68dd56c3e3046c2b983c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gayot?= Date: Sun, 22 Mar 2026 19:02:03 +0100 Subject: [PATCH] :bug: Reset first_select flag between tables in CLI mode Table::$first_select was not reset in get_structure_info() when processing a new table. In CLI mode (single PHP process), the flag carried over from the previous table, causing the first SELECT query to include a stale WHERE primary_key > '0' clause. This had no visible effect on tables with integer primary keys (e.g. wp_posts.ID) since ID > '0' evaluates to ID > 0 which is always true for auto-increment values. However, WordPress 6.4 changed wp_options PRIMARY KEY from option_id (bigint) to option_name (varchar). With utf8mb4_unicode_520_ci collation, underscore '_' sorts before '0', so the clause option_name > '0' silently excluded all '_'-prefixed options (_options_*, _site_transient_*, _squidge_*, etc.). This broke ACF get_field() for options pages after a CLI export/pull, because ACF reference entries (e.g. _options_cookies_categories) were missing from the exported dump. The fix resets $this->first_select = null alongside the existing $this->primary_keys reset in get_structure_info(), ensuring each table's first query starts without a compound key WHERE clause. --- class/Common/Sql/Table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/class/Common/Sql/Table.php b/class/Common/Sql/Table.php index 11a85863..c2185cda 100644 --- a/class/Common/Sql/Table.php +++ b/class/Common/Sql/Table.php @@ -673,6 +673,7 @@ public function get_structure_info( $table, $table_structure = array(), $state_d $points = array(); $field_set = array(); $this->primary_keys = array(); + $this->first_select = null; $use_primary_keys = true; foreach ( $table_structure as $struct ) {