Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displays friendly URLs correctly in error log #8443

Conversation

Sesquipedalian
Copy link
Member

Fixes #8440

Previously we had attempted to be clever about figuring out what parts of the URL to record in the log and then about how to reconstruct the complete URL when displaying the log.

Now we keep it simple:

  • When recording, if the URL starts with Config::$boardurl, we chop off Config::$boardurl and save the remainder. If the URL does not start with Config::$boardurl for whatever reason, we record the whole URL.

  • When displaying, if the recorded value is a complete URL, we display it as-is. Otherwise, we prepend Config::$boardurl to it.

This does mean that people who have not enabled the option to hide index.php in their URLs will have /index.php at the start of all the recorded values in the url field of the error log table. But that's really not a big deal.

@Sesquipedalian Sesquipedalian merged commit da8514a into SimpleMachines:release-3.0 Feb 5, 2025
6 checks passed
@Sesquipedalian Sesquipedalian deleted the 3.0/friendly_urls_errorlog branch February 5, 2025 08:04
@@ -232,7 +233,7 @@ public function view(): void
'time' => Time::create('@' . $row['log_time'])->format(),
'timestamp' => $row['log_time'],
'url' => [
'html' => Utils::htmlspecialchars(!str_contains($row['url'], 'cron.php') ? (str_starts_with($row['url'], '?') ? Config::$scripturl : '') . $row['url'] : $row['url']),
'html' => Utils::htmlspecialchars((Url::create($row['url'])->isValid() ? '' : Config::$boardurl) . $row['url']),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if the url is valid, we show nothing, otherwise we assume its a partial url and add in the boardurl? Why not show it if its a valid url?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. If the URL is valid then we show it as-is. If it isn't then we prepend Config::$boardurl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3.0]: Friendly URLs not displayed/logged properly in Error Log
2 participants