ViewsConfigUpdater $deprecationsEnabled flag does not persist to preSave hook

Created on 9 June 2025, 28 days ago

Problem/Motivation

In πŸ› Remove duplicate "add block" link from block content type view's "Results not found" message Postponed we are adding a new post update hook that updates views configs. This has started triggering deprecation errors from other views post update hooks (at this time views_post_update_table_css_class) because ViewsConfigUpdater is created using the classResolver pattern in both the post_update and ViewsHooks::viewPresave which means $view_config_updater->setDeprecationsEnabled(FALSE); does not persist from the post update to the presave.

This is compounded by the fact that for every views post update hook, the presave is called and then all views updates are run again on every view since the presave runs updateAll. This should be fixed in a separate issue.

Steps to reproduce

See https://git.drupalcode.org/issue/drupal-3095893/-/jobs/5480383

Proposed resolution

Turn ViewsConfigUpdater into a service so the class property persists.

Remaining tasks

Review
Commit

API changes

ViewsConfigUpdater is now a service

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

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

Merge Requests

Comments & Activities

  • Issue created by @acbramley
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Pipeline finished with Failed
    28 days ago
    Total: 129s
    #518147
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Pipeline finished with Success
    28 days ago
    Total: 2065s
    #518151
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Something we can get a test for?

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    To do that we need to add public API for getting the deprecationsEnabled flag, IMO this is covered by the other issue but I can see value in keeping a test around.

    I've pushed something up. The test only run will fail but that'll be because the service doesn't exist so you'll have to manually edit the post update + presave hooks to see that.

  • Pipeline finished with Failed
    27 days ago
    Total: 146s
    #519198
  • Pipeline finished with Failed
    27 days ago
    Total: 122s
    #519207
  • Pipeline finished with Failed
    27 days ago
    Total: 504s
    #519211
  • Pipeline finished with Failed
    27 days ago
    Total: 150s
    #519222
  • Pipeline finished with Success
    27 days ago
    Total: 1100s
    #519226
  • Pipeline finished with Failed
    27 days ago
    Total: 899s
    #519271
  • Pipeline finished with Success
    27 days ago
    Total: 882s
    #519280
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Ran the test-only job here https://git.drupalcode.org/issue/drupal-3529274/-/jobs/5584584 which outputted

    1) Drupal\Tests\views\Functional\ViewsConfigUpdaterTest::testDeprecationsFlagPersists
    The update failed with the following message: "Failed: Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "Drupal\views\ViewsConfigUpdater". in Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() (line 1041 of /builds/issue/drupal-3529274/vendor/symfony/dependency-injection/ContainerBuilder.php)."
    /builds/issue/drupal-3529274/core/tests/Drupal/Tests/UpdatePathTestTrait.php:68
    /builds/issue/drupal-3529274/core/modules/views/tests/src/Functional/ViewsConfigUpdaterTest.php:67
    FAILURES!
    Tests: 1, Assertions: 5, Failu

    I searched the repo for "\Drupal::classResolver(ViewsConfigUpdater" and all 4 instances have been replaced.

    Can we get a CR about this being a service and how should be used going forward.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks! Believe all feedback has been addressed

  • Pipeline finished with Success
    20 days ago
    Total: 587s
    #524916
Production build 0.71.5 2024