Call to undefined function _url

Created on 6 November 2023, about 1 year ago
Updated 16 November 2023, about 1 year ago

Problem/Motivation

When you attach a view using the the Google News Sitemap formatter to a Page (screenshots added), and then you load that page, you will get a php error:

Error: Call to undefined function Drupal\views_googlenews\Plugin\views\style\_url() in Drupal\views_googlenews\Plugin\views\style\GoogleNews->attachTo() (line 41 of modules/contrib/views_googlenews/src/Plugin/views/style/GoogleNews.php)

Indeed the _url "temporary" method was removed in Drupal 8 ( https://www.drupal.org/project/drupal/issues/2343669 )

Steps to reproduce

  1. Go create a new view based on content
  2. Add a Page and a Feed display
  3. On the Feed view display, use the formatter and row plugins provided by this module ("Google News Feed" for the format and "Google News fields" for the row config).
  4. Set the Feed display to be attached to the page you created before.
  5. Save changes
  6. When you go to configure or view the Page, you will get "Oops, something went wrong. Check your browser's developer console for more details." in the view config page
  7. Inspecting the console error logs, you will see the php error mentioned here about the non-existing method "_url()"
  8. If you remove the feed attachment to the Page, the error goes away

Proposed resolution

Use the correct function in the attachTo() method.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇦🇷Argentina anairamzap Buenos Aires

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

Comments & Activities

  • Issue created by @anairamzap
  • 🇦🇷Argentina anairamzap Buenos Aires
  • @anairamzap opened merge request.
  • Status changed to Needs review about 1 year ago
  • 🇦🇷Argentina anairamzap Buenos Aires

    Set to Needs Review since a MR is provided.

  • 🇮🇳India Raveen Kumar

    @anairamzap,

    ** I am also facing the same issue as you have mentioned. Please see my attached SS https://prnt.sc/Y712MmsO8Qqm
    ** I am using Drupal 10.1, PHP - 8.1, and composer 2.6.

  • 🇨🇭Switzerland berdir Switzerland

    This makes sense, but note that this feature makes no sense for this display. You don't attach google news to anything else, it's a standalone URL, there is no need for users to access it.

  • 🇦🇷Argentina anairamzap Buenos Aires

    This makes sense, but note that this feature makes no sense for this display. You don't attach google news to anything else, it's a standalone URL, there is no need for users to access it.

    @berdir would you recommend to remove that method entirely then?
    If we do that I'm wondering what would happen with existing view displays that attach the Feed display to a Page.

  • 🇬🇧United Kingdom oily Greater London

    @anairamzap I think that the method should be left now it is done. The README could be edited to say:

    1. The module is only intended to be used within a limited set of configurations.
    2. More unusual and complex configurations may not work
    3. Using the module outside the recommended configurations may result in errors
    4. Such errors should be tested against a recommended configuration
    5. Other errors will not be supported
Production build 0.71.5 2024