Fatal error on Drupal 8.5, on a data_export display that uses not the data_export style but the *default* style

Created on 22 March 2018, over 6 years ago
Updated 30 June 2023, over 1 year ago

I see this error when running drush cr or manually flushing the cache. I have a view with three Data Export displays:

Error: Call to undefined method Drupal\views\Plugin\views\style\DefaultStyle::getFormats() in Drupal\rest\Plugin\views\display\RestExport->collectRoutes() (line 368 of /mnt/www/html/naswastg/docroot/core/modules/rest/src/Plugin/views/display/RestExport.php) #0 /mnt/www/html/naswastg/docroot/core/modules/views/src/EventSubscriber/RouteSubscriber.php(120): Drupal\rest\Plugin\views\display\RestExport->collectRoutes(Object(Symfony\Component\Routing\RouteCollection)) #1 [internal function]: Drupal\views\EventSubscriber\RouteSubscriber->routes() #2 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/Routing/RouteBuilder.php(146): call_user_func(Array) #3 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild() #4 /mnt/www/html/naswastg/docroot/core/includes/common.inc(1156): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() #5 /mnt/www/html/naswastg/docroot/core/modules/system/src/Form/PerformanceForm.php(176): drupal_flush_all_caches() #6 [internal function]: Drupal\system\Form\PerformanceForm->submitCacheClear(Array, Object(Drupal\Core\Form\FormState)) #7 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array) #8 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #9 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(585): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #10 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('system_performa...', Array, Object(Drupal\Core\Form\FormState)) #11 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('system_performa...', Object(Drupal\Core\Form\FormState)) #12 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #13 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #14 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #15 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #16 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #17 /mnt/www/html/naswastg/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #18 /mnt/www/html/naswastg/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #19 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /mnt/www/html/naswastg/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /mnt/www/html/naswastg/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /mnt/www/html/naswastg/docroot/modules/contrib/shield/src/ShieldMiddleware.php(99): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\shield\ShieldMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /mnt/www/html/naswastg/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /mnt/www/html/naswastg/docroot/core/lib/Drupal/Core/DrupalKernel.php(657): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /mnt/www/html/naswastg/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #29 {main}.

πŸ› Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brooke_heaton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡ΎCyprus alex.bukach

    In our case it happened because of migrated views that originally used XLS data export in Drupal 7 which is not available in Drupal 9. Therefore they used default style plugin instead of the missing XLS one. Switching the style plugin to CSV fixed the issue.

  • πŸ‡ΈπŸ‡ͺSweden arne_hortell

    In core/modules/rest/src/Plugin/views/display/RestExport.php function collectRoutes

    find the line
    $formats = $style_plugin->getFormats();

    replace with
    $formats=false;
    if (method_exists($style_plugin,'getFormats'))
    $formats = $style_plugin->getFormats();

Production build 0.71.5 2024