CurrentPathStack::getPath should always return a path with leading slashes

Created on 26 August 2020, over 4 years ago
Updated 2 July 2024, 6 months ago

Problem/Motivation

If you visit /index.php.php path, the PHP warning occurs and a log record is created:

Notice: Undefined offset: 1 in template_preprocess_html() (line 1343 of core/includes/theme.inc).
template_preprocess_html(Array, 'html', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)

Steps to reproduce

1) First case: Visit your.site/index.php. or your.site/index.php.php

2) Second case:

  1. Clean Drupal installation
  2. Go to admin/structure/block, edit any (for example: Search) block that appears on the frontpage
  3. Go to pages tab and set /user/* and click "Show for the listed pages"
  4. Go to your.site/index.php.php
  5. There is an exception: InvalidArgumentException: Source path .php has to start with a slash. in Drupal\Core\Path\AliasManager->getAliasByPath() (line 229 of core/lib/Drupal/Core/Path/AliasManager.php).

Proposed resolution

1) Adjust Drupal\system\Plugin\Condition\RequestPath to request a path with a slash.
2) Fix template_preprocess_html() so it doesn't show a warning if there is an extra dot when resolving route path.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

The function CurrentPathStack::getPath() now returns the path with leading slashes. This change was made because paths with leading slashes are almost always correct in Drupal.

πŸ› Bug report
Status

Postponed

Version

11.0 πŸ”₯

Component
Request processingΒ  β†’

Last updated 7 days ago

No maintainer
Created by

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

    To celebrate Drupal’s 20th birthday, we held DrupalFest, a month-long series of virtual events focused on community, contribution, and the positive impacts Drupal has made possible. The community collaborated on Drupal contributions, built skills at training workshops, and came together with the Drupal community for events ranging from game nights to virtual happy hours.

Sign in to follow issues

Merge Requests

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