Call to undefined method when attempting database update

Created on 7 February 2023, almost 2 years ago
Updated 30 June 2023, over 1 year ago

Problem/Motivation

On a migration dev server running Drupal 9.4.9, I have pending database updates after updating Drupal core and modules, but cannot run them. The pending database updates are to the system module, ckeditor module, image module, update module, and views module.

Steps to reproduce

From the Drupal status page where it says You should run the database update script immediately. then clicking the Apply Pending Updates button I get an Updating page error message:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /update.php/start?id=13&op=do_nojs&op=do
StatusText: OK
ResponseText: Error: Call to undefined method Drupal\views\Plugin\views\style\DefaultStyle::getFormats() in Drupal\rest\Plugin\views\display\RestExport->collectRoutes() (line 351 of /var/www/cascade/prod/nesea.org/webroot/web/core/modules/rest/src/Plugin/views/display/RestExport.php).

I have searched extensively for a resolution for this without finding anything to try. Thanks for any help you can offer.

💬 Support request
Status

Closed: duplicate

Version

9.4

Component
Views 

Last updated 2 days ago

Created by

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

Comments & Activities

  • Issue created by @lkuttner
  • Get us the update identifier. It is probably the first on in the list.

  • Is this result from drush updatedb:status what you are looking for? Thanks.

      ------------------ ------------------------------------------ ---------------
      Module             Update ID                                  Type           
     ------------------ ------------------------------------------ --------------- 
      file entity type                                              entity-update  
      ckeditor           omit_settings_for_disabled_plugins         post-update    
                                                                                   
      image              image_loading_attribute                    post-update    
                                                                                   
      system             enable_provider_database_driver            post-update    
      update             add_view_update_notifications_permission   post-update    
                                                                                   
      views              image_lazy_load                            post-update    
      views              provide_revision_table_relationship        post-update    
    
    
    
  • Yes. Are there also numeric identifiers?

  • Also, are the issues in #3 relevant?

  • I did not see any numeric identifiers in the Drush output-- is there another way to view them?
    I had seen the issues in #3-- the first one includes comments from me about an earlier WSOD that I did resolve.
    The other threads have been a dead-end, and while this issue may be related, I do not know enough to determine that.

  • Not yet. I figured that I should resolve current issues before running that. I ran all the other migrations.

  • Ah, the reason those updates don't have numerical identifiers is because they are all post_update hooks.

    Can you get a stack trace?

  • How's this? Thanks.

    Error: Call to undefined method Drupal\views\Plugin\views\style\DefaultStyle::getFormats() in Drupal\rest\Plugin\views\display\RestExport->collectRoutes() (line 351 of /var/www/cascade/prod/nesea.org/webroot/web/core/modules/rest/src/Plugin/views/display/RestExport.php)
    
    #0 /var/www/cascade/prod/nesea.org/webroot/web/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 /var/www/cascade/prod/nesea.org/webroot/web/core/lib/Drupal/Core/Routing/RouteBuilder.php(146): call_user_func(Array)
    #3 /var/www/cascade/prod/nesea.org/webroot/web/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
    #4 /var/www/cascade/prod/nesea.org/webroot/web/core/includes/common.inc(587): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
    #5 /var/www/cascade/prod/nesea.org/webroot/web/core/modules/system/src/Controller/DbUpdateController.php(662): drupal_flush_all_caches()
    #6 /var/www/cascade/prod/nesea.org/webroot/web/core/includes/batch.inc(456): Drupal\system\Controller\DbUpdateController::batchFinished(false, Array, Array, Object(Drupal\Core\StringTranslation\TranslatableMarkup))
    #7 /var/www/cascade/prod/nesea.org/webroot/web/core/includes/batch.inc(98): _batch_finished()
    #8 /var/www/cascade/prod/nesea.org/webroot/web/core/modules/system/src/Controller/DbUpdateController.php(186): _batch_page(Object(Symfony\Component\HttpFoundation\Request))
    #9 [internal function]: Drupal\system\Controller\DbUpdateController->handle('start', Object(Symfony\Component\HttpFoundation\Request))
    #10 /var/www/cascade/prod/nesea.org/webroot/web/core/lib/Drupal/Core/Update/UpdateKernel.php(115): call_user_func_array(Array, Array)
    #11 /var/www/cascade/prod/nesea.org/webroot/web/core/lib/Drupal/Core/Update/UpdateKernel.php(76): Drupal\Core\Update\UpdateKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request))
    #12 /var/www/cascade/prod/nesea.org/webroot/web/update.php(27): Drupal\Core\Update\UpdateKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #13 {main}
  • This really looks quite a bit like the issues I linked in #3 and those are probably the best place for any information on this.

    In RestExport, lines 346 to 351 are:

          $style_plugin = $this->getPlugin('style');
    
          // REST exports should only respond to GET methods.
          $route->setMethods(['GET']);
    
          $formats = $style_plugin->getFormats();
    

    $style_plugin can be null or of a type that isn't expected. In this case it is an instance of Drupal\views\Plugin\views\style\DefaultStyle, which is exactly what is reported in 💬 REST views: Uncaught Error: Call to undefined method Drupal\views\Plugin\views\style\DefaultStyle::getFormats() Fixed and duplicated onto 🐛 Fatal error on Drupal 8.5, on a data_export display that uses not the data_export style but the *default* style Postponed: needs info . I really think this is already being discussed in those places.

    Are there any views with Rest data exports? Check their style settings. Does the site use Views data export module?

  • Yes, there is one Rest data export from before my time, and we do use the Views data export module. I just looked at the Rest settings for the first time. I do not see where style settings are defned. Where should I look for them? Thanks.

  • I have no idea. I really think those other issues are the place to look. They include exports of affected views and suggestions on fixing them.

  • OK-- thanks. I will follow up there.

  • Status changed to Closed: duplicate almost 2 years ago
  • Open this again if it turns out to be truly unique. But it will need supporting information that it is truly unique.

    Good luck with this!

    Consider re-creating the REST export and deleting the old one. That may sort it out.

  • 🇸🇪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();

  • That worked-- thank you very much!

Production build 0.71.5 2024