jploch Posted April 25, 2023 Share Posted April 25, 2023 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 More sharing options...
adrian Posted May 9, 2023 Share Posted May 9, 2023 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? 1 Link to comment Share on other sites More sharing options...
jploch Posted May 10, 2023 Author Share Posted May 10, 2023 @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 More sharing options...
adrian Posted May 10, 2023 Share Posted May 10, 2023 Looks like we've been down this path before: 1 Link to comment Share on other sites More sharing options...
jploch Posted May 11, 2023 Author Share Posted May 11, 2023 @adrian Sorry I totally forgot about this ? I can live with it. Since it only happens sometimes and only locally, it's fine. Thanks for your time! Link to comment Share on other sites More sharing options...
gRegor Posted February 26 Share Posted February 26 (edited) 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 February 26 by gRegor Additional debug info 1 Link to comment Share on other sites More sharing options...
adrian Posted February 26 Share Posted February 26 @gRegor - thanks - should be fixed in the latest version. Note that PW's core might also suffer from this here: https://github.com/processwire/processwire/blob/3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7/wire/core/WireInput.php#L991 Link to comment Share on other sites More sharing options...
gRegor Posted February 26 Share Posted February 26 @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. Link to comment Share on other sites More sharing options...
gRegor Posted February 26 Share Posted February 26 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 More sharing options...
gRegor Posted February 26 Share Posted February 26 Related: a helpful lib I've been using for URL normalization and parsing is https://sabre.io/uri/ Link to comment Share on other sites More sharing options...
adrian Posted February 26 Share Posted February 26 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now