Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Fatal error: Class 'searchQuery' not found in sites/all/modules/views/modules/search/views_handler_filter_search.inc on line 165
This problem appears when trying to import a calendar view. In particular, I am testing the 7.x-3.0-beta3 version to see if i can safely switch to it from 7.x-3.0-alpha1. The error happens when I import the calendar view that was exported from 7.x-3.0-alpha1.
Comment | File | Size | Author |
---|---|---|---|
#25 | views-n1108064-25.patch | 15.31 KB | DamienMcKenna |
Comments
Comment #1
dawehnerDo you have search.module enabled?
Comment #2
thekevinday CreditAttribution: thekevinday commentedYes.
Comment #3
dawehnerThis class is part of drupal core, so i have no idea how to help here.
Could it be that some kind of cache isn't cleared often enough ;)
Comment #4
thekevinday CreditAttribution: thekevinday commentedYour comment helped identify the problem.
It seems that it is a case-sensitivity issue.
SearchQuery is in core, but searchQuery is not.
Comment #5
dawehnerWow.
This really worked for me all the time. Commited the patch.
Which version of php did you used? Perhaps this is just special for a new version of php. Here i use php 5.3 and it worked fine.
Comment #6
thekevinday CreditAttribution: thekevinday commentedI am not really sure myself why.
php version is 5.3.2.
I am also wondering if the reason for this might be some sort of UTF8 or caching issue.
Despite the reasons, the problem is consistent and only happens during view import of a calendar view.
Comment #7
dawehnerDid you tryed to add a filter manually to the view before the patch?
Just wanted to know...
Comment #8
thekevinday CreditAttribution: thekevinday commentedI can add a filter before the patch to any view, except the Calendar view.
After the patch, the calendar view works when adding filters.
Comment #10
dgastudio CreditAttribution: dgastudio commentedi have the same problem, but appears only if i DISABLE core search module.
Comment #11
damiankloip CreditAttribution: damiankloip commentedIf you disable the search module and you are still using a view handler that's expecting the SearchQuery class, you will probably get issues. I think you either need to remove any search handlers from your view, or re enable the search module.
Comment #12
dawehnerSo you disable search.module but you don't clear any caches?
I would bet that if you clear the views caches, the problem would go away...
Comment #13
thekevinday CreditAttribution: thekevinday commentedStrange how I am back to this, for a different reason.
I noticed @kervi's problem when I was installing a fresh system and disabled the search module prior (or perhaps at the same time?) to the installation of the views module.
Enabling/Installing views module produced mentioned error.
Clearing the cache, I did not notice a problem again.
Perhaps this would be something good to note in the documentation about disabling the search module and clearing the cache, assuming it is not already.
Comment #14
esmerel CreditAttribution: esmerel commentedComment #15
dawehnerWell one thing you could do is to wrap the class with a module_exists().
I'm not sure where the documentation could be placed to be able to be found as this is quite a special problem.
Comment #16
Cayenne CreditAttribution: Cayenne commentedWell, here we are, October 2013, and this issue has reared its head. Ironically, I disabled search to try to solve a different problem (too many modules). Ah well, at least the answer is easy to find, but a more graceful failure mode would be lovely.
Comment #17
dark_kz CreditAttribution: dark_kz commentedI have this problem, and I need to disable search module. October 2014, but problem isn't solved yet?
Comment #18
thekevinday CreditAttribution: thekevinday commentedJust glancing at the code, it looks like they include the php file that references the SearchQuery class in the main views.info file.
To disable this, those lines would have to be removed.
They look like:
The next thing you would have to do is to search for occurances of the classes and functions provided by those files.
Then wrap the discovered functions in one of the following:
if (module_exists('search')) { }
if (class_exists('SearchQuery')) { }
The first one is the proper way, the second performs a lot better and uses a php core function.
I would recommend class_exists() to avoid a performance hit everytime the code in question would need to perform the check.
Comment #19
Hal Adams CreditAttribution: Hal Adams commentedI am a neophyte Drupal user so treat the following with some patience. It might be useful info. I got to installing the Enterprise Blog module and related modules. I encountered this Fatal Error when enabling the modules. I surmise I was trying to enable too many modules at one time with limited amounts of shared memory.
I saw a Fatal Error message indicating that I was out of memory and that something had failed to allocate. I hit the browser back button and tried again, which is when I saw the:
Fatal error: Class 'SearchQuery' not found in ......modules//search/views_handler_filter_search.inc on line 201
error message. The site crashed, and I did not appear to be able to log in or access the administration menus. But after a lot of nail-biting, poking around on the web and sleeping on it, I was able to recover it. It seems the crash caused a lot of the core modules to be disabled, but I had an administration session open which allowed me to access the Modules page and re-enable them incrementally, along with rebuilding some of the databases. A lot of the content was gone but (fortunately) I had set up Backup/Migrate a few days ago and I was able to restore 95% of what was missing.
Comment #20
DamienMcKennaFYI I ran into this on a Windows server that was running wincachedrupal, I had to reboot the server to force the cache to clear, even Drush was triggering the error.
Comment #21
DamienMcKennaBTW I ran into the problem after disabling the core Search module after building a replacement with Search API.
Comment #22
vinmassaro CreditAttribution: vinmassaro commentedFWIW, we had the same issue as #21, hitting on this error with a site that uses core search.module and had Search API and Search API Solr stood up after that. Attempting to disable core search.module returns this error.
Comment #23
DamienMcKenna@vinmassaro: It was a bit weird - on my local Mac/MAMP install it worked again after just clearing cache_views, but the Windows server took extra prodding,
Comment #24
agentrickardI was working with Vincent, and here's how we disabled search. A bit of a workaround:
The proper fix in the code, I think is to wrap the views class in an IF exists check.
Comment #25
DamienMcKennaLike so?
Comment #26
citlacom CreditAttribution: citlacom commentedI was having this issue after disable the core search module in favor of search_api implementation and tried the @agentrickard workaround that worked perfectly. Thanks.
Comment #27
sk33lz CreditAttribution: sk33lz commentedSame issue as #26 and the patch in #25 fixes the issue for me.
Comment #28
dawehnerSorry for the harsh words.
I don't think this is a good idea
drush rr
, or even running update.php can't you?Comment #29
damiankloip CreditAttribution: damiankloip commentedTalked with dawhener about this, agree totally with what he is saying ^^. Wrapping the class definition is a module_exists() is not a good plan...
Comment #30
mxr576#24 worked for me.
Comment #31
jmart CreditAttribution: jmart commentedI ran drush rr.
Then I disabled the search module.
That seemed to work for me.
Comment #32
millerrs CreditAttribution: millerrs commented#24 worked for me with modifications. I had to clear the cache_bootstrap bin.
Comment #33
jdearie CreditAttribution: jdearie as a volunteer commentedI ran drush rr.
Then I disabled the search module.
That worked for me.
I had run drush rr with the search module already disabled, but continued to get the error. Once I enabled search and then ran drush rr, I was able to disable the search module with no errors.
Comment #34
djdevinThere are some cases where none of the patches here will solve it. (other than the class/module exists wrappers)
Take this example, with Date module, _date_views_fields() (search module has been disabled, rr has been run)
Date iterates over all the fields and tries to check if there is a filter for it also.
Because of this, the views_handler_filter_search.inc is included and triggers a fatal:
Date isn't doing anything specific to Search and is using standard Views functions.
Clearing all caches/invalidating the Views cache does appear to fix the problem but other modules might make it pretty difficult.
Comment #35
newswatch CreditAttribution: newswatch commentedResolution #12 worked for me. Thanks.