Problem/Motivation

Part of #1577902: [META] Remove all usages of drupal_static() & drupal_static_reset() effort. Removes drupal_static() from views_ui_contextual_links_suppress().

Proposed resolution

  • Deprecate views_ui_contextual_links_suppress(), views_ui_contextual_links_suppress_push(), views_ui_contextual_links_suppress_pop() with no replacement.

Remaining tasks

None.

User interface changes

None.

API changes

  • views_ui_contextual_links_suppress
  • views_ui_contextual_links_suppress_push
  • views_ui_contextual_links_suppress_pop

Have been deprecated with no replacement.

Data model changes

None.

Release notes snippet

N/A

Issue fork drupal-3039248

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Status: Active » Needs review
StatusFileSize
new10.46 KB

Patch.

andypost’s picture

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

naresh_bavaskar’s picture

StatusFileSize
new10.45 KB

#2 Patch Re-rolled for 9.1.x
Please review

hardik_patel_12’s picture

StatusFileSize
new10.46 KB
new8.03 KB

Changing deprecation message from Drupal 8.8.0 and will be removed before Drupal 9.0.0 to Drupal 9.1.0 and will be removed before Drupal 10.0.0.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

I am not convinced this code even works. The comment says

      // Suppress contextual links of entities within the result set during a
      // Preview.

but if I edit the frontpage view that comes with core, contextual links are still displayed in the preview of any teaser nodes.

I put a breakpoint inside views_ui_contextual_links_suppress() and the push and pop methods are called but views_ui_contextual_links_view_alter() doesn't seem to get called in this context, although it seems like it should because the contextual links are being generated!

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alex_optim’s picture

StatusFileSize
new6.5 KB

Please check.

andypost’s picture

Status: Needs review » Needs work
+++ b/core/includes/bootstrap.inc
@@ -674,7 +675,10 @@ function drupal_static_reset($name = NULL) {
+      @trigger_error('Using drupal_static_reset() with "views_ui_contextual_links_suppress" as parameter is deprecated in Drupal 9.1.0 and will be removed before Drupal 10.0.0. Use \Drupal\views_ui\ViewsUiContextualLinks::reset() instead. See https://www.drupal.org/node/3039250.', E_USER_DEPRECATED);

+++ b/core/modules/views_ui/views_ui.module
@@ -268,39 +269,46 @@ function views_ui_contextual_links_view_alter(&$element, $items) {
+ * @deprecated in Drupal 9.1.0 and will be removed before Drupal 10.0.0. Use
...
+  @trigger_error('views_ui_contextual_links_suppress() is deprecated in Drupal 9.1.0 and will be removed before Drupal 10.0.0. Use \Drupal\views_ui\ViewsUiContextualLinks::isSuppressed() to check if rendering of contextual links is suppressed and \Drupal\views_ui\ViewsUiContextualLinks::setSuppressed() to overwrite the current state. See https://www.drupal.org/node/3039250.', E_USER_DEPRECATED);
...
+ * @deprecated in Drupal 9.1.0 and will be removed before Drupal 10.0.0. Use
...
+  @trigger_error('views_ui_contextual_links_suppress_push() is deprecated in Drupal 9.1.0 and will be removed before Drupal 10.0.0. Use \Drupal\views_ui\ViewsUiContextualLinks::suppress() instead. See https://www.drupal.org/node/3039250.', E_USER_DEPRECATED);
...
+ * @deprecated in Drupal 9.1.0 and will be removed before Drupal 10.0.0. Use
...
+  @trigger_error('views_ui_contextual_links_suppress_pop() is deprecated in Drupal 9.1.0 and will be removed before Drupal 10.0.0. Use \Drupal\views_ui\ViewsUiContextualLinks::render() instead. See https://www.drupal.org/node/3039250.', E_USER_DEPRECATED);

9.4.0 instead of 9.1

alex_optim’s picture

StatusFileSize
new7.18 KB
andypost’s picture

Thank you, now only deprecation test is needed

@alex_optim Do not forget to add interdiff https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...

andypost’s picture

alex_optim’s picture

StatusFileSize
new9.47 KB

Added interdiff.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

+++ b/core/modules/views_ui/views_ui.module
@@ -268,39 +269,46 @@ function views_ui_contextual_links_view_alter(&$element, $items) {
+  @trigger_error('views_ui_contextual_links_suppress_push() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\views_ui\ViewsUiContextualLinks::suppress() instead. See https://www.drupal.org/node/3039250', E_USER_DEPRECATED);
...
+ * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use

should be 10.0.0 and 10.1.0

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

nicxvan made their first commit to this issue’s fork.

longwave’s picture

As far as I can see I don't think any of this code works.

I put breakpoints in:

  • ViewUI::renderPreview() - where push and pop are called
  • ViewsUIHooks::contextualLinksViewAlter() - where the links are meant to be suppressed
  • ContextualLinks::preRenderLinks() - where the alter hook is called from

The push and pop are called, but the hook is never invoked. This is because contextual links don't appear to use the #contextual_links render element any more, but #contextual_links_placeholder instead - adding a breakpoint in ContextualLinksPlaceholder::preRenderPlaceholder() is caught, but that doesn't invoke the alter hook.

Even if this did work, the push and pop are wrapped around the preview time, which only builds a render array; the prerender hook won't be called until later, after the suppression has been popped.

I think we should deprecate these functions entirely, removing all functionality and leaving just stubs that can be removed in a future major.

longwave changed the visibility of the branch 3039248-test to hidden.

longwave changed the visibility of the branch 3039248-deprecate-viewsuicontextuallinkssuppress-viewsuicontextuallinkssuppresspush to hidden.

longwave’s picture

Status: Needs work » Needs review

nicxvan’s picture

I searched contrib and only found one call to views_ui_contextual_links_suppress: https://www.drupal.org/project/commerce_invoice_receipt which has no current release.

I think on that alone we can deprecate with no replacement.

I did put breakpoints I saw that contextualLinksViewAlter did get called in the ui, but supress never returned true so we only hit the elseif clause.

I think that is what you are saying is right though.

This is meant to stop contextual links from showing up in the views preview right? When I checked that I do see contextual links in the preview both on this MR and in main so I think this is fine to remove.

nicxvan’s picture

Took a quick look, I think we also need a deprecation in bootstrap.inc for the drupal_static call for views_ui_contextual_links_suppress

berdir’s picture

> Took a quick look, I think we also need a deprecation in bootstrap.inc for the drupal_static call for views_ui_contextual_links_suppress

Do we really need to bother with this? This isn't a cache, it's just a means to carry in-memory-state between multiple functions, nothing anyone should ever need to reset. I'd say skip this, avoids conflicts in there.

nicxvan’s picture

I'll defer to you guys here

nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

I checked the CR and updated the IS.

I think deprecating these for removal in 12 is fine since contrib doesn't call them and they have not worked in ages.

alexpott’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 3742821e2b1 to main and 4b473042d6c to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 4b473042 on 11.x
    task: #3039248 Deprecate views_ui_contextual_links_suppress(),...

  • alexpott committed 3742821e on main
    task: #3039248 Deprecate views_ui_contextual_links_suppress(),...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.