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

Additional redirects for mongodb set-to-book conversion #1103

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion error.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,14 @@
'regexp.reference' => 'regexp.introduction',
"security" => "manual/security",

// Set to book
// MongoDB converted from set to book
'set.mongodb' => 'book.mongodb',
'mongodb.installation.homebrew' => 'mongodb.installation',
Copy link
Member Author

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.

Copy link
Member

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 = [

Copy link
Member Author

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.

'mongodb.installation.manual' => 'mongodb.installation',
'mongodb.installation.pecl' => 'mongodb.installation',
'mongodb.installation.windows' => 'mongodb.installation',
'mongodb.persistence.deserialization' => 'mongodb.persistence',
'mongodb.persistence.serialization' => 'mongodb.persistence',
];

if (isset($manual_page_moves[$URI])) {
Expand Down
Loading