"Source path has to start with a slash" exception when hitting path prefixed with index.php with RequestPath condition

Created on 27 March 2019, over 5 years ago
Updated 16 August 2024, 3 months ago

Problem/Motivation

When hitting a site with at least one block configured with a request_path condition on any URL prefixed with index.php (i.e example.com/index.phpfoo, the following error is thrown (truncated stacktrace for brevity)

InvalidArgumentException: Source path foo has to start with a slash. in Drupal\path_alias\AliasManager->getAliasByPath() (line 185 of core/modules/path_alias/src/AliasManager.php).

Drupal\system\Plugin\Condition\RequestPath->evaluate() (Line: 77)
Drupal\Core\Condition\ConditionManager->execute() (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)

Steps to reproduce

  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

Potentially always prefix $path with a forward slash.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
System 

Last updated 8 days ago

No maintainer
Created by

🇮🇳India shamseerva

Live updates comments and jobs are added and updated live.
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