-
Notifications
You must be signed in to change notification settings - Fork 538
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
Additional redirects for mongodb set-to-book conversion #1103
Conversation
The first redirect was added in php#1100, but additional sections that no longer have their own page were missed. The original conversion was done in php/doc-en#3627 and php/doc-base#138. https://jira.mongodb.org/browse/PHPC-1247
🚀 Regression report for commit e6407c6 is at https://web-php-regression-report-pr-1103.preview.thephp.foundation |
🚀 Preview for commit e6407c6 can be found at https://web-php-pr-1103.preview.thephp.foundation |
error.php
Outdated
'set.mongodb' => 'book.mongodb', | ||
'mongodb.installation.homebrew' => 'mongodb.installation', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered redirecting to the URL fragment (#mongodb.installation.homebrew), which appears to be supported, but the logic in elseif
below always appends .php
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe (untested):
error.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/error.php b/error.php
index 56a375fe..70f8e460 100644
--- a/error.php
+++ b/error.php
@@ -259,7 +259,12 @@ if (isset($manual_page_moves[$URI])) {
} elseif (preg_match("!^manual/([^/]+)/([^/]+).php$!", $URI, $match) &&
isset($manual_page_moves[$match[2]])) {
status_header(301);
- mirror_redirect("/manual/$match[1]/" . $manual_page_moves[$match[2]] . ".php");
+ $parts = explode("#", $manual_page_moves[$match[2]], 2);
+ if (count($parts) === 1) {
+ mirror_redirect("/manual/$match[1]/" . $parts[0] . ".php");
+ } else {
+ mirror_redirect("/manual/$match[1]/" . $parts[0] . ".php" . "#" . $parts[1]);
+ }
}
$manual_redirections = [
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed outside the scope of this PR, so I erred on not adding it. Happy to do so if there are no objections, though.
if (count($parts) === 1) { | ||
mirror_redirect("/manual/{$match[1]}/{$parts[0]}.php"); | ||
} else { | ||
mirror_redirect("/manual/{$match[1]}/{$parts[0]}.php#{$parts[1]}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically not required, but I opted for curly syntax here for readability. I'm not sure why concatenation was used in the original code (seemed inconsistent since interpolation was already used for $match[1]
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The first redirect was added in #1100, but additional sections that no longer have their own page were missed. The original conversion was done in php/doc-en#3627 and php/doc-base#138.
https://jira.mongodb.org/browse/PHPC-1247