jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/129095 )
Change subject: Document Special:Diff and Special:PermanentLink ...................................................................... Document Special:Diff and Special:PermanentLink If no revision is given to Special:Diff or PermaLink show a form (cf. Special:ComparePages) List these on Special:SpecialPages under "redirects". Bug: 45221 Change-Id: I77edd4a1bbd342d4d18c27d5bc10dac76b8ab6c9 --- M includes/specialpage/RedirectSpecialPage.php M includes/specials/SpecialDiff.php M includes/specials/SpecialPermanentLink.php M languages/i18n/en.json M languages/i18n/qqq.json 5 files changed, 115 insertions(+), 7 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/specialpage/RedirectSpecialPage.php b/includes/specialpage/RedirectSpecialPage.php index 9b5d5f4..4e5da97 100644 --- a/includes/specialpage/RedirectSpecialPage.php +++ b/includes/specialpage/RedirectSpecialPage.php @@ -52,8 +52,7 @@ return $redirect; } else { - $class = static::class; - throw new MWException( "RedirectSpecialPage $class doesn't redirect!" ); + $this->showNoRedirectPage(); } } @@ -106,6 +105,11 @@ public function personallyIdentifiableTarget() { return false; } + + protected function showNoRedirectPage() { + $class = static::class; + throw new MWException( "RedirectSpecialPage $class doesn't redirect!" ); + } } /** diff --git a/includes/specials/SpecialDiff.php b/includes/specials/SpecialDiff.php index 9804e77..28cd0d1 100644 --- a/includes/specials/SpecialDiff.php +++ b/includes/specials/SpecialDiff.php @@ -56,11 +56,64 @@ $this->mAddedRedirectParams['oldid'] = $parts[0]; $this->mAddedRedirectParams['diff'] = $parts[1]; } else { - // Wrong number of parameters, bail out - $this->addHelpLink( 'Help:Diff' ); - throw new ErrorPageError( 'nopagetitle', 'nopagetext' ); + return false; } return true; } + + protected function showNoRedirectPage() { + $this->addHelpLink( 'Help:Diff' ); + $this->setHeaders(); + $this->outputHeader(); + $this->showForm(); + } + + private function showForm() { + $form = HTMLForm::factory( 'ooui', [ + 'oldid' => [ + 'name' => 'oldid', + 'type' => 'int', + 'label-message' => 'diff-form-oldid', + ], + 'diff' => [ + 'name' => 'diff', + 'class' => 'HTMLTextField', + 'label-message' => 'diff-form-revid', + ], + ], $this->getContext(), 'diff-form' ); + $form->setSubmitTextMsg( 'diff-form-submit' ); + $form->setSubmitCallback( [ $this, 'onFormSubmit' ] ); + $form->show(); + } + + public function onFormSubmit( $formData ) { + $params = []; + if ( $formData['oldid'] ) { + $params[] = $formData['oldid']; + } + if ( $formData['diff'] ) { + $params[] = $formData['diff']; + } + $title = $this->getPageTitle( $params ? implode( '/', $params ) : null ); + $url = $title->getFullUrlForRedirect(); + $this->getOutput()->redirect( $url ); + } + + public function getDescription() { + // 'diff' message is in lowercase, using own message + return $this->msg( 'diff-form' )->text(); + } + + public function getName() { + return 'diff-form'; + } + + public function isListed() { + return true; + } + + protected function getGroupName() { + return 'redirects'; + } } diff --git a/includes/specials/SpecialPermanentLink.php b/includes/specials/SpecialPermanentLink.php index 2bd3ab7..b1772b7 100644 --- a/includes/specials/SpecialPermanentLink.php +++ b/includes/specials/SpecialPermanentLink.php @@ -39,11 +39,44 @@ public function getRedirect( $subpage ) { $subpage = intval( $subpage ); if ( $subpage === 0 ) { - # throw an error page when no subpage was given - throw new ErrorPageError( 'nopagetitle', 'nopagetext' ); + return false; } $this->mAddedRedirectParams['oldid'] = $subpage; return true; } + + protected function showNoRedirectPage() { + $this->setHeaders(); + $this->outputHeader(); + $this->showForm(); + } + + private function showForm() { + $form = HTMLForm::factory( 'ooui', [ + 'revid' => [ + 'type' => 'int', + 'name' => 'revid', + 'label-message' => 'permanentlink-revid', + ], + ], $this->getContext(), 'permanentlink' ); + $form->setSubmitTextMsg( 'permanentlink-submit' ); + $form->setSubmitCallback( [ $this, 'onFormSubmit' ] ); + $form->show(); + } + + public function onFormSubmit( $formData ) { + $revid = $formData['revid']; + $title = $this->getPageTitle( $revid ?: null ); + $url = $title->getFullUrlForRedirect(); + $this->getOutput()->redirect( $url ); + } + + public function isListed() { + return true; + } + + protected function getGroupName() { + return 'redirects'; + } } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 61a113e..86ac78e 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3917,6 +3917,15 @@ "compare-invalid-title": "The title you specified is invalid.", "compare-title-not-exists": "The title you specified does not exist.", "compare-revision-not-exists": "The revision you specified does not exist.", + "diff-form": "Differences", + "diff-form-oldid": "Old revision ID (optional)", + "diff-form-revid": "Revision ID of difference", + "diff-form-submit": "Show differences", + "diff-form-summary": "", + "permanentlink": "Permanent link", + "permanentlink-revid": "Revision ID", + "permanentlink-submit": "Go to revision", + "permanentlink-summary": "", "dberr-problems": "Sorry! This site is experiencing technical difficulties.", "dberr-again": "Try waiting a few minutes and reloading.", "dberr-info": "(Cannot access the database: $1)", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 7be71f0..62b4d66 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -4107,6 +4107,15 @@ "compare-invalid-title": "Used as error message in [[Special:ComparePages]].", "compare-title-not-exists": "Used as error message in [[Special:ComparePages]].", "compare-revision-not-exists": "Used as error message in [[Special:ComparePages]].", + "permanentlink": "The title of [[Special:PermanentLink]]", + "permanentlink-revid": "Label for the field for the revision ID in [[Special:PermanentLink]]", + "permanentlink-submit": "Submit button on [[Special:PermanentLink]]", + "permanentlink-summary": "{{doc-specialpagesummary|permanentlink}}", + "diff-form": "The title of [[Special:Diff]]", + "diff-form-summary": "{{doc-specialpagesummary|diff}}", + "diff-form-oldid": "Label for the field of the old revision in the comparison for [[Special:Diff]]", + "diff-form-revid": "Label for the field of the new revision in the comparison for [[Special:Diff]]", + "diff-form-submit": "Submit button on [[Special:Diff]]", "dberr-problems": "This message does not allow any wiki nor html markup.", "dberr-again": "This message does not allow any wiki nor html markup.", "dberr-info": "This message does not allow any wiki nor html markup. Parameters:\n* $1 - database server name\nSee also:\n* {{msg-mw|Dberr-info-hidden}} - hides database server name", -- To view, visit https://gerrit.wikimedia.org/r/129095 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I77edd4a1bbd342d4d18c27d5bc10dac76b8ab6c9 Gerrit-PatchSet: 9 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Ajraddatz <ajradd...@gmail.com> Gerrit-Reviewer: Aldnonymous <aldnonymo...@gmail.com> Gerrit-Reviewer: Bartosz DziewoĆski <matma....@gmail.com> Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: PiRSquared17 <pirsquare...@gmail.com> Gerrit-Reviewer: Scott Martin <sc...@urbigenous.net> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits