Problem/Motivation

Currently visitors tries to get the title directly from the routeObject. This doesn't work on some pages, such as /admin/reports/dblog.

Steps to reproduce

Enable the module and visit the database log page. Check the "visitors" table in the database and see there is no title for the entry.

Proposed resolution

Use the title_resolver service to get the title.

Reference: drupal_set_title() and drupal_get_title() were removed.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork visitors-3268967

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

imclean created an issue. See original summary.

imclean’s picture

Status: Active » Needs review
StatusFileSize
new700 bytes

This should probably be injected but there are a few other \Drupal calls so they could all be fixed in the one issue.

imclean’s picture

Issue summary: View changes

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

  • bluegeek9 committed 844ec2d on 8.x-2.x
    Issue #3268967: Use title_resolver to get the page title
    
bluegeek9’s picture

Status: Needs review » Fixed
sah62’s picture

There's actually an issue with this fix: \Drupal::service('title_resolver')->getTitle can return an array, and you can't pass an array to htmlspecialchars_decode().

bluegeek9’s picture

Status: Fixed » Needs work

Good catch. if the result is an array, the '#markup' index should be used.

sah62’s picture

StatusFileSize
new800 bytes

Here's a proposed patch. getTitle can also return null, so I thought it best to test the return value to see if it's a string, or an array, and then return an empty string if it isn't a string or an array.

bluegeek9’s picture

Version: 8.x-2.7 » 8.x-2.x-dev
Status: Needs work » Needs review

I added the is_array check. The is_string check is redundant.

bluegeek9’s picture

  • bluegeek9 committed e0a9d66 on 8.x-2.x
    Issue #3268967 by imclean, sah62: Use title_resolver to get the page...
bluegeek9’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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