Views method FieldPluginBase::renderAsLink check for a 'host' or 'url' keys that can never be set

Created on 12 October 2016, about 8 years ago
Updated 19 February 2023, almost 2 years ago

Problem/Motivation

Around line 1420 in \Drupal\views\Plugin\views\field\FieldPluginBase::renderAsLink

A check for $url['host'] doesn't make sense becuase it's never set by UrlHelper::parse()

   // Parse the URL and move any query and fragment parameters out of the path.
    $url = UrlHelper::parse($path);

    // Seriously malformed URLs may return FALSE or empty arrays.
    if (empty($url)) {
      return $text;
    }

    // If the path is empty do not build a link around the given text and return
    // it as is.
    // http://www.example.com URLs will not have a $url['path'], so check host as well.
    if (empty($url['path']) && empty($url['host']) && empty($url['fragment']) && empty($url['url'])) {
      return $text;
    }

Proposed resolution

remove the check and fix the code comment

Remaining tasks

doit

User interface changes

none

API changes

none

Data model changes

none

πŸ› Bug report
Status

Needs work

Version

9.5

Component
ViewsΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States pwolanin

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024