Description of issue or problem I’m having:
At some point during a series of consecutive changes, search stopped working. Any query returns empty results.
Steps I took leading up to the issue:
We made some changes around the time this happened
Switched to an external managed database
Enabled Cloudflare for DDOS, IP masking, and CDN/Caching
What I tried to resolve the issue:
Disabling Cloudflare for this domain
Disabling caching for query URLs
Exploring theme code to see if input values were misaligned, etc
Checked the database logs - no queries are detected
Application Version:
3.2.1.2
Additional information, such as screenshots and error log messages if applicable:
It seems like the issue is in the frontend, thinking the value of query is blank, so it doesn’t even try to forward the network request to the DB.
Consistently, with any query, the following shows in the Apache error.log file:
[Sat Nov 13 02:55:24.309548 2021] [php7:warn]
[pid 1850195] [client 108.162.246.200:27146]
PHP Warning: Creating default object from empty value in
/var/www/html/cache/t_compile/912819d46cd25075eaf3e831e7b7db1fb6a10d5e^756a7119cb48731a8fd45c250b45f4bcca2d6b01_0.app.frontendpagessearch.tpl.php
on line 51, referer: https://journal.bahaistudies.ca/online/search/search?query=article&title=&authors=&dateFromYear=&dateFromMonth=&dateFromDay=&dateToYear=&dateToMonth=&dateToDay=
// Line breaks added for readability
The expanding/collapsing search bar on the front of OJS up at the top in the header is generally quite broken in 3.2. It’s been removed completely in 3.3 because it often did not return results. Do searches work if you go to the “advanced search” page and run them from there?
If those don’t work, the first thing I’d suggest is rebuilding your search index with:
php tools/rebuildSearchIndex.php
From the web root. If that still doesn’t fix it, Cloudflare might be the problem.
I fished out your journal URL from your error message, and I also do not get results on the advanced page. In that case I’d try rebuilding the search index first, with the command I mentioned above.
Hi @jnugent - thanks for your response. I’ve tested both suggestions, but unfortunately it doesn’t seem to have fixed the issue so far. The index rebuild seems to run fine, although there is a notice displayed dozens of times while it’s running.
PHP Notice: Array to string conversion in /var/www/html/lib/pkp/classes/search/SubmissionSearchIndex.inc.php on line 37
PHP Notice: Array to string conversion in /var/www/html/lib/pkp/classes/search/SubmissionSearchIndex.inc.php on line 37
[... many identical "PHP Notice" messages]
337 articles indexed
It’s odd to me that disabling Cloudflare doesn’t seem to solve the issue. Do you think it’s frontend related? Could it be how the frontend talks to the server perhaps, and something to do with the request not making it to the managed database? This is the oddest thing so far, is that I don’t ever see the queries in my SQL logs for these searches.
MySQL may log queries, but that would be something outside of OJS. You could also have a look at the various submission_search_* tables in the database to see if they have content. If you looked at database queries, you’d want to see searches using the submission_search_object_keywords table.
What’s the managed database configuration? Are you load balanced and perhaps running queries against a replicated database that hasn’t received updated content and you are searching empty tables?
You don’t have any search related plugins perhaps? Lucene or something enabled and you aren’t searching what you are think you are?
Hi @jnugent - so after querying the keywords table, I can see a few hundred records. I’m using a managed database cluster, but only with a single primary database, running MySQL 8.
The only search related plugin I have is disabled (Algolia)
So, that test right there should rule out a problem with your own theme.
The other database table worth a look at is submission_search_keyword_list which is the table that stores the actual indexed keywords. If there’s nothing in that table, or it looks small, that could be a problem. For 300+ articles there should be a fair bit of content in that.
Looks like that table is solid.
When looking at those Apache logs, it still seems like it’s trying to search for an empty string, not even querying the database in the first place. How would that be possible?
Specifically, this file in the logs:
PHP Warning: Creating default object from empty value in
[...]/cache/[...]app.frontendpagessearch.tpl.php on line 51