Skip to content

A platform for community discussion. Free, open, simple.

FIX: Bookmarkable query placholders (#35935)

Martin Brennanddd4f2e64d13
diff --git a/app/services/registered_bookmarkable.rb b/app/services/registered_bookmarkable.rb
index 3591e784464..f09c2be1796 100644
--- a/app/services/registered_bookmarkable.rb
+++ b/app/services/registered_bookmarkable.rb
@@ -41,7 +41,9 @@ class RegisteredBookmarkable
# See BaseBookmarkable#search_query for argument docs.
def perform_search_query(bookmarks, query, ts_query)
bookmarkable_klass.search_query(bookmarks, query, ts_query) do |bookmarks_joined, where_sql|
- bookmarks_joined.where("#{where_sql} OR bookmarks.name ILIKE ?", query)
+ # Take into account plugins needing placeholders with ?
+ query = where_sql.include?("?") ? [query, query] : [query]
+ bookmarks_joined.where("#{where_sql} OR bookmarks.name ILIKE ?", *query)
end
end
diff --git a/plugins/chat/lib/chat/message_bookmarkable.rb b/plugins/chat/lib/chat/message_bookmarkable.rb
index f603dc62ff3..9af05d68a70 100644
--- a/plugins/chat/lib/chat/message_bookmarkable.rb
+++ b/plugins/chat/lib/chat/message_bookmarkable.rb
@@ -34,7 +34,7 @@ module Chat
end
def self.search_query(bookmarks, query, ts_query, &bookmarkable_search)
- bookmarkable_search.call(bookmarks, "chat_messages.message ILIKE :q")
+ bookmarkable_search.call(bookmarks, "chat_messages.message ILIKE ?")
end
def self.validate_before_create(guardian, bookmarkable)
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb
index fc7e9eacf54..37dde1a38bd 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb
@@ -36,7 +36,7 @@ module DiscourseDataExplorer
# Searchable only by data_explorer_queries name
def self.search_query(bookmarks, query, ts_query, &bookmarkable_search)
- bookmarkable_search.call(bookmarks, "data_explorer_queries.name ILIKE :q")
+ bookmarkable_search.call(bookmarks, "data_explorer_queries.name ILIKE ?")
end
def self.reminder_handler(bookmark)