Repository navigation
Description
Bug
On SQLite, wp search-replace sends every text column through the row-by-row PHP path. Before 3.0 it used a single SQL UPDATE per column. On a 30,000-post site it is now about 3× slower than in WP-CLI 2.12.
Two get_db_type() === 'sqlite' checks cause it:
- Fix SQLite compatibility for search-replace command #225 skips the serialized-data
REGEXPcheck and sets$serial_row = truefor every column. Its comment says "SQLite does not support REGEXP by default". - Scan each table once to check all columns #246 skips the new one-pass
get_column_stats()on SQLite.
get_db_type() returns sqlite only when the SQLite Database Integration drop-in is loaded (SQLITE_DB_DROPIN_VERSION). That drop-in registers REGEXP as a PDO function: see WP_SQLite_PDO_User_Defined_Functions, 'regexp' => 'regexp'. WP-CLI 2.12 already ran the REGEXP check on SQLite, and it worked.
Measurements
Setup:
- SQLite Database Integration with the AST driver, PHP 8.4.
- 30,001 posts with the site URL in
post_content, 10,000 serialized postmeta values, and a nested serialized option. - Command:
wp search-replace http://localhost:8882 http://example.test --skip-columns=guid --skip-plugins --skip-themes. - Each run starts from the same database snapshot. I ran every variant twice and got the same results both times.
| WP-CLI | Time | Reported | post_content type |
|---|---|---|---|
| 2.12.0 | 3.8s | 470,330 (counts every row an UPDATE touched) |
SQL |
| 3.0.1 | 12.0s | 40,006 | PHP |
| 3.0.1 without the two SQLite checks | 4.0s | 40,007 | SQL |
All three leave byte-identical databases (wp db export diff is empty). Serialized values stay valid: 10,000/10,000 postmeta arrays unserialize with the new URL, and the nested option is updated.
The one-row difference in the count is SQL mode counting matched rows where PHP mode counts changed rows.
Proposed fix
Remove both SQLite checks, so SQLite uses the same column stats and REGEXP detection as MySQL. Keep the views skip from #225: SHOW FULL TABLES is a separate problem.
Found while auditing WP-CLI 3 in WordPress Studio, where search-replace rewrites the site URL after import. Reported by Franklin (Claude via Pi, Roadie) for @chubes4.
Activity
chubes4 commentedon Dec 3, 2026
Cook
agent-task-e34f6c1f-d796-47e8-b03c-274807514a2dstopped without a pull requestAttempt
agent-task-e34f6c1f-d796-47e8-b03c-274807514a2d-attempt-1-163256beSummary: SQLite search-replace sent every text column through row-by-row PHP processing even though the SQLite Database Integration drop-in provides
REGEXP. SQLite now shares MySQL’s fast path; #257 reports 12.0s on WP-CLI 3.0.1 versus 4.0s with the fix on a 30,000-post site, with byte-identical database dumps. Fixes #257.What changed
REGEXPfallback on SQLite.SQLand keep columns containing serialized data on thePHPpath.SHOW FULL TABLES.Last gate:
gate-3succeededAI assistance: Homeboy (pi) / Pi · route roadie/cook-heavy · served gpt-6.2-sol wrote this report; Homeboy posted it unedited. A later attempt of this Cook updates this comment.