Jump to content

Error: Undefined index path


jploch
 Share

Recommended Posts

When running tracy in my local development environment (node + laravel valet), I get the following error on my frontend:

Notice: Undefined index: path in /Users/jploch/Sites/pgrid-dev/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/TracyDebugger.module.php on line 2784

This happens with the master as well as the dev version of PW.

Link to comment
Share on other sites

  • 2 weeks later...

Hi @jploch - sorry for the late response - I was on vacation.

Can you please point me to the line on the Github repo. I feel like it might actually be: https://github.com/adrianbj/TracyDebugger/blob/6f62b8e2c03e1520615ea654e79f4e44b61f9f20/TracyDebugger.module.php#L2847 but that isn't the line number from your error.

Also can you please do a dump of parse_url($_SERVER['REQUEST_URI']); so I can see what is returned?

  • Like 1
Link to comment
Share on other sites

@adrian no worries. Thanks for taking a look. I made some changes already to my local enviroment (updating php and valet) and the error above seems to have changed. Strangely it was only happening once in a while, and not on all the pages. But for some of my local websites I still get errors on the frontend and tracy is not loading (only on some pages):

TypeError: strpos() expects parameter 1 to be string, bool given in /Users/jploch/Sites/pgrid-website/dist/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/assets/loader.phtml:14 Stack trace: #0 /Users/jploch/Sites/pgrid-website/dist/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/assets/loader.phtml(14): strpos(false, '?') #1 /Users/jploch/Sites/pgrid-website/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/Bar.php(109): require('/Users/jploch/S...') #2 /Users/jploch/Sites/pgrid-website/dist/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Debugger/DevelopmentStrategy.php(139): Tracy\Bar->render(Object(Tracy\DeferredContent)) #3 /Users/jploch/Sites/pgrid-website/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Debugger/Debugger.php(321): Tracy\DevelopmentStrategy->renderBar() #4 [internal function]: Tracy\Debugger::shutdownHandler() #5 {main} (stored in /Users/jploch/Sites/pgrid-website/dist/site/assets/logs/tracy/exception--2023-03-19--14-23--52479f289e.html)

 

9 hours ago, adrian said:

Also can you please do a dump of parse_url($_SERVER['REQUEST_URI']); so I can see what is returned?

I did a "var_dump(parse_url($_SERVER['REQUEST_URI']));" on those pages on the frontend, it returns this:

array(1) {
  ["path"]=>
  string(0) ""
}

array(1) {
  ["path"]=>
  string(0) ""
}

On the pages that work (same installation and setup), I get this response for the var_dump:

array(1) { ["path"]=> string(4) "ice/" } array(1) { ["path"]=> string(4) "ice/" }

 

Link to comment
Share on other sites

  • 9 months later...

I'm experiencing this in production, not with Laravel. It appears to happen when the path has an empty segment, e.g. https://gregorlove.com//xmlrpc.php?rsd 

This isn't a valid URL on my site, I know it's just someone scanning for vulnerabilities, but I saw this error in the Tracy logs:

Warning: Undefined array key "path" in /site/assets/cache/FileCompiler/site/modules/TracyDebugger/TracyDebugger.module.php on line 2865
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /site/assets/cache/FileCompiler/site/modules/TracyDebugger/TracyDebugger.module.php on line 2865

ProcessWire: 3.0.210
PHP: 8.1.27
TracyDebugger: 4.25.17

Update:

The issue appears to be that `REQUEST_URI` in this instance is `//xmlrpc.php?rsd`. Running parse_url() on that does not return a path segment because it parses `xmlrpc.php` as the host and `?rsd` as the query. The following explode() line expects that path. I think there needs to be some more sanitization before using the result of that parse_url().

Edited by gRegor
Additional debug info
  • Like 1
Link to comment
Share on other sites

4.25.18 appears to still have the issue. It's in these lines:

$info = parse_url($_SERVER['REQUEST_URI']);
$parts = explode('/', $info['path']);

I added some debugging and a proof of concept workaround (surely not correct) for the missing path:

$info = parse_url($_SERVER['REQUEST_URI']);

if (array_key_exists('path', $info)) {
    $path = $info['path'];
} else {
    $path = '/';
}

$parts = explode('/', $path);

I think the more correct thing to do is ensure a full, valid URL is passed into parse_url() to ensure the path gets parsed correctly.

I can file a github issue if that helps.

Link to comment
Share on other sites

58 minutes ago, gRegor said:

@adrian Oh interesting, I had just updated it before posting, but I see there's actually 4.25.18. PW might have had .17 cached as the newest version. I'll update again.

Nope, 18 was a brand new version (after your bug report).

39 minutes ago, gRegor said:

4.25.18 appears to still have the issue. It's in these lines:

Sorry, I missed that line - I did get the one (and one other) from your initial report, but that was one I missed.

The latest should hopefully be OK now.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...