From 1854a7c965401089842c486dcba4e0e0462e917f Mon Sep 17 00:00:00 2001 From: Stuart Langridge Date: Tue, 14 Feb 2023 23:49:34 +0000 Subject: [PATCH] Make is_text_col's search case-insensitive for sqlite support When using wp-sqlite-db as the back end for WordPress, wpcli's `search-replace` command fails because wp-sqlite-db returns text column types as `TEXT`, and wpcli search-replace checks whether a column is textual in `is_text_col` with `strpos` for "text" or "varchar". If this were `stripos` instead of `strpos` then this problem would be resolved, which would be nice, and I don't believe there would be any backward compatibility implications. So, here's a one-character PR :-) (Of course, sqlite as backend isn't actually supported, but this is a fairly small change which should make things better for that without affecting the mainline code. I've also proposed https://github.com/aaemnnosttv/wp-sqlite-db/pull/56 to wp-sqlite-db to have that return lowercase "text" for column types as well, thus hopefully fixing the problem at both ends.) --- src/Search_Replace_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Search_Replace_Command.php b/src/Search_Replace_Command.php index 689d5522..75397d50 100644 --- a/src/Search_Replace_Command.php +++ b/src/Search_Replace_Command.php @@ -712,7 +712,7 @@ private static function get_columns( $table ) { private static function is_text_col( $type ) { foreach ( array( 'text', 'varchar' ) as $token ) { - if ( false !== strpos( $type, $token ) ) { + if ( false !== stripos( $type, $token ) ) { return true; } }