Search Isn't Working - PHP Warning

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

  1. Switched to an external managed database
  2. 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:

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] 
PHP Warning:  Creating default object from empty value in 
on line 51, referer:
// Line breaks added for readability 

Client IP is Cloudflare FYI - okay to expose.

Right now search doesn’t work at all.

Hi @benaltair

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.


1 Like

Hi again, @benaltair

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/ on line 37
PHP Notice:  Array to string conversion in /var/www/html/lib/pkp/classes/search/ 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.

Actually, I should ask: what should I be looking for in my SQL logs for a successful search?

Hi @benaltair

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)

In case it helps, the theme files are in this repo: GitHub - bahaistudies/jbs: Our main JBS theme for OJS.

I really appreciate the assistance troubleshooting this one.

Out of curiosity, have you briefly tried flipping to a standard default theme?

Good question. I just tried it, and it doesn’t seem to make a difference.

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

Hi @benaltair

Is there a chance that you can duplicate your installation locally, off of Cloudflare and your managed database environment?