2
0
Эх сурвалжийг харах

Merge branch 'main' into release/3

Vince Salvino 1 жил өмнө
parent
commit
88cda2d136

+ 4 - 0
coderedcms/templates/coderedcms/pages/search.html

@@ -63,7 +63,11 @@
   {% for page in results_paginated %}
   <div class="mb-5">
     {% with page=page.specific %}
+    {% if page.search_template %}
     {% include page.search_template %}
+    {% else %}
+    {% include "coderedcms/pages/search_result.html" %}
+    {% endif %}
     {% endwith %}
   </div>
   {% endfor %}

+ 9 - 1
coderedcms/views.py

@@ -22,6 +22,8 @@ from django.views.decorators.http import require_POST
 from icalendar import Calendar
 from wagtail.admin import messages
 from wagtail.models import Page, get_page_models
+from wagtail.search.backends import get_search_backend
+from wagtail.search.backends.database.mysql.mysql import MySQLSearchBackend
 from coderedcms import utils
 from coderedcms.forms import SearchForm
 from coderedcms.models import CoderedPage, LayoutSettings
@@ -61,7 +63,13 @@ def search(request):
                 model = ContentType.objects.get(
                     model=search_model
                 ).model_class()
-                results = results.type(model)
+                # Workaround for Wagtail MySQL search bug.
+                # See: https://github.com/wagtail/wagtail/issues/11273
+                backend = get_search_backend()
+                if type(backend) is MySQLSearchBackend:
+                    results = model.objects.live()
+                else:
+                    results = results.type(model)
             except ContentType.DoesNotExist:
                 # Maintain existing behavior of only returning objects if the page type is real
                 results = None

+ 1 - 0
docs/releases/index.rst

@@ -27,6 +27,7 @@ Supported Versions:
 .. toctree::
     :maxdepth: 1
 
+    v3.0.2
     v3.0.1
     v3.0.0
     v2.1.4

+ 14 - 0
docs/releases/v3.0.2.rst

@@ -0,0 +1,14 @@
+v3.0.2 release notes
+====================
+
+
+Bug fixes
+---------
+
+* Fix site search: when searching by specific page models (``search_filterable=True``) on MySQL databases, no search results would be returned. We have applied a workaround to this bug in Wagtail, with one small caveat: for example when filtering by a model ``WebPage``, the search results on SQLite and Postgres will return results for ``WebPage`` and anything inherting from ``WebPage``. On MySQL, it will ONLY return ``WebPage`` results. *However, the bug still persists in the Wagtail Admin search and will need to be fixed in a future version of Wagtail.*
+
+
+Thank you!
+----------
+
+Thanks to everyone who contributed to `3.0.2 on GitHub <https://github.com/coderedcorp/coderedcms/milestone/52?closed=1>`_.