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

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Oct 24, 2024

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

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
Copy link

github-actions bot commented Oct 24, 2024

🚀 Regression report for commit e6407c6 is at https://web-php-regression-report-pr-1103.preview.thephp.foundation

Copy link

github-actions bot commented Oct 24, 2024

🚀 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',
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.

if (count($parts) === 1) {
mirror_redirect("/manual/{$match[1]}/{$parts[0]}.php");
} else {
mirror_redirect("/manual/{$match[1]}/{$parts[0]}.php#{$parts[1]}");
Copy link
Member Author

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]).

Copy link
Member

@sy-records sy-records left a comment

Choose a reason for hiding this comment

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

LGTM.

@sy-records sy-records merged commit 08cc46b into php:master Oct 25, 2024
5 checks passed
@jmikola jmikola deleted the mongodb-redirects branch October 25, 2024 18:10
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 participants