Page MenuHomePhorge

No OneTemporary

Size
8 KB
Referenced Files
None
Subscribers
None
diff --git a/includes/editpage/Constraint/DoubleRedirectConstraint.php b/includes/editpage/Constraint/DoubleRedirectConstraint.php
index fd5ee1ab04c..59e73da1b3b 100644
--- a/includes/editpage/Constraint/DoubleRedirectConstraint.php
+++ b/includes/editpage/Constraint/DoubleRedirectConstraint.php
@@ -41,6 +41,8 @@ class DoubleRedirectConstraint implements IEditConstraint {
private Content $originalContent;
private LinkTarget $title;
private string $result;
+ public bool $willCreateSelfRedirect;
+ private ?LinkTarget $doubleRedirectTarget;
private RedirectLookup $redirectLookup;
/**
@@ -48,6 +50,7 @@ class DoubleRedirectConstraint implements IEditConstraint {
* @param Content $newContent
* @param Content $originalContent
* @param LinkTarget $title
+ * @param RedirectLookup $redirectLookup
*/
public function __construct(
bool $allowDoubleRedirects,
@@ -75,6 +78,11 @@ class DoubleRedirectConstraint implements IEditConstraint {
// fail if there was no previous content or the previous content already contained a double redirect
if ( !$currentTarget || !$currentTarget->isRedirect() ) {
$this->result = self::CONSTRAINT_FAILED;
+ $this->doubleRedirectTarget =
+ $this->redirectLookup->getRedirectTarget( $this->newContent->getRedirectTarget() );
+ $this->willCreateSelfRedirect =
+ $this->doubleRedirectTarget != null &&
+ $this->doubleRedirectTarget->isSameLinkAs( $this->title );
return self::CONSTRAINT_FAILED;
}
diff --git a/includes/editpage/EditPage.php b/includes/editpage/EditPage.php
index 2bf34e7e87b..a60920cc4e3 100644
--- a/includes/editpage/EditPage.php
+++ b/includes/editpage/EditPage.php
@@ -272,6 +272,9 @@ class EditPage implements IEditObject {
/** @var bool */
private $doubleRedirect = false;
+ /** @var bool */
+ private $doubleRedirectLoop = false;
+
/** @var bool */
private $allowDoubleRedirects = false;
@@ -2662,6 +2665,7 @@ class EditPage implements IEditObject {
$this->brokenRedirect = true;
} elseif ( $failed instanceof DoubleRedirectConstraint ) {
$this->doubleRedirect = true;
+ $this->doubleRedirectLoop = $failed->willCreateSelfRedirect;
}
}
@@ -3418,23 +3422,30 @@ class EditPage implements IEditObject {
}
if ( $this->doubleRedirect ) {
- $editContent = $this->toEditContent( $this->textbox1 );
- $redirectTarget = $editContent->getRedirectTarget();
-
- $doubleRedirectTarget = $this->redirectLookup->getRedirectTarget( $redirectTarget );
- $doubleRedirectTargetTitle = Title::castFromLinkTarget( $doubleRedirectTarget );
-
- $suggestedRedirectContent =
- $editContent->getContentHandler()->makeRedirectContent( $doubleRedirectTargetTitle );
- $suggestedRedirectCode =
- Html::element( 'pre', [], $this->toEditText( $suggestedRedirectContent ) );
-
- $out->wrapWikiMsg( "<div id='mw-doubleredirect'>\n$1\n</div>", [
- 'edit-constraint-doubleredirect',
- $buttonLabel,
- wfEscapeWikiText( $doubleRedirectTargetTitle->getPrefixedText() ),
- $suggestedRedirectCode,
- ] );
+ if ( $this->doubleRedirectLoop ) {
+ $out->wrapWikiMsg(
+ "<div id='mw-doubleredirectloop'>\n$1\n</div>",
+ [ 'edit-constraint-doubleredirect-loop', $buttonLabel ]
+ );
+ } else {
+ $editContent = $this->toEditContent( $this->textbox1 );
+ $redirectTarget = $editContent->getRedirectTarget();
+
+ $doubleRedirectTarget = $this->redirectLookup->getRedirectTarget( $redirectTarget );
+ $doubleRedirectTargetTitle = Title::castFromLinkTarget( $doubleRedirectTarget );
+
+ $suggestedRedirectContent =
+ $editContent->getContentHandler()->makeRedirectContent( $doubleRedirectTargetTitle );
+ $suggestedRedirectCode =
+ Html::element( 'pre', [], $this->toEditText( $suggestedRedirectContent ) );
+
+ $out->wrapWikiMsg( "<div id='mw-doubleredirect'>\n$1\n</div>", [
+ 'edit-constraint-doubleredirect',
+ $buttonLabel,
+ wfEscapeWikiText( $doubleRedirectTargetTitle->getPrefixedText() ),
+ $suggestedRedirectCode,
+ ] );
+ }
}
if ( $this->hookError !== '' ) {
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index eb42a43c653..d98e4a32f1f 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -602,6 +602,7 @@
"selfredirect": "<strong>Warning:</strong> You are redirecting this page to itself.\nYou may have specified the wrong target for the redirect, or you may be editing the wrong page.\nIf you click \"$1\" again, the redirect will be created anyway.",
"edit-constraint-brokenredirect": "<strong>Warning:</strong> You are redirecting this page to a page which does not exist.\nYou may have specified the wrong target for the redirect.\nIf you click \"$1\" again, the redirect will be created anyway.",
"edit-constraint-doubleredirect": "<strong>Warning:</strong> You are trying to redirect this page to a second redirect page, creating a double redirect.\nYour target page currently redirects to [[$2]].\n\nPlease consider revising the content of this redirect as follows:\n$3\n\nNote: If you click \"$1\" again, the double redirect will be created anyway.",
+ "edit-constraint-doubleredirect-loop": "<strong>Warning:</strong> You are trying to redirect this page to a redirect back to itself, thus creating a non-functioning redirect loop. Please reconsider what you are doing. If you click \"$1\" again, the redirect will be created anyway.",
"missingcommenttext": "Please enter a comment.",
"missingcommentheader": "<strong>Reminder:</strong> You have not provided a subject for this comment.\nIf you click \"$1\" again, your edit will be published without one.",
"summary-preview": "Preview of edit summary:",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 9a75df38be4..9cb555a55ac 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -874,6 +874,7 @@
"selfredirect": "Notice displayed once after the user tries to create a redirect to the same article.\n\nParameters:\n* $1 – The label of the save button – one of {{msg-mw|savearticle}} or {{msg-mw|savechanges}} on save-labelled wiki, or {{msg-mw|publishpage}} or {{msg-mw|publishchanges}} on publish-labelled wikis.",
"edit-constraint-brokenredirect": "Notice displayed once after the user tries to create a redirect to a nonexistent page.\n\nParameters:\n* $1 - The label of the save button – one of {{msg-mw|savearticle}} or {{msg-mw|savechanges}} on save-labelled wiki, or {{msg-mw|publishpage}} or {{msg-mw|publishchanges}} on publish-labelled wikis.",
"edit-constraint-doubleredirect": "Notice displayed once after the user tries to create a redirect to another redirect.\n\nParameters:\n* $1 - The label of the save button – one of {{msg-mw|savearticle}} or {{msg-mw|savechanges}} on save-labelled wiki, or {{msg-mw|publishpage}} or {{msg-mw|publishchanges}} on publish-labelled wikis.\n* $2 - The name of the page the double redirect is targeting.",
+ "edit-constraint-doubleredirect-loop": "Notice displayed once after the user tries to create a redirect to another redirect that would create a redirect loop.\n\nParameters:\n* $1 - The label of the save button – one of {{msg-mw|savearticle}} or {{msg-mw|savechanges}} on save-labelled wiki, or {{msg-mw|publishpage}} or {{msg-mw|publishchanges}} on publish-labelled wikis.",
"missingcommenttext": "This message is shown when the user tries to save a textbox created by the new section links, and the textbox is empty. \"Comment\" refers to the content that is supposed to be posted in the new section, usually a talk page comment.",
"missingcommentheader": "Edit summary that is shown if you enable \"Prompt me when entering a blank summary\" and add a new section without headline to a talk page.\n\nParameters:\n* $1 – The label of the save button – one of {{msg-mw|savearticle}} or {{msg-mw|savechanges}} on save-labelled wiki, or {{msg-mw|publishpage}} or {{msg-mw|publishchanges}} on publish-labelled wikis.\n\n\"Subject\" is {{msg-mw|subject}}.\n\nSee also:\n* {{msg-mw|Missingsummary}}\n* {{msg-mw|Savearticle}}",
"summary-preview": "Preview of the edit summary, shown under the edit summary itself.\nShould match: {{msg-mw|summary}}.",

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:32 AM (23 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227654
Default Alt Text
(8 KB)

Event Timeline