silverstripe / silverstripe-search-service

A service-agnostic search module for Silverstripe CMS
BSD 3-Clause "New" or "Revised" License
5 stars 18 forks source link

the method 'searchableFields' does not exist on 'SilverStripe\SearchService\Admin\IndexedDocumentsResult' #82

Closed bclegaspi closed 1 year ago

bclegaspi commented 1 year ago

Hello,

Anyone getting the error: the method 'searchableFields' does not exist on 'SilverStripe\SearchService\Admin\IndexedDocumentsResult' after upgrading to silverstripe/recipe-cms 4.13 in the search service tab on the CMS?

Thank you

chrispenny commented 1 year ago

Hi @bclegaspi,

Could you please share what version (or commit hash) of this module you're running (from your composer.lock file)?

I checked out version 1.0.0 (Dec 2021) of this module, and there was/is no method called searchableFields() provided by the module. If you were previously running a pre-release (and have now switched to a tagged release), then it's possible that there was a "breaking change" at some point between pre-release and release.

bclegaspi commented 1 year ago

Hi @chrispenny ,

I am using the release version for 2.0.3

image

This was fine until I upgraded to silverstripe 4.13 from 4.12

chrispenny commented 1 year ago

Thanks, @bclegaspi

Any chance you have a full stack trace of the error, and could you please provide any extra context on when this error occurs?

I upgraded one of my 4.12 projects that uses this module to 4.13, and I was able to perform the following tasks without experiencing this error:

Is it possible that you have some bespoke code that is triggering this method call?

bclegaspi commented 1 year ago

Here is the stack trace, the indexing functions seems to be working fine, I am only encountering the error when I go to search service in the admin module:

[Emergency] Uncaught BadMethodCallException: Object->__call(): the method 'searchableFields' does not exist on 'SilverStripe\SearchService\Admin\IndexedDocumentsResult' GET /admin/search-service/ Line 54 in /var/www/html/vendor/silverstripe/framework/src/Core/CustomMethods.php

Source 45 @throws BadMethodCallException 46 / 47 public function call($method, $arguments) 48 { 49 // If the method cache was cleared by an an Object::add_extension() / Object::remove_extension() 50 // call, then we should rebuild it. 51 $class = static::class; 52 $config = $this->getExtraMethodConfig($method); 53 if (empty($config)) { 54 throw new BadMethodCallException( 55 "Object->call(): the method '$method' does not exist on '$class'" 56 ); 57 } 58 59 switch (true) { 60 case isset($config['callback']): { Trace SilverStripe\View\ViewableData->call GridFieldFilterHeader.php:262 SilverStripe\Forms\GridField\GridFieldFilterHeader->canFilterAnyColumns GridFieldFilterHeader.php:528 SilverStripe\Forms\GridField\GridFieldFilterHeader->getHTMLFragments GridField.php:527 SilverStripe\Forms\GridField\GridField->FieldHolder call_user_func_array ViewableData.php:488 SilverStripe\View\ViewableData->obj ViewableData.php:550 SilverStripe\View\ViewableData->XML_val SSViewer_Scope.php:323 SilverStripe\View\SSViewer_Scope->call SSViewer_DataPresenter.php:309 SilverStripe\View\SSViewer_DataPresenter->__call .cachevendor.silverstripe.admin.templates.SilverStripe.Admin.Includes.LeftAndMain_EditForm.ss:161 include(/tmp/silverstripe-cache-php8.1.8-var-www-html/www-data/.cachevendor.silverstripe.admin.templates.SilverStripe.Admin.Includes.LeftAndMain_EditForm.ss) SSViewer.php:605 SilverStripe\View\SSViewer->includeGeneratedTemplate SSViewer.php:677 SilverStripe\View\SSViewer->process SSViewerProxy.php:38 LeKoala\DebugBar\Proxy\SSViewerProxy->process ViewableData.php:404 SilverStripe\View\ViewableData->renderWith Form.php:1566 SilverStripe\Forms\Form->forTemplate ViewableData.php:552 SilverStripe\View\ViewableData->XML_val SSViewer_Scope.php:323 SilverStripe\View\SSViewer_Scope->call SSViewer_DataPresenter.php:309 SilverStripe\View\SSViewer_DataPresenter->call .cachevendor.silverstripe.admin.templates.SilverStripe.Admin.Includes.LeftAndMain_Content.ss:14 include(/tmp/silverstripe-cache-php8.1.8-var-www-html/www-data/.cachevendor.silverstripe.admin.templates.SilverStripe.Admin.Includes.LeftAndMain_Content.ss) SSViewer.php:605 SilverStripe\View\SSViewer->includeGeneratedTemplate SSViewer.php:677 SilverStripe\View\SSViewer->process SSViewerProxy.php:38 LeKoala\DebugBar\Proxy\SSViewerProxy->process ViewableData.php:404 SilverStripe\View\ViewableData->renderWith LeftAndMain.php:1192 SilverStripe\Admin\LeftAndMain->Content call_user_func_array ViewableData.php:488 SilverStripe\View\ViewableData->obj ViewableData.php:550 SilverStripe\View\ViewableData->XML_val SSViewer_Scope.php:323 SilverStripe\View\SSViewer_Scope->call SSViewer_DataPresenter.php:309 SilverStripe\View\SSViewer_DataPresenter->call .cachevendor.silverstripe.admin.templates.SilverStripe.Admin.LeftAndMain.ss:48 include(/tmp/silverstripe-cache-php8.1.8-var-www-html/www-data/.cachevendor.silverstripe.admin.templates.SilverStripe.Admin.LeftAndMain.ss) SSViewer.php:605 SilverStripe\View\SSViewer->includeGeneratedTemplate SSViewer.php:677 SilverStripe\View\SSViewer->process SSViewerProxy.php:38 LeKoala\DebugBar\Proxy\SSViewerProxy->process ViewableData.php:404 SilverStripe\View\ViewableData->renderWith LeftAndMain.php:1048 SilverStripe\Admin\LeftAndMain->SilverStripe\Admin{closure} call_user_func PjaxResponseNegotiator.php:92 SilverStripe\Control\PjaxResponseNegotiator->respond LeftAndMain.php:891 SilverStripe\Admin\LeftAndMain->index RequestHandler.php:323 SilverStripe\Control\RequestHandler->handleAction Controller.php:286 SilverStripe\Control\Controller->handleAction RequestHandler.php:202 SilverStripe\Control\RequestHandler->handleRequest Controller.php:212 SilverStripe\Control\Controller->handleRequest LeftAndMain.php:820 SilverStripe\Admin\LeftAndMain->handleRequest AdminRootController.php:123 SilverStripe\Admin\AdminRootController->handleRequest Director.php:361 SilverStripe\Control\Director->SilverStripe\Control{closure} VersionedHTTPMiddleware.php:41 SilverStripe\Versioned\VersionedHTTPMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} LoginSessionMiddleware.php:53 SilverStripe\SessionManager\Middleware\LoginSessionMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} SEORequestProcessor.php:78 SilverStripers\SEO\Control\SEORequestProcessor->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} DebugBarMiddleware.php:19 LeKoala\DebugBar\Middleware\DebugBarMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} ConfirmationMiddleware.php:254 SilverStripe\Control\Middleware\ConfirmationMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} ConfirmationMiddleware.php:254 SilverStripe\Control\Middleware\ConfirmationMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} PasswordExpirationMiddleware.php:84 SilverStripe\Security\PasswordExpirationMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} BasicAuthMiddleware.php:68 SilverStripe\Security\BasicAuthMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} AuthenticationMiddleware.php:61 SilverStripe\Security\AuthenticationMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} ExecMetricMiddleware.php:20 SilverStripe\Control\Middleware\ExecMetricMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} CanonicalURLMiddleware.php:190 SilverStripe\Control\Middleware\CanonicalURLMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} HTTPCacheControlMiddleware.php:43 SilverStripe\Control\Middleware\HTTPCacheControlMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} ChangeDetectionMiddleware.php:28 SilverStripe\Control\Middleware\ChangeDetectionMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} FlushMiddleware.php:31 SilverStripe\Control\Middleware\FlushMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} RequestProcessor.php:69 SilverStripe\Control\RequestProcessor->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} SessionMiddleware.php:20 SilverStripe\Control\Middleware\SessionMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} AllowedHostsMiddleware.php:60 SilverStripe\Control\Middleware\AllowedHostsMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} TrustedProxyMiddleware.php:176 SilverStripe\Control\Middleware\TrustedProxyMiddleware->process HTTPMiddlewareAware.php:62 SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure} HTTPMiddlewareAware.php:65 SilverStripe\Control\Director->callMiddleware Director.php:370 SilverStripe\Control\Director->handleRequest HTTPApplication.php:120 SilverStripe\Control\HTTPApplication::SilverStripe\Control{closure} call_user_func HTTPApplication.php:143 SilverStripe\Control\HTTPApplication->SilverStripe\Control{closure} HTTPMiddlewareAware.php:65 SilverStripe\Control\HTTPApplication->callMiddleware HTTPApplication.php:144 SilverStripe\Control\HTTPApplication->execute HTTPApplication.php:119 SilverStripe\Control\HTTPApplication->handle index.php:24

chrispenny commented 1 year ago

Thanks, @bclegaspi! That stack trace was super helpful.

I can see the change that occurred in 4.13.

In 4.12 it looks like the canFilterAnyColumns() method didn't attempt to access this searchableFields() method (in fact, no part of this class does): https://github.com/silverstripe/silverstripe-framework/blob/4.12/src/Forms/GridField/GridFieldFilterHeader.php#L251

In 4.13, it now does: https://github.com/silverstripe/silverstripe-framework/blob/4.13/src/Forms/GridField/GridFieldFilterHeader.php#L254

I had a very quick go of adding a searchableFields() method definition to IndexedDocumentsResult, but that just shifted the error to the next use of the value.

I think this will actually need to be an issue raised on SS Framework, as really we need a fix there to not assume that these methods are available. I'm working on raising an issue there.

bclegaspi commented 1 year ago

Thanks alot @chrispenny for looking into this, I appreciate your help.

chrispenny commented 1 year ago

My pleasure, @bclegaspi! I appreciate you raising the issue - it's going to be a problem for all of us!

I've raised an Issue here: https://github.com/silverstripe/silverstripe-framework/issues/10768

GuySartorelli commented 1 year ago

Is there anything about this issue which is not covered by https://github.com/silverstripe/silverstripe-framework/issues/10768? If not, this issue should be closed.

chrispenny commented 1 year ago

Thanks, @GuySartorelli !

Yup, I think we can close this - it's still searchable when anyone else comes across it, and it sounds like there won't be anything for us to do here.

chrispenny commented 1 year ago

Reopening, as after some discussion with @GuySartorelli there will be some changes required for this module.

In particular, we need to remove GridFieldFilterHeader from the GridField in the model admin.

chrispenny commented 1 year ago

@bclegaspi a new tag is available: https://github.com/silverstripe/silverstripe-search-service/releases/tag/2.1.0

I'll also port this fix for Silverstripe 5.