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.

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

anairamzap created an issue. See original summary.

anairamzap’s picture

Title: Call to deprecated function _url » Call to undefined function _url

anairamzap’s picture

Status: Active » Needs review

Set to Needs Review since a MR is provided.

raveen_thakur51’s picture

@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.

** But after implementing the MR! the issue has been fixed. Thank You!!

berdir’s picture

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.

anairamzap’s picture

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.

oily’s picture

@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 produce errors
  3. Such errors should be tested against a recommended configuration
  4. Other errors will not be supported
recrit’s picture

static patch for composer builds.

  • berdir committed 612596b4 on 8.x-1.x authored by anairamzap
    fix: #3399714 Call to undefined function _url
    
    By: anairamzap
    
berdir’s picture

Status: Needs review » Fixed

Not sure how to prevent this being available as an attachment, the display type maybe. Merge this for now.

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.

Status: Fixed » Closed (fixed)

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